Updated 2023-09-07
    with pool_info as (
    select
    token0_address,
    token1_address,
    min(date(block_timestamp)) as min_date
    from ethereum.uniswapv3.ez_pool_stats
    where pool_address ilike '{{pool_info_address}}'
    group by 1,2
    ),


    first_token0_price as (select
    date(hour) as daily,
    symbol,
    avg(price) as daily_price

    from ethereum.core.fact_hourly_token_prices
    where token_address ilike (select distinct token0_address from pool_info)
    and
    daily = (select min_date from pool_info)
    group by 1,2
    ),
    last_token0_price as (select
    date(hour) as daily,
    symbol,
    avg(price) as daily_price

    from ethereum.core.fact_hourly_token_prices
    where token_address ilike (select distinct token0_address from pool_info)
    and
    daily>= (select min_date from pool_info)


    group by 1,2)

    ,
    Run a query to Download Data