Popex404DAU/WAU/MAU Ethereum DEX Swaps
    Updated 2022-12-07
    -- Using SQL recipe from my alchemist bootcamp
    -- Daily/Weekly/Monthly Active Users

    SELECT date_trunc('month', day) as date, avg(active_addresses) as users, 'DAU' as type
    FROM (
    SELECT day, count(distinct addresses) AS active_addresses
    FROM (
    SELECT date_trunc('day', block_timestamp) as day, sender as addresses
    FROM ethereum.core.ez_dex_swaps
    where block_timestamp >= '2022-01-03'

    )
    GROUP BY day
    )
    GROUP BY date

    UNION ALL
    SELECT date_trunc('month', day) as date, avg(active_addresses) as users, 'WAU' as type
    FROM (
    SELECT day, COUNT(DISTINCT addresses) AS active_addresses
    FROM (
    SELECT date_trunc('week', block_timestamp) as day, sender as addresses
    FROM ethereum.core.ez_dex_swaps
    where block_timestamp >= '2022-01-03'


    )

    GROUP BY day
    )
    GROUP BY date
    UNION ALL
    SELECT date_trunc('month', day) as date, COUNT(DISTINCT addresses) AS users, 'MAU' as type
    FROM (
    SELECT date_trunc('day', block_timestamp) as day, sender as addresses
    Run a query to Download Data