Afonso_Diaz2023-05-04 06:05 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 }}')
),
t3 as (
select date_trunc('week', min_date)::date as week,
count(distinct user) as new_swappers
from (
select
user,
min(block_timestamp)::date as min_date
from t2
group by 1
)
Run a query to Download Data