Kruys-Collinsfree-white
    Updated 2025-03-09
    WITH base AS (
    SELECT
    DATE_TRUNC('day', block_timestamp) AS day,
    CASE
    WHEN token_in = '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01::mod_coin::MOD' THEN 'sell'
    WHEN token_out = '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01::mod_coin::MOD' THEN 'buy'
    END AS tag,
    amount_in_usd,
    amount_out_usd
    FROM
    aptos.defi.ez_dex_swaps
    WHERE
    token_in = '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01::mod_coin::MOD'
    OR token_out = '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01::mod_coin::MOD'
    ),

    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
    FROM
    base
    GROUP BY
    day, tag
    )
    SELECT
    day,
    tag,
    num_swaps AS daily_num_swaps,
    total_volume AS daily_total_volume
    FROM
    daily_swaps
    ORDER BY
    day, tag;

    Last run: about 2 months ago
    DAY
    TAG
    DAILY_NUM_SWAPS
    DAILY_TOTAL_VOLUME
    1
    2023-04-05 00:00:00.000buy20
    2
    2023-04-05 00:00:00.000sell40
    3
    2023-04-06 00:00:00.000buy1168684004.590167144
    4
    2023-04-06 00:00:00.000sell982-722241.242160983
    5
    2023-04-07 00:00:00.000buy574339155.279599992
    6
    2023-04-07 00:00:00.000sell512-305875.063150165
    7
    2023-04-08 00:00:00.000buy831179624.664239381
    8
    2023-04-08 00:00:00.000sell785-189991.344201203
    9
    2023-04-09 00:00:00.000buy556218859.952858342
    10
    2023-04-09 00:00:00.000sell529-257301.123044477
    11
    2023-04-10 00:00:00.000buy943422059.513414498
    12
    2023-04-10 00:00:00.000sell914-509543.213628189
    13
    2023-04-11 00:00:00.000buy1339319637.07026937
    14
    2023-04-11 00:00:00.000sell1314-292398.935748836
    15
    2023-04-12 00:00:00.000buy1064340277.975207361
    16
    2023-04-12 00:00:00.000sell1027-221489.1791963
    17
    2023-04-13 00:00:00.000buy1877818357.790475727
    18
    2023-04-13 00:00:00.000sell1870-850690.567838694
    19
    2023-04-14 00:00:00.000buy2083921130.80901562
    20
    2023-04-14 00:00:00.000sell2027-888765.997571245
    ...
    1410
    78KB
    3s