MuzeJoe Price
    Updated 2023-04-05


    with prices as (
    select
    date_trunc('day', recorded_hour) as day,
    avg( close ) as price

    from crosschain.core.fact_hourly_prices
    where id = 'joe'
    group by 1
    ),

    volume as (
    select
    date as day,
    sum( volume ) as volume

    from external.defillama.fact_dex_volume
    where chain = 'avalanche'
    and protocol in ( 'joe v2', 'trader joe dex')
    group by 1
    )

    select
    a.day,
    volume,
    price,
    sum( volume ) over(order by a.day) as cum_volume

    from prices a
    left join volume b on a.day = b.day
    where a.day <= current_date - interval '3 days'
    -- group by 1
    order by 1 desc


    Run a query to Download Data