tomingTop Pairs Monthly copy
    Updated 2024-07-23
    -- forked from Jhanlycn / Top Pairs Monthly @ https://flipsidecrypto.xyz/Jhanlycn/q/Oglncan2ebx0/top-pairs-monthly

    WITH
    first_swaps AS (
    SELECT
    sender AS address,
    MIN(DATE_TRUNC('month', BLOCK_TIMESTAMP)) AS first_swap_month
    FROM
    ethereum.uniswapv3.ez_swaps
    GROUP BY
    sender
    UNION
    SELECT
    recipient AS address,
    MIN(DATE_TRUNC('month', BLOCK_TIMESTAMP)) AS first_swap_month
    FROM
    ethereum.uniswapv3.ez_swaps
    GROUP BY
    recipient
    ),
    new_swappers AS (
    SELECT
    address,
    first_swap_month
    FROM
    first_swaps
    WHERE
    first_swap_month >= DATEADD('month', -12, CURRENT_DATE())
    ),
    pair_swaps AS (
    SELECT
    DATE_TRUNC('month', BLOCK_TIMESTAMP) AS month,
    CONCAT(TOKEN0_SYMBOL, '/', TOKEN1_SYMBOL) AS pair,
    COUNT(*) AS pair_amount
    FROM
    ethereum.uniswapv3.ez_swaps
    QueryRunArchived: QueryRun has been archived