mar1na-catscatscodetrader joe avax swaps
Updated 2022-06-28Copy Reference Fork
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
›
⌄
select
-- date_trunc('hour', block_timestamp) as block_hour,
block_timestamp::date as block_date,
count(distinct tx_hash) as n_swaps,
count(distinct origin_from_address) as n_swappers,
sum(amount) as amount_avax,
amount_avax/n_swaps as avg_avax_per_swap,
amount_avax/n_swappers as avg_avax_per_user,
n_swaps/n_swappers as swaps_per_user
from avalanche.core.ez_avax_transfers
where origin_to_address = '0x60ae616a2155ee3d9a68541ba4544862310933d4' -- trader joe router
and tx_hash in (select tx_hash from (
select
t1.block_timestamp::date as block_date,
t1.tx_hash,
t1.origin_function_signature,
t1.origin_from_address,
t2.address_name
-- t3.event_inputs
from avalanche.core.fact_token_transfers t1
join avalanche.core.dim_labels t2 on t2.address = t1.origin_to_address
-- join avalanche.core.fact_event_logs t3 on t3.tx_hash = t1.tx_hash
where t2.label_type = 'dex'
and t2.label_subtype = 'swap_contract'
and block_date >= '2022-06-10'
-- and (t3.event_inputs:amount0In is not null or t3.event_inputs:amount1In is not null)
))
group by block_date
Run a query to Download Data