Sbhn_NPeth swap activity
Updated 2022-10-14
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
›
⌄
WITH
eth_price as (
SELECT
date_trunc('day',hour) as day,
avg(price) as eth_price
from ethereum.core.fact_hourly_token_prices
where symbol='WETH' and hour >='2022-09-01'
group by 1
),
eth_dex as (
SELECT
date_trunc('day',block_timestamp) as day,
sum(case when symbol_in='WETH' then amount_in end) as volume_in,
sum(case when symbol_out='WETH' then amount_out end) as volume_out,
avg(case when symbol_in='WETH' then amount_in end) as avg_volume_in,
avg(case when symbol_out='WETH' then amount_out end) avg_volume_out,
count(case when symbol_in='WETH' then 1 end) as swaps_in,
count(case when symbol_out='WETH' then 1 end) as swaps_out
from ethereum.core.ez_dex_swaps where (symbol_in='WETH' or symbol_out='WETH') and block_timestamp >='2022-09-01'
and amount_in_usd<1e9 and amount_out_usd<1e9
group by 1
)
SELECT
x.day,
volume_in,
volume_out,
volume_in-volume_out as net_volume ,
avg_volume_in,
avg_volume_out,
swaps_in,
swaps_out,
swaps_in-swaps_out as net_swaps,
eth_price
from eth_dex x join eth_price y on x.day=y.DAY
order by 1 asc
Run a query to Download Data