0xHaM-dC1
Updated 2024-07-06
999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with final as (
select
date_trunc('{{Time_Interval}}', BLOCK_TIMESTAMP)::date as date,
'Borrow' as type,
count(DISTINCT(tx_hash)) as total_tx,
count(DISTINCT(BORROWER)) as total_user,
sum(LOAN_AMOUNT_USD) as total_volume,
avg(LOAN_AMOUNT_USD) as avg_volume,
sum(total_tx) over (partition by type order by date) as cum_tx,
sum(total_volume) over (partition by type order by date) as cum_volume,
avg(total_volume) over (partition by type order by date asc rows between 6 preceding and current row ) as avg_7_days_moving
from ethereum.compound.ez_borrows
where block_timestamp::date >= CURRENT_DATE - INTERVAL '{{Past_Weeks}} WEEK'
group by 1,2
UNION
select
date_trunc('{{Time_Interval}}', BLOCK_TIMESTAMP)::date as date,
'Deposit' as type,
count(DISTINCT(tx_hash)) as total_tx,
count(DISTINCT(SUPPLIER)) as total_user,
sum(SUPPLIED_BASE_ASSET_USD) as total_volume,
avg(SUPPLIED_BASE_ASSET_USD) as avg_volume,
sum(total_tx) over (partition by type order by date) as cum_tx,
sum(total_volume) over (partition by type order by date) as cum_volume,
avg(total_volume) over (partition by type order by date asc rows between 6 preceding and current row ) as avg_7_days_moving
from ethereum.compound.ez_deposits
where block_timestamp::date >= CURRENT_DATE - INTERVAL '{{Past_Weeks}} WEEK'
group by 1,2
UNION
select
date_trunc('{{Time_Interval}}', BLOCK_TIMESTAMP)::date as date,
'Repayment' as type,
QueryRunArchived: QueryRun has been archived