evetliuBASE - overall
Updated 2023-08-29
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
›
⌄
with pr_tab as
(select date(hour) as daily,token_address,symbol,ifnull(avg(price),0) as avg_price
from base.core.fact_hourly_token_prices
group by 1,2,3),
volume_1 as (select s.*,
amount_in*p1.avg_price as amount_inflow,
amount_out*p2.avg_price as amount_outflow
from (select date(block_timestamp) as daily,platform,tx_hash,
origin_from_address, pool_name,amount_in,amount_out,token_in,token_out
from base.defi.ez_dex_swaps) s
left outer join pr_tab p1
on s.daily = p1.daily and s.token_in = p1.token_address
left outer join pr_tab p2
on s.daily = p2.daily and s.token_out = p2.token_address),
volume_2 as (select daily, platform, tx_hash, origin_from_address, pool_name,
case when amount_inflow is null then amount_outflow else amount_inflow end as USD_volume
from volume_1)
select count(DISTINCT tx_hash) as count_transactions,
count(DISTINCT origin_from_address) as count_users,
sum(USD_volume) as total_usd_volume,
count_transactions/count_users as txn_per_user,
total_usd_volume/count_transactions as volume_per_txn
from volume_2
where platform ilike '%sushiswap%'
Run a query to Download Data