datavortexTop swap token by swaps 24hr
    Updated 2024-09-18
    WITH recent_data AS (
    SELECT
    block_timestamp,
    tx_hash,
    origin_from_address,
    COALESCE(amount_in_usd, 0) AS amount_in_usd,
    symbol_in
    FROM optimism.defi.ez_dex_swaps
    WHERE block_timestamp >= CURRENT_TIMESTAMP() - INTERVAL '1 DAY'
    ),

    aggregated_data AS (
    SELECT
    symbol_in AS symbol,
    COUNT(DISTINCT tx_hash) AS total_swaps,
    COUNT(DISTINCT origin_from_address) AS total_swappers,
    SUM(amount_in_usd) AS total_swap_volume
    FROM recent_data
    GROUP BY symbol_in
    )

    SELECT
    symbol,
    total_swaps,
    total_swappers,
    total_swap_volume
    FROM aggregated_data
    WHERE total_swap_volume IS NOT NULL
    ORDER BY total_swap_volume DESC
    LIMIT 11;


    QueryRunArchived: QueryRun has been archived