Eman-RazSPEC Swaps Over Time
    Updated 2025-04-28
    with overview as (select block_timestamp, tx_hash, origin_from_address as swapper, symbol_in || '➡' || symbol_out as token_pair, case
    when token_in = lower('0xAdF7C35560035944e805D98fF17d58CDe2449389') then sum(amount_in)
    when token_out = lower('0xAdF7C35560035944e805D98fF17d58CDe2449389') then sum(amount_out)
    end as volume, sum(coalesce(amount_in_usd,amount_out_usd)) as volume_usd, platform as dex, case
    when token_in = lower('0xAdF7C35560035944e805D98fF17d58CDe2449389') then 'Sell'
    when token_out = lower('0xAdF7C35560035944e805D98fF17d58CDe2449389') then 'Buy'
    end as swap_direction, 'Ethereum' as "Chain"
    from ethereum.defi.ez_dex_swaps
    where (token_in = lower('0xAdF7C35560035944e805D98fF17d58CDe2449389')
    or token_out = lower('0xAdF7C35560035944e805D98fF17d58CDe2449389'))
    and block_timestamp::date between '{{Start_Date}}' and '{{End_Date}}'
    group by block_timestamp, token_in, token_out, tx_hash, origin_from_address, symbol_in, symbol_out, platform

    union all

    select block_timestamp, tx_hash, origin_from_address as swapper, symbol_in || '➡' || symbol_out as token_pair, case
    when token_in = lower('0x96419929d7949D6A801A6909c145C8EEf6A40431') then sum(amount_in)
    when token_out = lower('0x96419929d7949D6A801A6909c145C8EEf6A40431') then sum(amount_out)
    end as volume, sum(coalesce(amount_in_usd,amount_out_usd)) as volume_usd, platform as dex, case
    when token_in = lower('0x96419929d7949D6A801A6909c145C8EEf6A40431') then 'Sell'
    when token_out = lower('0x96419929d7949D6A801A6909c145C8EEf6A40431') then 'Buy'
    end as swap_direction, 'Base' as "Chain"
    from base.defi.ez_dex_swaps
    where (token_in = lower('0x96419929d7949D6A801A6909c145C8EEf6A40431')
    or token_out = lower('0x96419929d7949D6A801A6909c145C8EEf6A40431'))
    and block_timestamp::date between '{{Start_Date}}' and '{{End_Date}}'
    group by block_timestamp, token_in, token_out, tx_hash, origin_from_address, symbol_in, symbol_out, platform)

    select date_trunc('{{Time_Frame}}',block_timestamp) as "Date", count(distinct tx_hash) as "Swap Count", sum(volume) as "Swap Volume ($SPEC)",
    sum(volume_usd) as "Swap Volume ($USD)", count(distinct swapper) as "Swapper Count", "Chain"
    from overview
    group by 1,6
    order by 1
    Last run: about 1 month ago
    Date
    Swap Count
    Swap Volume ($SPEC)
    Swap Volume ($USD)
    Swapper Count
    Chain
    1
    2024-05-01 00:00:00.0004437888541.5426116758371971.721016Ethereum
    2
    2024-05-01 00:00:00.0006900513466446.9325953122129119.2121432Base
    3
    2024-06-01 00:00:00.000480366166179.2037978456887097.195359Base
    4
    2024-06-01 00:00:00.0001777384711.2250948173652539.39502Ethereum
    5
    2024-07-01 00:00:00.0001059211363.9120554481486677.12362Ethereum
    6
    2024-07-01 00:00:00.000293234371238.2145629530044951.543187Base
    7
    2024-08-01 00:00:00.000290503516215.0271430521673744.842247Base
    8
    2024-08-01 00:00:00.0001182279548.2306651411751234.17329Ethereum
    9
    2024-09-01 00:00:00.000368512876983.2020244320643678.822365Base
    10
    2024-09-01 00:00:00.0001353342916.4840218122523151.5430Ethereum
    11
    2024-10-01 00:00:00.0002748541489.0372626465108415.43958Ethereum
    12
    2024-10-01 00:00:00.000842634536749.3134073542967651.524344Base
    13
    2024-11-01 00:00:00.00046121198785.5151124514385045.291685Ethereum
    14
    2024-11-01 00:00:00.00013265411500204.1613293126506045.3614839Base
    15
    2024-12-01 00:00:00.0001145908396394.91802957101482819.8315205Base
    16
    2024-12-01 00:00:00.00047931220802.3511814816187671.521891Ethereum
    17
    2025-01-01 00:00:00.000167089822.064115006816852.17518Base
    18
    2025-01-01 00:00:00.0009017687.540919288169420.0861Ethereum
    18
    1KB
    42s