Afonso_Diaz2023-05-04 05:23 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,
symbol,
decimals,
token_address,
avg(price) as price_usd
from avalanche.core.fact_hourly_token_prices
group by 1, 2, 3, 4
),
t2 as (
select
tx_hash,
t.symbol as symbol,
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 }}')
union all
select
tx_hash,
t.symbol as symbol,
block_timestamp,
case
when amount_out_usd is not null then amount_out_usd
when token_address = null then null
Run a query to Download Data