Moe3 gran - dep
Updated 2023-03-06Copy Reference Fork
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 prices as (
select
hour::date as days,
SYMBOL,token_ADDRESS,DECIMALS,
avg(PRICE) as price
from
optimism.core.fact_hourly_token_prices
group by 1,2,3,4
)
,base as (select
SYMBOL,price*RAW_AMOUNT/pow(10,decimals) as usd_amount,x.*
from
optimism.core.fact_token_transfers x
join prices y on x.CONTRACT_ADDRESS=y.token_ADDRESS
where
ORIGIN_TO_ADDRESS = '0x8fd4af47e4e63d1d2d45582c3286b4bd9bb95dfe'
and ORIGIN_FUNCTION_SIGNATURE='0xe8eda9df' -- deposit
)
select
BLOCK_TIMESTAMP::date as days,
SYMBOL ,
count(distinct tx_hash) as txs_count,
sum(txs_count)over(partition by SYMBOL order by days rows between unbounded preceding and current row ) as cumulative_txs_count,
count(distinct origin_from_address) as users,
sum(users)over(partition by SYMBOL order by days rows between unbounded preceding and current row ) as cumulative_users,
sum(USD_AMOUNT) as amount_usd,
sum(amount_usd)over(partition by SYMBOL order by days rows between unbounded preceding and current row ) as cumulative_amount_usd,
avg(USD_AMOUNT) as avg_USD_AMOUNT,
avg(avg_USD_AMOUNT)over(partition by SYMBOL order by days rows between 6 preceding and current row ) as m_avg7_usd
from base
Run a query to Download Data