datavortexChanges 1 Month
    Updated 2024-11-26
    WITH total AS (
    SELECT
    SUM(amount_in_usd) AS "total swap volume",
    COUNT(DISTINCT tx_hash) AS "total swaps",
    COUNT(DISTINCT origin_from_address) AS "total users"
    FROM
    avalanche.defi.ez_dex_swaps
    WHERE
    block_timestamp >= '2024-01-01'
    AND block_timestamp <= '2024-12-31'
    AND platform = 'uniswap-v3'
    ),
    averages AS (
    SELECT
    "total swap volume" / NULLIF("total users", 0) AS "average swap volume per user",
    "total swaps" / NULLIF("total users", 0) AS "average swaps per user"
    FROM
    total
    ),
    monthly AS (
    SELECT
    DATE_TRUNC('month', block_timestamp) AS "month",
    SUM(amount_in_usd) AS "monthly swap volume",
    COUNT(DISTINCT tx_hash) AS "monthly swaps",
    COUNT(DISTINCT sender) AS "monthly users"
    FROM
    avalanche.defi.ez_dex_swaps
    WHERE
    block_timestamp >= CURRENT_DATE - INTERVAL '2 months'
    AND platform = 'uniswap-v3'
    GROUP BY
    DATE_TRUNC('month', block_timestamp)
    ),
    volume_change AS (
    SELECT
    "month",
    QueryRunArchived: QueryRun has been archived