hessTop deposited per chain
Updated 2023-03-01
99
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 ethereum as (select symbol,'Ethereum' as chain, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(DEPOSITOR_ADDRESS)) as total_user,
sum(SUPPLIED_USD) as total_volume, avg(SUPPLIED_USD) as avg_volume,
median(SUPPLIED_USD) as median_volume, max(SUPPLIED_USD) as max_volume, min(SUPPLIED_USD) as min_volume
from ethereum.aave.ez_deposits
where block_timestamp::date >= CURRENT_DATE - {{N_Days}}
group by 1,2)
,
supply_tx as ( select DISTINCT tx_hash
from optimism.core.fact_event_logs
where origin_to_address = '0x794a61358d6845594f94dc1db02a252b5b4814ad'
and event_name = 'Mint'
and block_timestamp::date >= CURRENT_DATE - {{N_Days}})
,
supply as ( select 'Deposit' as type, 'Optimism' as chain, date(block_timestamp) as date, tx_hash , origin_from_address, contract_address as token, EVENT_INPUTS:value as raw_amount
from optimism.core.fact_event_logs
where origin_to_address = '0x794a61358d6845594f94dc1db02a252b5b4814ad'
and tx_hash in (select tx_hash from supply_tx)
and block_timestamp::date >= CURRENT_DATE - {{N_Days}}
and event_name = 'Transfer'
and origin_from_address = EVENT_INPUTS:from)
,
price as ( select date(hour) as date, token_address , symbol, decimals , avg(price) as avg_price
from optimism.core.fact_hourly_token_prices
where hour::date >= CURRENT_DATE - {{N_Days}}
and token_address in (select token from supply)
group by 1,2,3,4)
,
tb2 as ( select a.date, type, chain, tx_hash , origin_from_address, symbol, (raw_amount/pow(10,decimals))*avg_price as volume
from supply a left outer join price b on a.date = b.date and a.token = b.token_address
)
,
final_2 as ( select chain, symbol, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(origin_from_address)) as total_user,
sum(volume) as total_volume, avg(volume) as avg_volume
from tb2
group by 1,2
UNION
Run a query to Download Data