maybeyonaseth_rem_uni_swaps
Updated 2022-09-18
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
›
⌄
-- positive inflows to protocol
with swaps as (
select
block_timestamp,
tx_hash,
case
when token0_symbol = 'WETH' then amount0_adjusted
when token1_symbol = 'WETH' then amount1_adjusted
else 'sus' end as amt,
case when amt <0 then 'out' else 'in' end as direction,
case
when token0_symbol = 'WETH' then token1_symbol
when token1_symbol = 'WETH' then token0_symbol
else 'sus' end as token
from ethereum.uniswapv3.ez_swaps
where (token0_symbol = 'WETH' or token1_symbol ='WETH')
)
select *,
case when net_vol < 0 then 'out' else 'in' end as direction
from (
select
date(block_timestamp) as date,
-- direction,
sum(amt) as net_vol
from swaps
group by 1
order by date desc
limit 180
)