Afonso_Diazsushiswap-4-455
    Updated 2023-03-18
    with t as (
    select
    block_timestamp::date as day,
    'Gnosis' as chain,
    count(distinct tx_hash) as swaps,
    count(distinct origin_from_address) as swappers,
    sum(iff(symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM'), amount_in, amount_out)) as swap_volume_usd,
    sum(swaps) over (order by day) as cumulative_swaps,
    sum(swap_volume_usd) over (order by day) as cumulative_swap_volume_usd
    from gnosis.sushi.ez_swaps
    where (
    symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM') or
    symbol_out in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM')
    )
    and block_timestamp > current_date - interval '3 months'
    group by 1

    union

    select
    block_timestamp::date as day,
    'BSC' as chain,
    count(distinct tx_hash) as swaps,
    count(distinct origin_from_address) as swappers,
    sum(iff(symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM'), amount_in, amount_out)) as swap_volume_usd,
    sum(swaps) over (order by day) as cumulative_swaps,
    sum(swap_volume_usd) over (order by day) as cumulative_swap_volume_usd
    from bsc.sushi.ez_swaps
    where (
    symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM') or
    symbol_out in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM')
    )
    and block_timestamp > current_date - interval '3 months'
    group by 1

    union
    Run a query to Download Data