ArioPools Details
    Updated 2023-10-10
    -- forked from Pools Details @ https://flipsidecrypto.xyz/edit/queries/efbe20d3-86b4-4b9e-a8ea-58237aff98e1

    with
    price_{{Blokchain}} as (
    select
    date_trunc({{Granularity}}, HOUR) as date,
    TOKEN_ADDRESS,
    avg(PRICE) as avg_Price
    from
    {{Blokchain}}.price.ez_hourly_token_prices
    where 1=1
    and TOKEN_ADDRESS is not NULL
    group by
    1,
    2
    ),
    tab1 as (
    SELECT
    Pool_name,
    count(distinct tx_hash) as "# Swap",
    count(DISTINCT ORIGIN_FROM_ADDRESS) as "# Sawpper",
    sum(AMOUNT_IN * avg_Price) as "Swap Volume ($)",
    avg(AMOUNT_IN * avg_Price) as "Avg Swap Volume ($)"
    from
    {{Blokchain}}.defi.ez_dex_swaps a
    join price_{{Blokchain}} b on date_trunc({{Granularity}}, block_timestamp) = b.date
    and a.TOKEN_IN = b.TOKEN_ADDRESS
    where
    BLOCK_TIMESTAMP::date between '{{Start_date}}' and '{{End_date}}'
    and platform in ('trader-joe-v1', 'trader-joe-v2')
    and pool_name not in ('ORBIT-WAVAX')
    group by 1
    having sum(AMOUNT_IN * avg_Price) < 4e8
    ),
    tab2 as (
    SELECT
    Run a query to Download Data