0xHaM-dSwap
Updated 2022-11-28Copy 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 eth_swaps as (
select
date_trunc('{{Interval}}', block_timestamp) as date,
Count(DISTINCT tx_hash) as eth_swaps,
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,
case
when token_out ='0xae7ab96520de3a18e5e111b5eaab095312d7fe84' then 'ETH => stETH'
when token_out ='0xe95a203b1a91a908f9b9ce46459d101078c2c3cb' then 'ETH => aETH'
when token_out ='0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593' then 'ETH => rETH'
end AS swap_catg
from ethereum.core.ez_dex_swaps
where event_name = 'Swap'
AND token_in = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
AND token_out in ('0xae7ab96520de3a18e5e111b5eaab095312d7fe84', '0xe95a203b1a91a908f9b9ce46459d101078c2c3cb', '0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593')
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
and block_timestamp::date >= '{{Since_date}}'
group by 1,7
)
,steth_swaps as (
select
date_trunc('{{Interval}}', block_timestamp) as date,
Count(DISTINCT tx_hash) as steth_swaps,
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,
Run a query to Download Data