hbd1994Swaps in Base - Daily Overview - Swappers and New Swappers
    Updated 2023-08-29
    with first_date as (
    select
    distinct ORIGIN_FROM_ADDRESS as swapper,
    min(block_timestamp::date) as first_swap_date
    from base.defi.ez_dex_swaps
    group by 1
    order by 1),

    newcomers as (
    select
    first_swap_date,
    count(distinct swapper) as Newcomer,
    sum(Newcomer) over (order by first_swap_date) as cml_newcomer
    from first_date
    where first_swap_date >= '{{Start_Date}}'
    and first_swap_date <= '{{End_Date}}'
    group by 1),

    daily_swappers as (
    select
    date(block_timestamp) as "Date",
    count(distinct ORIGIN_FROM_ADDRESS) as "Swapper"
    from base.defi.ez_dex_swaps
    where block_timestamp >= '{{Start_Date}}'
    and block_timestamp <= '{{End_Date}}'
    group by 1
    order by 1)

    select
    "Date",
    "Swapper" as "Daily Swappers",
    Newcomer as "Daily New Swappers",
    cml_newcomer as "Cumulative New Swappers"
    from daily_swappers
    join newcomers on "Date" = first_swap_date
    order by 1
    Run a query to Download Data