Afonso_Diaz2023-05-04 06:04 PM
Updated 2023-05-04
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 t as (
select
hour::date as date,
decimals,
token_address,
avg(price) as price_usd
from avalanche.core.fact_hourly_token_prices
group by 1, 2, 3
),
t2 as (
select
tx_hash,
block_timestamp,
case
when amount_in_usd is not null then amount_in_usd
when token_address = null then null
else (amount_in / pow(10, decimals)) * price_usd
end as amount_usd,
origin_from_address as user
from avalanche.core.ez_dex_swaps
left join t on date = block_timestamp::date and token_in = token_address
where amount_usd is not null
and platform in ('{{ platform }}')
)
select
user as swapper,
count(distinct tx_hash) as swaps,
sum(amount_usd) as volume_usd,
avg(amount_usd) as average_volume_usd,
median(amount_usd) as median_volume_usd
from t2
group by 1
order by 3 desc
limit 10
Run a query to Download Data