bachiethswaps lido1
Updated 2022-06-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
›
⌄
-- Swaps by Staker
with ethtosteth as (
select sender as staker, sum(amount_in) as amount_swapped_in, sum(amount_out) as amount_swapped_out,
sum(amount_in_usd) as amount_swapped_in_usd, sum(amount_out_usd) as amount_swapped_out_usd,
'ETH to stETH' as swap_catg from ethereum.core.ez_dex_swaps
where event_name='Swap'
and symbol_out = 'stETH' and symbol_in like '%ETH' and token_in = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
and token_out = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84' and amount_in > 0 and amount_in is not null
and amount_out > 0 and amount_out is not null and amount_in_usd > 0 and amount_in_usd is not null and
amount_out_usd >0 and amount_out_usd is not null
group by sender ),
stethtoeth as (
select sender as staker, sum(amount_in) as amount_swapped_in, sum(amount_out) as amount_swapped_out,
sum(amount_in_usd) as amount_swapped_in_usd, sum(amount_out_usd) as amount_swapped_out_usd,
'stETH to ETH' as swap_catg from ethereum.core.ez_dex_swaps where event_name='Swap'
and symbol_out like '%ETH' and symbol_in= 'stETH' and token_in = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84'
and token_out = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' and amount_in is not null and amount_in > 0
and amount_out > 0 and amount_out is not null and amount_in_usd is not null and amount_in_usd > 0
and amount_out_usd > 0 and amount_out_usd is not null
group by sender
)
select staker,
case when amount_swapped_in > amount_swapped_out then 'Lose'
when amount_swapped_in < amount_swapped_out then 'Gain'
end as loss_or_gain,
case when amount_swapped_in > amount_swapped_out then (amount_swapped_in - amount_swapped_out)
when amount_swapped_in < amount_swapped_out then (amount_swapped_out- amount_swapped_in)
end as loss_or_gain_amount,
case when amount_swapped_in_usd > amount_swapped_out_usd then (amount_swapped_in_usd - amount_swapped_out_usd)
when amount_swapped_in_usd < amount_swapped_out_usd then (amount_swapped_out_usd- amount_swapped_in_usd)
end as loss_or_gain_amount_usd,
swap_catg from ethtosteth
union
select staker,
Run a query to Download Data