banbannardSlippery Slippage
Updated 2022-02-13
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 in_table as (select tx_id, amount_usd as amount_in, pool_address
from ethereum.dex_swaps
where platform = 'sushiswap'
and date_trunc('day', block_timestamp) >= current_date - 90
and direction = 'IN'),
out_table as (select tx_id, amount_usd as amount_out, pool_address
from ethereum.dex_swaps
where platform = 'sushiswap'
and date_trunc('day', block_timestamp) >= current_date - 90
and direction = 'OUT'),
tvl_table as (select date_trunc('day',balance_date) as day,
pool_name,
pool_address,
(sum(coalesce(amount_usd,0))) as sushi_tvl
from ethereum.erc20_balances a
join ethereum.dex_liquidity_pools b
on user_address = pool_address
where b.platform = 'sushiswap'
and date_trunc('day', a.balance_date) = current_date - 1
group by 1,2,3
order by 4 desc
limit 5),
table1 as (select a.tx_id,
pool_name,
amount_in - amount_out as difference
from in_table a
join out_table b
on a.tx_id = b.tx_id
join tvl_table c
on a.pool_address = c.pool_address
where (difference is not null)
and amount_in > 0
and amount_out > 0)
Run a query to Download Data