JonasoL2s: swap
    Updated 2024-09-08
    with

    A as( select 'Arbitrum' as chain, block_timestamp, amount_out_usd, origin_from_address from arbitrum.defi.ez_dex_swaps
    union all select 'Optimism' as chain, block_timestamp, amount_out_usd, origin_from_address from optimism.defi.ez_dex_swaps
    union all select 'Base' as chain, block_timestamp, amount_out_usd, origin_from_address from base.defi.ez_dex_swaps
    ),

    B as(
    select date_trunc('month',block_timestamp) as time, chain,
    sum(amount_out_usd) as volume,
    count(distinct origin_from_address) as trader
    from A
    group by 1,2),

    C as(
    select chain, sum(amount_out_usd) as volume, count(distinct origin_from_address) as trader
    from A
    where block_timestamp >= current_date - interval '720 hours'
    group by 1)

    select a.*, b.volume as "Volume (30d)", b.trader as "Active Traders (30d)"
    from B as a
    left join C as b on a.chain = b.chain and a.time = (select max(time) from B)
    where year(a.time) >= 2022
    order by a.time desc









    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived