ArioTraderJoe Fee Volume
    Updated 2023-10-11
    -- forked from Avalanche dex Fee Volume @ https://flipsidecrypto.xyz/edit/queries/bb4a8db4-246d-489b-bd14-45e6a2e4f9fb

    with
    price_{{Blokchain}} as (
    select
    date_trunc({{Granularity}}, HOUR) as date,
    avg(PRICE) as avg_Price
    from
    {{Blokchain}}.price.ez_hourly_token_prices
    where
    1=1
    and TOKEN_ADDRESS is not NULL
    and symbol in (case when '{{Blokchain}}' = 'Avalanche' then 'WAVAX'
    when '{{Blokchain}}' = 'Bsc' then 'WBNB' else 'WETH' end)
    group by
    1
    ),
    platforms as (
    select
    tx_hash
    from {{Blokchain}}.defi.ez_dex_swaps
    where 1=1
    and platform in ('trader-joe-v1', 'trader-joe-v2')
    and block_timestamp::date between '{{Start_date}}' and '{{End_date}}'
    )
    select
    date::date as date,
    round("Fee Volume ($)", 2) as "Fee Volume ($)",
    round(sum("Fee Volume ($)") over (
    order by
    date
    ), 2) as "Cum. Fee Volume ($)",
    avg("Fee Volume ($)") over(order by date rows between 6 preceding and current row) as "MA 7D - Fee Volume ($)"
    from
    (
    SELECT
    Run a query to Download Data