Kruys-CollinsAVAX negative-salmon
    Updated 2025-03-17
    WITH base AS (
    SELECT
    DATE_TRUNC('day', block_timestamp) AS day,
    CASE
    WHEN token_in = LOWER('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E') THEN 'sell'
    WHEN token_out = LOWER('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E') THEN 'buy'
    END AS tag,
    amount_in_usd,
    amount_out_usd,
    origin_from_address AS swapper
    FROM
    avalanche.defi.ez_dex_swaps
    WHERE
    (token_in = LOWER('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E')
    OR token_out = LOWER('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E'))
    AND block_timestamp >= DATEADD(day, -{{lookback_period}}, CURRENT_TIMESTAMP)
    ),

    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
    Last run: about 1 month ago
    DAY
    TAG
    DAILY_NUM_SWAPS
    DAILY_TOTAL_VOLUME
    DAILY_TOTAL_SWAPPERS
    DAILY_NET_VOLUME
    Average Price
    1
    2025-02-15 00:00:00.000buy114222639.7654-70948.410.7464055
    2
    2025-02-15 00:00:00.000sell145-293588.1758-70948.410.7464055
    3
    2025-02-16 00:00:00.000buy403259141.27113-173895.240.746737625
    4
    2025-02-16 00:00:00.000sell342-433036.51119-173895.240.746737625
    5
    2025-02-17 00:00:00.000buy791852991.24165-334334.330.7460969583
    6
    2025-02-17 00:00:00.000sell795-1187325.57173-334334.330.7460969583
    7
    2025-02-18 00:00:00.000buy602452031.55146-74191.170.7449660833
    8
    2025-02-18 00:00:00.000sell585-526222.72137-74191.170.7449660833
    9
    2025-02-19 00:00:00.000buy483545974.14124-287232.980.7448044167
    10
    2025-02-19 00:00:00.000sell511-833207.12129-287232.980.7448044167
    11
    2025-02-20 00:00:00.000buy6041531466.06152735746.920.7453300417
    12
    2025-02-20 00:00:00.000sell571-795719.14159735746.920.7453300417
    13
    2025-02-21 00:00:00.000buy8381032629.13197153127.340.7477534167
    14
    2025-02-21 00:00:00.000sell819-879501.79205153127.340.7477534167
    15
    2025-02-22 00:00:00.000buy512809271.99136223985.560.7486101667
    16
    2025-02-22 00:00:00.000sell511-585286.43143223985.560.7486101667
    17
    2025-02-23 00:00:00.000buy336527538.1108-132604.770.74851
    18
    2025-02-23 00:00:00.000sell334-660142.87111-132604.770.74851
    19
    2025-02-24 00:00:00.000buy518595675.5116-329777.420.7480404583
    20
    2025-02-24 00:00:00.000sell385-925452.92122-329777.420.7480404583
    62
    5KB
    4s