Afonso_DiazOvertime
    Updated 1 day ago
    with

    main as (
    select
    tx_hash,
    block_timestamp,
    origin_from_address as user,
    symbol_in,
    symbol_out,
    split(platform, '-')[0] as platform,
    greatest(symbol_in, symbol_out) || ' - ' || least(symbol_in, symbol_out) as token_pair,
    iff(symbol_in in ('USDC', 'USDT', 'USDC.e', 'DAI'), 'StableCoin', 'Other') || ' -> ' || iff(symbol_out in ('USDC', 'USDT', 'USDC.e', 'DAI'), 'StableCoin', 'Other') as route,
    case
    when symbol_in in ('USDC', 'USDT', 'USDC.e', 'DAI') then amount_in
    when symbol_out in ('USDC', 'USDT', 'USDC.e', 'DAI') then amount_out
    else nvl(amount_in_usd, amount_out_usd)
    end as amount_usd
    from
    kaia.defi.ez_dex_swaps
    where
    amount_usd > 0
    and block_timestamp >= '2024-01-01'

    ),

    overtime as (
    select
    date_trunc('{{ period }}', block_timestamp) as date,
    count(distinct tx_hash) as swaps,
    count(distinct user) as swappers,
    sum(amount_usd) as volume_usd,
    avg(amount_usd) as average_amount_usd,
    sum(swaps) over (order by date) as cumulative_swaps,
    sum(volume_usd) over (order by date) as cumulative_volume_usd
    from main
    group by 1
    Last run: 1 day ago
    DATE
    SWAPS
    SWAPPERS
    VOLUME_USD
    AVERAGE_AMOUNT_USD
    CUMULATIVE_SWAPS
    CUMULATIVE_VOLUME_USD
    NEW_SWAPPERS
    RETURNING_SWAPPERS
    1
    2024-02-01 00:00:00.00071338353023034491.0318065301.8976792867133823034491.031806535300
    2
    2024-03-01 00:00:00.00039127531203111182971.872656247.986411905462613134217462.904463298281375
    3
    2024-04-01 00:00:00.0002935862876779175339.4362225.115405977756199213392802.340663257942973
    4
    2024-05-01 00:00:00.0002966532468458485268.545552149.0157857541052852271878070.886215213713313
    5
    2024-06-01 00:00:00.0003475932812587334002.847402160.1389216151400445359212073.733617245033622
    6
    2024-07-01 00:00:00.0003501703637290627416.224378132.3116825721750615449839489.957995319324440
    7
    2024-08-01 00:00:00.0005331225604686533353.97001280.5246826742283737536372843.928007505235523
    8
    2024-09-01 00:00:00.0004518313825472169830.08024692.0183783212735568608542674.008253320776177
    9
    2024-10-01 00:00:00.00058216079042135612397.721768130.671952543317728744155071.730021711267916
    10
    2024-11-01 00:00:00.000865008138912326978917.383162208.84880950641827361071133989.113181303228590
    11
    2024-12-01 00:00:00.0001219871123373527618468.151172249.16435022754026071598752457.264351157437630
    12
    2025-01-01 00:00:00.00086835054878191512886.445524138.67836925662709571790265343.70988485536325
    13
    2025-02-01 00:00:00.0005142855376891144225.51308995.4810712567852421881409569.22297482675501
    14
    2025-03-01 00:00:00.0003952555597848219872.17538366.27568969871804971929629441.39835503925586
    15
    2025-04-01 00:00:00.0003711505185850363880.69395575.8923073775516471979993322.09231458226036
    16
    2025-05-01 00:00:00.0002132241753699596.71816388.77256672375729691983692918.8104730081167
    16
    2KB
    3s