datavortexTop Swapped Pairs
    Updated 2024-12-24
    WITH aggregated_data AS (
    SELECT
    CONCAT(symbol_in, '-', symbol_out) AS "Token Pair Symbol",
    COUNT(DISTINCT tx_hash) AS "Total Swaps",
    SUM(amount_in_usd) AS "Total Swap In Volume"
    FROM
    aptos.defi.ez_dex_swaps
    WHERE
    block_timestamp >= DATE_TRUNC('month', CURRENT_DATE)
    AND symbol_in IS NOT NULL
    AND symbol_out IS NOT NULL
    GROUP BY
    token_in,
    token_out,
    symbol_in,
    symbol_out
    ),
    ranked_data AS (
    SELECT
    "Token Pair Symbol",
    "Total Swaps",
    "Total Swap In Volume",
    RANK() OVER (ORDER BY "Total Swaps" DESC) AS swap_rank
    FROM
    aggregated_data
    )
    SELECT
    "Token Pair Symbol",
    "Total Swaps",
    "Total Swap In Volume"
    FROM
    ranked_data
    WHERE
    swap_rank <= 15
    ORDER BY
    "Total Swaps" DESC;

    QueryRunArchived: QueryRun has been archived