elsina2025-02-25: Daily new users vs old users
    Updated 2025-02-26
    WITH base AS (
    SELECT
    block_timestamp,
    origin_from_address,
    tx_hash,
    pool_name,
    CASE
    WHEN amount_in_usd IS NOT NULL AND amount_out_usd IS NOT NULL THEN (amount_in_usd + amount_out_usd) / 2
    ELSE COALESCE(amount_in_usd, amount_out_usd)
    END AS amount
    FROM
    avalanche.defi.ez_dex_swaps
    WHERE
    platform = 'pangolin' AND
    (amount_in_usd IS NOT NULL OR amount_out_usd IS NOT NULL)
    ),

    first_tx_of_each_users AS (
    SELECT
    origin_from_address,
    MIN(block_timestamp) AS min_date
    FROM
    base
    GROUP BY
    origin_from_address
    ),

    new_users AS (
    SELECT
    date_trunc('day', min_date) AS date,
    COUNT(DISTINCT origin_from_address) AS new_user_count
    FROM
    first_tx_of_each_users
    GROUP BY
    date
    ),
    Last run: about 1 month ago
    DAILY
    OLD_USERS
    ALL_USERS
    NEW_USERS
    PERCENT_NEW_USERS
    PERCENT_OLD_USERS
    1
    2025-01-01 00:00:00.000557288192826298.0672473021.932752698
    2
    2025-01-02 00:00:00.000758301012934397.4818112362.518188764
    3
    2025-01-03 00:00:00.0007934230811514765.62540617834.374593822
    4
    2025-01-04 00:00:00.000691312670575745.4380426254.56195738
    5
    2025-01-05 00:00:00.000731105432330.6451612969.35483871
    6
    2025-01-06 00:00:00.000844130045635.07692307764.923076923
    7
    2025-01-07 00:00:00.000780117539533.61702127766.382978723
    8
    2025-01-08 00:00:00.000746115440835.35528596264.644714038
    9
    2025-01-09 00:00:00.000754119143736.69185558463.308144416
    10
    2025-01-10 00:00:00.000813128647336.78071539763.219284603
    11
    2025-01-11 00:00:00.000682349753429398.050035741.94996426
    12
    2025-01-12 00:00:00.000635100236736.62674650763.373253493
    13
    2025-01-13 00:00:00.000967140643931.22332859268.776671408
    14
    2025-01-14 00:00:00.000716341203340497.9015240332.098475967
    15
    2025-01-15 00:00:00.000955139143631.34435657868.655643422
    16
    2025-01-16 00:00:00.000869137211285293.6666423736.333357627
    17
    2025-01-17 00:00:00.0001016147746131.21191604668.788083954
    18
    2025-01-18 00:00:00.000930137844832.51088534167.489114659
    19
    2025-01-19 00:00:00.0001373221584238.01354401861.986455982
    20
    2025-01-20 00:00:00.0001203177657332.26351351467.736486486
    57
    4KB
    5s