Updated 2024-07-27
    WITH t1 AS (
    SELECT
    block_timestamp::date AS dt,
    tx_hash,
    symbol_in,
    symbol_out,
    swapper,
    coalesce(amount_in_usd, amount_out_usd) AS amount_usd
    FROM aptos.defi.ez_dex_swaps
    WHERE
    platform = 'thala'
    AND amount_usd>0
    )

    SELECT
    DATE_TRUNC('WEEK', dt) AS "dt",
    COUNT(DISTINCT swapper) AS "Swappers",
    COUNT(DISTINCT tx_hash) AS "Swaps",
    SUM(amount_usd) AS "Weekly Volume($)",
    AVG(amount_usd) AS "Avg Volume($)",
    SUM("Weekly Volume($)") OVER (ORDER BY "dt") AS "Total Volume($)"
    FROM t1
    GROUP BY "dt"

    QueryRunArchived: QueryRun has been archived