ArioTraderJoe New Swapper Over time
    Updated 2023-10-11
    -- forked from New Swapper Over time @ https://flipsidecrypto.xyz/edit/queries/98751a1e-7898-42a9-9c5a-886a48db756a

    with
    min_d as (
    select
    ORIGIN_FROM_ADDRESS as User_address,
    min(date_trunc({{Granularity}}, BLOCK_TIMESTAMP)) as min_date
    from
    {{Blokchain}}.defi.ez_dex_swaps
    where
    1 = 1
    and platform in ('trader-joe-v1', 'trader-joe-v2')
    group by
    1
    )
    SELECT
    date_trunc({{Granularity}}, min_date) as date,
    count(distinct User_address) as "# New Swapper",
    count(DISTINCT ORIGIN_FROM_ADDRESS) as "# Sawpper"
    from
    {{Blokchain}}.defi.ez_dex_swaps a
    join min_d b on date_trunc({{Granularity}}, block_timestamp) = date_trunc({{Granularity}},min_date)
    where
    min_date::date between '{{Start_date}}' and '{{End_date}}'
    and platform in ('trader-joe-v1', 'trader-joe-v2')
    group by
    1
    Run a query to Download Data