Eman-RazTotal Swap Volume By Chain
    Updated 2024-08-04
    with final_table as (
    ----------------------------------------------Ethereum------------------------------------------------------

    with ethereum as (select date_trunc('{{Time_Frame}}',block_timestamp) as "Date", sum(amount_in_usd) as "Swap Volume (USD)", 'Ethereum' as "Chain"
    from ethereum.defi.ez_dex_swaps
    where (token_in=lower('0x2598c30330D5771AE9F983979209486aE26dE875') or
    token_out=lower('0x2598c30330D5771AE9F983979209486aE26dE875'))
    and (block_timestamp::date between '{{Start_Date}}' and '{{End_Date}}')
    group by 1
    order by 1),

    ----------------------------------------------Base------------------------------------------------------

    base as (select date_trunc('{{Time_Frame}}',block_timestamp) as "Date", sum(amount_in_usd) as "Swap Volume (USD)", 'Base' as "Chain"
    from base.defi.ez_dex_swaps
    where (token_in=lower('0x2598c30330D5771AE9F983979209486aE26dE875') or
    token_out=lower('0x2598c30330D5771AE9F983979209486aE26dE875'))
    and (block_timestamp::date between '{{Start_Date}}' and '{{End_Date}}')
    group by 1
    order by 1),

    ----------------------------------------------Arbitrum------------------------------------------------------

    arbitrum as (select date_trunc('{{Time_Frame}}',block_timestamp) as "Date", sum(amount_in_usd) as "Swap Volume (USD)", 'Arbitrum' as "Chain"
    from arbitrum.defi.ez_dex_swaps
    where (token_in=lower('0x2598c30330D5771AE9F983979209486aE26dE875') or
    token_out=lower('0x2598c30330D5771AE9F983979209486aE26dE875'))
    and (block_timestamp::date between '{{Start_Date}}' and '{{End_Date}}')
    group by 1
    order by 1),

    ----------------------------------------------BSC------------------------------------------------------

    bsc as (select date_trunc('{{Time_Frame}}',block_timestamp) as "Date", sum(amount_in_usd) as "Swap Volume (USD)", 'BSC' as "Chain"
    from bsc.defi.ez_dex_swaps
    where (token_in=lower('0x2598c30330D5771AE9F983979209486aE26dE875') or
    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived