Eman-RazstETH: Price vs Swap volume
    Updated 2023-04-13
    with t1 as (select date_trunc('day', hour) as day, avg(price) as steth_price
    from ethereum.core.fact_hourly_token_prices
    where day>'2021-01-01' and token_address='0xae7ab96520de3a18e5e111b5eaab095312d7fe84'
    group by 1
    order by 1),
    t2 as (with buy as (select BLOCK_TIMESTAMP::date as day, sum(amount_out) as buying_volume
    from ethereum.core.ez_dex_swaps
    where token_out='0xae7ab96520de3a18e5e111b5eaab095312d7fe84' --stETH
    and day>='2021-01-01'
    group by 1
    order by 1),

    sell as (select BLOCK_TIMESTAMP::date as day, sum(amount_in) as selling_volume
    from ethereum.core.ez_dex_swaps
    where token_in='0xae7ab96520de3a18e5e111b5eaab095312d7fe84' --stETH
    and day>='2021-01-01'
    group by 1
    order by 1)

    select buy.day as time, buy.buying_volume as buy_vol, sell.selling_volume as sell_vol, (buy.buying_volume+sell.selling_volume) as swap_vol
    from buy full outer join sell
    on buy.day=sell.DAY
    order by 1)

    select t1.day , t1.steth_price as "stETH Price" ,t2.swap_vol as "stETH Swap Volume"
    from t1 full outer join t2 on t1.day=t2.time order by 1





    Run a query to Download Data