datavortexGas Fees
    Updated 2024-12-21
    /*
    WITH swap_fees AS (
    SELECT
    s.tx_hash,
    (t.gas_used * t.gas_unit_price) / 1e8 AS "total apt Gas Fees"
    FROM
    aptos.defi.ez_dex_swaps AS s
    INNER JOIN
    aptos.core.fact_transactions AS t ON s.tx_hash = t.tx_hash
    WHERE
    s.block_timestamp BETWEEN '2024-01-01' AND '2024-12-31'
    AND (s.token_in = '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT'
    OR s.token_out = '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT')
    )
    SELECT
    COUNT(DISTINCT s.swapper) AS "Total Swappers",
    COUNT(DISTINCT s.tx_hash) AS "Total Swaps",
    SUM(s.amount_in_usd) AS "Total Volume Swapped (USD)",
    SUM(f."total apt Gas Fees") AS "Total Gas Fees (APT)",
    AVG(f."total apt Gas Fees") AS "Average Gas Fee per Swap (APT)"
    FROM
    swap_fees AS f
    INNER JOIN
    aptos.defi.ez_dex_swaps AS s ON f.tx_hash = s.tx_hash;
    */
    WITH apt_price AS (
    SELECT
    AVG(price) AS avg_apt_price_usd
    FROM
    aptos.price.ez_prices_hourly
    WHERE
    symbol = 'APT'
    AND hour BETWEEN '2024-01-01' AND '2024-12-31'
    ),
    swap_fees AS (
    SELECT
    QueryRunArchived: QueryRun has been archived