farid-c9j0VMDaily total Loss and Gain from stETH to ETH
    Updated 2022-06-13
    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