NakedCollectorAvalanche Active Wallets
    Updated 2024-07-17
    -- forked from Active Wallets @ https://flipsidecrypto.xyz/edit/queries/ee1cff8f-5ee3-441b-a751-9082ea03fa78

    -- New Users: Wallets with first transaction

    with active as(

    SELECT date_trunc('{{interval}}',block_timestamp) as date,
    count(DISTINCT from_address) as active_wallets
    FROM avalanche.core.fact_transactions
    WHERE status = 'SUCCESS' and block_timestamp >= '{{start_date}}'
    GROUP BY 1
    ),

    new as (

    SELECT date_trunc('{{interval}}',first_tx) as date,
    count(DISTINCT from_address) as new_wallets,
    sum(new_wallets)over(ORDER BY date) as cum_new_wallets
    FROM
    (SELECT from_address,
    min (block_timestamp) as first_tx
    FROM avalanche.core.fact_transactions
    WHERE status = 'SUCCESS' and block_timestamp >= '{{start_date}}'
    GROUP BY 1 )
    GROUP BY 1
    ORDER BY date DESC
    )
    ,

    combo as (

    SELECT
    *
    FROM active
    JOIN new
    USING (date)
    QueryRunArchived: QueryRun has been archived