i_dan$XSGD: Totals
    Updated 2025-03-17
    WITH trade_data AS (
    SELECT
    block_timestamp
    , tx_hash
    , origin_from_address
    , CASE WHEN token_in = lower('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E') THEN 'buy'
    WHEN token_out = lower('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E') THEN 'sell'
    END AS Action
    , CASE WHEN token_in = lower('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E') THEN symbol_in
    WHEN token_out = lower('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E') THEN symbol_out
    END AS symbol
    , CASE WHEN amount_in_usd IS NULL THEN amount_out_usd ELSE amount_in_usd END AS usd_amount
    , CASE WHEN token_in = lower('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E') THEN amount_in
    WHEN token_out = lower('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E') THEN amount_out
    END AS token_amount
    , platform
    FROM avalanche.defi.ez_dex_swaps
    WHERE token_in = lower('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E')
    OR token_out = lower('0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E')
    )

    SELECT
    COUNT(DISTINCT origin_from_address) AS wallets
    , SUM(usd_amount) AS Total_volume
    , COUNT(tx_hash) AS Transactions
    , AVG(usd_amount) AS average_volume
    , MAX(usd_amount) AS Max_trade
    FROM trade_data
    --GROUP BY 1
    --ORDER BY 2 DESC


    -- XSGD - 0xb2F85b7AB3c2b6f62DF06dE6aE7D09c010a5096E
    Last run: about 1 month ago
    WALLETS
    TOTAL_VOLUME
    TRANSACTIONS
    AVERAGE_VOLUME
    MAX_TRADE
    1
    3595427930424.772260411893.162381747587573.98
    1
    53B
    2s