kiacryptoCorrelation between all swaps and Op price on both SushiSwap and Velodrome
    Updated 2022-10-06
    with swaps as (
    select
    date_trunc('week', block_timestamp) as date,
    tx_hash,
    origin_from_address,
    amount_in_usd as amount
    from optimism.sushi.ez_swaps
    union all
    select
    date_trunc('week', block_timestamp) as date,
    tx_hash,
    origin_from_address,
    amount_in_usd as amount
    from optimism.velodrome.ez_swaps
    ),
    op_price as (
    select
    date_trunc('week', hour) as date,
    avg (price) as price
    from optimism.core.fact_hourly_token_prices
    where symbol = 'OP'
    group by 1
    )
    select
    s.date,
    count(distinct tx_hash) as swap_count,
    count(distinct origin_from_address) as unique_swapper,
    sum(amount) as swaps_volume_usd,
    sum(swap_count) over (order by s.date) as cum_swap_count,
    sum(unique_swapper) over (order by s.date) as cum_unique_swapper,
    sum(swaps_volume_usd) over (order by s.date) as cum_sswaps_volume_usd,
    avg(price) as price
    from swaps s join op_price p on s.date = p.date
    group by 1
    Run a query to Download Data