0xHaM-d$DONK - Pool's Swap Performance
    Updated 2024-11-17
    with swapEvent as (
    SELECT
    BLOCK_TIMESTAMP,
    TX_HASH,
    swapper,
    token_in,
    SYMBOL_IN,
    token_out,
    SYMBOL_OUT,
    AMOUNT_IN,
    AMOUNT_OUT,
    AMOUNT_IN_USD,
    AMOUNT_OUT_USD
    FROM aptos.defi.ez_dex_swaps
    WHERE (TOKEN_OUT ilike '%0xe88ae9670071da40a9a6b1d97aab8f6f1898fdc3b8f1c1038b492dfad738448b::coin::Donk%'
    OR TOKEN_IN ilike '%0xe88ae9670071da40a9a6b1d97aab8f6f1898fdc3b8f1c1038b492dfad738448b::coin::Donk%')
    )
    , priceTb as (
    SELECT
    hour,
    TOKEN_ADDRESS,
    SYMBOL,
    price
    FROM aptos.price.ez_prices_hourly
    WHERE TOKEN_ADDRESS ilike ('0xe88ae9670071da40a9a6b1d97aab8f6f1898fdc3b8f1c1038b492dfad738448b::coin::Donk')
    )
    , swap_detail as (
    SELECT
    concat(symbol_in, '/',symbol_out) as "Pair",
    count(distinct swapper) as "Swapper Count",
    count(distinct tx_hash) as "swaps Count",
    round(sum(case when amount_in_usd is not null then amount_in_usd else amount_out_usd end ),1) as "Total Volume ($)"
    FROM swapEvent
    group by 1
    )
    ,LAST24 AS ( -- swap volume in the last 24 hour
    QueryRunArchived: QueryRun has been archived