Updated 2024-11-18
    WITH swap_data AS (
    SELECT
    DATE_TRUNC('day', block_timestamp::date) AS date,
    tx_hash,
    swapper,
    amount_in_usd,
    amount_out_usd,
    (amount_in_usd + amount_out_usd) / 2 AS total_volume_usd
    FROM aptos.defi.ez_dex_swaps
    WHERE platform = 'cetus'
    )

    SELECT
    date,
    COUNT(DISTINCT tx_hash) AS total_swaps,
    COUNT(DISTINCT swapper) AS unique_traders,
    SUM(total_volume_usd) AS total_volume_usd
    FROM swap_data
    WHERE date >= CURRENT_DATE - INTERVAL '7 days'
    GROUP BY date
    ORDER BY date DESC;
    QueryRunArchived: QueryRun has been archived