farid-c9j0VMDaily total Loss and Gain from stETH to ETH
Updated 2022-06-13Copy 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 stETH as (
SELECT
date_trunc('day', hour) as day,
avg(price) as stETH_price
FROM ethereum.token_prices_hourly
WHERE token_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84'--stETH contract
GROUP BY 1
),
eth as (
SELECT
date_trunc('day', hour) as day,
avg(price) as ETH_price
FROM ethereum.token_prices_hourly
WHERE token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'--wETH contract
GROUP BY 1
),
peg as (
SELECT
stETH.day,
stETH.stETH_price as steth,
eth.ETH_price as eth,
steth / eth as price_peg
FROM stETH
LEFT OUTER JOIN eth
ON stETH.day = eth.day
),
buy_eth as (
SELECT
date_trunc('day', block_timestamp) as day,
sum(amount_out) as ETH_amount,
COUNT(to_address) as users
FROM ethereum.dex_swaps
WHERE pool_address = '0x4028daac072e492d34a3afdbef0ba7e35d8b55c4'
AND token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
Run a query to Download Data