CryptoIcicleLido-10.Gain or Lose
    Updated 2022-06-13
    -- Payout 75 USDC
    -- Grand Prize 225 USDC
    -- Level Intermediate

    -- Q10. Of the stakers that have swapped ETH to stETH, how much ETH did they gain or lose
    -- depending on the peg of stETH to ETH at the time of the swap?

    with steth_price as (
    select
    date_trunc('day', hour) as date,
    avg(price) as price
    from ethereum.token_prices_hourly
    where token_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84' -- stETH
    and hour >= '2021-01-01'
    group by date
    ),
    eth_price as (
    select
    date_trunc('day', hour) as date,
    avg(price) as price
    from ethereum.token_prices_hourly
    where symbol = 'WETH'
    and hour >= '2021-01-01'
    group by date
    ),
    ratio as (
    select
    s.date,
    s.price as steth,
    e.price as eth,
    eth/steth as eth_steth_ratio,
    steth/eth as steth_eth_ratio
    from steth_price s
    join eth_price e on s.date = e.date
    ),
    high_diff as (
    Run a query to Download Data