ArioOptimism-WETH Correlation of WETH Swap Volume and OP Price
    Updated 2023-04-15
    with Swap as (
    select
    date_trunc(hour, block_timestamp) as date,
    sum(amount_out_usd) as "Swap Volume(USD)"
    from optimism.core.ez_dex_swaps
    where EVENT_NAME = 'Swap'
    and SYMBOL_IN = 'WETH'
    and SYMBOL_OUT = 'OP'
    and amount_out_usd is not null
    and BLOCK_TIMESTAMP >= Current_date - 60
    and BLOCK_TIMESTAMP < Current_date
    group by 1
    ),
    price as (
    select
    date_trunc(hour, hour)::date as date,
    avg(price) as price
    from optimism.core.fact_hourly_token_prices
    where symbol = 'OP'
    and hour >= Current_date - 60
    and hour < Current_date
    group by 1
    ),
    main_table as (
    select
    a.*,
    b.price
    from Swap a join price b on a.date = b.date
    )
    select
    case
    when price < 2 then 'Tier 1: Less than $2'
    when price between 2 and 2.3 then 'Tier 2: $2-2.3'
    when price between 2.3 and 2.6 then 'Tier 3: $2.3-2.6'
    when price between 2.6 and 2.9 then 'Tier 4: $2.6-2.9'
    when price between 2.9 and 3.1 then 'Tier 5: $2.9-3.1'
    Run a query to Download Data