afonsoOP stats daily
Updated 2023-04-06Copy 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
›
⌄
with t as (
select
block_timestamp,
tx_hash,
origin_from_address,
iff(symbol_in = 'OP', amount_in_usd, 0) as outflow_usd,
iff(symbol_in = 'OP', amount_out_usd, 0) as inflow_usd,
inflow_usd - outflow_usd as netflow
from optimism.sushi.ez_swaps
where 'OP' in (symbol_in, symbol_out)
union all
select
block_timestamp,
tx_hash,
origin_from_address,
iff(symbol_in = 'OP', amount_in_usd, 0) as outflow_usd,
iff(symbol_in = 'OP', amount_out_usd, 0) as inflow_usd,
inflow_usd - outflow_usd as netflow
from optimism.velodrome.ez_swaps
where 'OP' in (symbol_in, symbol_out)
)
select block_timestamp::date as day,
count(distinct tx_hash) as swaps_count,
count(origin_from_address) as swappers_count,
sum(inflow_usd) as inflow_volume_usd,
sum(outflow_usd) as outflow_volume_usd,
inflow_volume_usd - outflow_volume_usd as netflow_volume_usd,
sum (swaps_count) over (order by day) as cumulative_swaps_count,
sum(inflow_volume_usd) over (order by day) as cumulative_inflow_volume_usd,
sum(outflow_volume_usd) over (order by day) as cumulative_outflow_volume_usd,
sum(netflow_volume_usd) over (order by day) as cumulative_netflow_volume_usd
from t
where day >= '2022-01-01'
Run a query to Download Data