MoeUntitled Query
Updated 2022-09-24
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 base as (select date_trunc(day,block_timestamp) as days,* from ethereum.aave.ez_withdraws
where symbol ilike 'weth'),
--Moe
price as (
select
date_trunc(days,hour)::date as days,
avg (price) as price
from
ethereum. core.fact_hourly_token_prices
where
symbol ilike 'weth'
group by 1
),
--Moe
base2 as (select
b.*,price,WITHDRAWN_TOKENS*price as AMOUNT_WITHDRAWN from base b, price p where b.days = p.days)
SELECT
--Moe
date_trunc('day', block_timestamp) as weeks,
avg(price) price,
count(DISTINCT tx_hash) as num_txs,
COUNT(DISTINCT DEPOSITOR_ADDRESS) as num_users,
sum(AMOUNT_WITHDRAWN) as total_withdraw_usd,
avg(AMOUNT_WITHDRAWN) as avg_withdraw_usd,
sum(total_withdraw_usd)over(order by weeks rows between unbounded preceding and current row ) as cumulative_total_withdraw_usd,
100*(total_withdraw_usd-lag(total_withdraw_usd,1)over(order by weeks))/lag(total_withdraw_usd,1)over(order by weeks) lag_total_withdraw_usd
FROM base2
WHERE 1=1
and block_timestamp ilike '%2022%'
and symbol ILIKE 'WETH'
GROUP BY weeks
Run a query to Download Data