Updated 2025-02-02
    WITH swaps AS (
    SELECT DATE_TRUNC('day', BLOCK_TIMESTAMP) as date,
    CASE
    WHEN TOKEN_IN = '0xffff003a6bad9b743d658048742935fffe2b6ed7' THEN 'Sell'
    ELSE 'Buy' END as direction,
    ORIGIN_FROM_ADDRESS as trader,
    TX_HASH,
    NULLIF(AMOUNT_IN_USD, 0) AS amount_usd,
    NULLIF(AMOUNT_OUT_USD, 0) AS amount_out_usd,
    TOKEN_IN,
    TOKEN_OUT
    FROM avalanche.defi.ez_dex_swaps
    WHERE TOKEN_IN = '0xffff003a6bad9b743d658048742935fffe2b6ed7'
    OR TOKEN_OUT = '0xffff003a6bad9b743d658048742935fffe2b6ed7'
    )
    SELECT
    direction as type,
    COUNT(DISTINCT trader) as unique_traders,
    COUNT(*) as total_trades,
    SUM(COALESCE(amount_usd, amount_out_usd)) as total_volume
    FROM swaps
    GROUP BY direction;


    Last run: 17 days ago
    TYPE
    UNIQUE_TRADERS
    TOTAL_TRADES
    TOTAL_VOLUME
    1
    Sell5843289210187239321.85
    2
    Buy17864218369210283306.19
    2
    69B
    3s