RamaharSwapped from (native)
Updated 2022-11-02Copy 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
31
32
33
34
35
36
›
⌄
--ETH > OP
With native_bridge as ( select block_timestamp, origin_from_address, tx_hash, 'ETH' as symbol, amount_usd
from ethereum.core.ez_eth_transfers
where eth_to_address = lower('0x99c9fc46f92e8a1c0dec1b1747d010903e884be1')
UNION
select block_timestamp, origin_from_address, tx_hash, symbol, amount_usd
from ethereum.core.ez_token_transfers
where to_address = '0x99c9fc46f92e8a1c0dec1b1747d010903e884be1'),
first_tx as ( select min(block_timestamp) as date, origin_from_address
from native_bridge
where block_timestamp::date >= '2022-01-01'
group by 2)
,
second_tx as ( select min(block_timestamp) as m_date, a.origin_from_address
from optimism.velodrome.ez_swaps a join first_tx b on a.origin_from_address = b.origin_from_address
and date < block_timestamp
group by 2)
,
fnl as ( select date(block_timestamp) as dayz, a.origin_from_address as from_address , SYMBOL_IN, tx_hash, amount_in_usd
from optimism.velodrome.ez_swaps a join second_tx b on a.origin_from_address = b.origin_from_address
and block_timestamp = m_date
)
select
dayz,
SYMBOL_IN,
count(DISTINCT from_address) as daily_user,
count(DISTINCT(tx_hash)) as daily_total,
sum(daily_user) over (partition by symbol_in) as user,
sum(daily_total) over (partition by symbol_in) as total,
sum(daily_user) over (partition by symbol_in order by dayz asc rows between unbounded preceding and current row) as cumu_users,
sum(daily_total) over (partition by symbol_in order by dayz asc rows between unbounded preceding and current row) as cumu_total
from fnl
where symbol_in is not null
group by 1, 2
Run a query to Download Data