MasiTotal New Swappers
    Updated 2025-05-17
    with tb1 as (select trunc(block_timestamp,'day') as day,
    tx_hash,
    origin_from_address,
    POOL_NAME,
    PLATFORM,
    token_in,
    token_out,
    symbol_in,
    symbol_out,
    case when amount_in_Usd is null then amount_out_usd else amount_in_usd end as volume
    from avalanche.defi.ez_dex_swaps
    where (token_in in (lower('0xE7d69acbc00D0EC5d9c02162310EE21DAA77f69C'),lower('0x420FcA0121DC28039145009570975747295f2329'))
    or token_out in (lower('0xE7d69acbc00D0EC5d9c02162310EE21DAA77f69C'),lower('0x420FcA0121DC28039145009570975747295f2329')))
    )
    ,
    tb2 as ( select min(day) as date,
    origin_from_address
    from tb1
    group by 2)
    ,
    tb3 as (select date,
    count(DISTINCT origin_from_address) as "New Swappers",
    sum("New Swappers") over (order by date asc) as "Cumulative New Swappers"
    from tb2
    where date >= current_date - 31
    group by 1)

    select sum("New Swappers"),
    avg("New Swappers")
    from tb3
    Last run: about 1 month ago
    SUM("NEW SWAPPERS")
    AVG("NEW SWAPPERS")
    1
    145745.53125
    1
    17B
    9s