potmoVelodrome OHLC Price Action
    Updated 2023-04-13
    with price_per_swap as (
    select block_timestamp,
    flipside_prod_db.tokenflow_eth.hextoint(substring(data,1,66)) /1e18 as token0,
    flipside_prod_db.tokenflow_eth.hextoint(substring(data,67,130)) /1e6 as token1,
    token1 / token0 as velo_price
    from optimism.core.fact_event_logs
    where 1
    --and tx_hash ilike '0x0e7c77137eff40da43e88a4ea6e16f7cd924a8e7dd0ffb1f04ee35bfc3522aa4'
    and contract_address ilike '0xe8537b6ff1039cb9ed0b71713f697ddbadbb717d'
    -- and origin_to_address ilike '0x287f9681af590354d6722ac51e6935beef631941'
    and origin_function_signature ilike ('0xfdb5a03e')
    and topics[0] ilike '0xcf2aa%'
    --and block_timestamp = (select block_timestamp, max(1) from optimism.core.fact_event_logs group by 1)
    and block_timestamp::timestamp >= '2022-06-15'
    ),


    agg_prices as (
    select date_trunc('d', block_timestamp) as date_time,
    avg(velo_price) as avg_VELO_price,
    min(velo_price) as low,
    max(velo_price) as high,
    min(block_timestamp) as open_time,
    max(block_timestamp) as close_time
    from price_per_swap
    group by 1
    order by 1
    ),

    open_price as (
    select block_timestamp, velo_price as open
    from price_per_swap p
    where block_timestamp in (select distinct open_time from agg_prices)
    ),
    close_price as (
    select block_timestamp, velo_price as close
    Run a query to Download Data