phu[Post Merge Behavior] ETH swap from by new/return
Updated 2022-09-25
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
swap_from_cte as (
select
BLOCK_TIMESTAMP::date date
, ORIGIN_FROM_ADDRESS swapper
, sum(amount_in) amount
, count(tx_hash) tx_count
from ethereum.core.ez_dex_swaps
where 1=1
and token_in = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
group by 1,2
)
select
date
, grp
, amount
, swapper
, tx_count / swapper tx_count_per_swapper
from (
select
date
, case
when rn = 1 then 'new'
else 'return'
end grp
, sum(amount) amount
, sum(tx_count) tx_count
, count(distinct swapper) swapper
from (
select
date
, swapper
, amount
, tx_count
, row_number() over(partition by swapper order by date) rn
from swap_from_cte
Run a query to Download Data