Updated 2025-03-23
    WITH base AS (
    SELECT
    DATE_TRUNC('day', block_timestamp) AS day,
    CASE
    WHEN token_in = '0xe4ccb6d39136469f376242c31b34d10515c8eaaa38092f804db8e08a8f53c5b2::assets_v1::EchoCoin002' THEN 'sell'
    WHEN token_out = '0xe4ccb6d39136469f376242c31b34d10515c8eaaa38092f804db8e08a8f53c5b2::assets_v1::EchoCoin002' THEN 'buy'
    END AS tag,
    amount_in_usd,
    amount_out_usd,
    swapper
    FROM
    aptos.defi.ez_dex_swaps
    WHERE
    token_in = '0xe4ccb6d39136469f376242c31b34d10515c8eaaa38092f804db8e08a8f53c5b2::assets_v1::EchoCoin002'
    OR token_out = '0xe4ccb6d39136469f376242c31b34d10515c8eaaa38092f804db8e08a8f53c5b2::assets_v1::EchoCoin002'
    ),

    daily_swaps AS (
    SELECT
    day,
    tag,
    COUNT(*) AS num_swaps,
    SUM(CASE WHEN tag = 'buy' THEN COALESCE(amount_in_usd, amount_out_usd, 0) ELSE COALESCE(-amount_in_usd, -amount_out_usd, 0) END) AS total_volume,
    COUNT(DISTINCT swapper) AS total_swappers
    FROM
    base
    GROUP BY
    day, tag
    ),
    daily_net_volume AS (
    SELECT
    day,
    SUM(CASE WHEN tag = 'buy' THEN COALESCE(amount_in_usd, amount_out_usd, 0) ELSE -COALESCE(amount_in_usd, amount_out_usd, 0) END) AS net_volume
    FROM
    base
    GROUP BY
    Last run: about 1 month ago
    DAY
    TAG
    DAILY_NUM_SWAPS
    DAILY_TOTAL_VOLUME
    DAILY_TOTAL_SWAPPERS
    DAILY_NET_VOLUME
    Average Price
    1
    2023-12-24 00:00:00.000buy4630814900.6671342722420-76517.4955654560.00002060221269
    2
    2023-12-24 00:00:00.000sell3577-891418.1626997292104-76517.4955654560.00002060221269
    3
    2023-12-25 00:00:00.000buy2624360392.69899814815159810.5326040840.00001784345569
    4
    2023-12-25 00:00:00.000sell1759-350582.16639406510199810.5326040840.00001784345569
    5
    2023-12-26 00:00:00.000buy3050385881.6349262431241-33209.5089030530.00001940912132
    6
    2023-12-26 00:00:00.000sell2690-419091.1438292961239-33209.5089030530.00001940912132
    7
    2023-12-27 00:00:00.000buy1918163955.357710108807-31204.4367824450.00001739008945
    8
    2023-12-27 00:00:00.000sell1716-195159.794492552808-31204.4367824450.00001739008945
    9
    2023-12-28 00:00:00.000buy1919229861.47515389793-6708.131766860.00001509996851
    10
    2023-12-28 00:00:00.000sell1585-236569.606920751687-6708.131766860.00001509996851
    11
    2023-12-29 00:00:00.000buy1366145635.552826191585-52433.0068827590.00001308181257
    12
    2023-12-29 00:00:00.000sell1220-198068.55970895600-52433.0068827590.00001308181257
    13
    2023-12-30 00:00:00.000buy1179180372.31915267154943703.5438822940.00001261020243
    14
    2023-12-30 00:00:00.000sell1294-136668.77527037675443703.5438822940.00001261020243
    15
    2023-12-31 00:00:00.000buy1032171529.40673099655635268.0666089150.00001448337932
    16
    2023-12-31 00:00:00.000sell1470-136261.340122081107035268.0666089150.00001448337932
    17
    2024-01-01 00:00:00.000buy1011274395.59297745247828708.8036475530.00001673669186
    18
    2024-01-01 00:00:00.000sell1209-245686.789329980728708.8036475530.00001673669186
    19
    2024-01-02 00:00:00.000buy1010240774.006332649502-6609.4492816050.0000194539048
    20
    2024-01-02 00:00:00.000sell997-247383.455614254643-6609.4492816050.0000194539048
    ...
    912
    81KB
    5s