Elprognerd2- New users eth
    Updated 2023-05-16
    WITH min_swaps AS (
    SELECT
    MIN(a.block_timestamp) AS min_date,
    a.origin_from_address AS user_address
    FROM
    ethereum.core.ez_dex_swaps a
    JOIN
    ethereum.core.fact_transactions b ON a.tx_hash = b.tx_hash
    WHERE
    a.platform LIKE 'uniswap%'
    AND a.amount_in_usd IS NOT NULL
    AND a.amount_in_usd > 0
    GROUP BY
    2
    ),

    new_user_counts AS (
    SELECT
    DATE_TRUNC('month', a.min_date) AS month,
    COUNT(DISTINCT a.user_address) AS user_count
    FROM
    min_swaps a
    WHERE month > current_date - interval '12 months'
    GROUP BY
    1
    )

    SELECT
    month,
    user_count AS "New Users",
    SUM(user_count) OVER (ORDER BY month ASC) AS "Total New Users"
    FROM
    new_user_counts
    ORDER BY 1 ASC
    Run a query to Download Data