Sbhn_NPswap pairs avax
    Updated 2023-05-04
    with base as (select date_trunc('{{Date}}',block_timestamp) as date,
    case when
    LOWER(SYMBOL_in)>LOWER(SYMBOL_OUT)
    then concat(SYMBOL_OUT,'/',SYMBOL_in)
    else
    concat(SYMBOL_in,'/',SYMBOL_OUT)
    end AS pair,
    count(DISTINCT tx_hash) as txs,
    sum(amount_in_usd) as usd_volume,
    rank() over (partition by date order by txs desc) as r
    from avalanche.core.ez_dex_swaps
    where amount_in_usd>0
    and date >= '{{Start_Date}}' and date <= '{{End_Date}}'
    group by 1,2)

    select date,
    iff(r <= 5,pair,'Other') as pairs,
    sum(txs) as swaps,
    sum(usd_volume) as vol
    from base
    group by 1,2

    Run a query to Download Data