datavortexgas fees percentage
    Updated 2024-09-17
    WITH all_swaps AS (
    SELECT
    ez_dex_swaps.tx_hash,
    fact_transactions.tx_fee
    FROM polygon.defi.ez_dex_swaps AS ez_dex_swaps
    JOIN polygon.core.fact_transactions AS fact_transactions
    ON ez_dex_swaps.tx_hash = fact_transactions.tx_hash
    ),
    stablecoin_swaps AS (

    SELECT
    ez_dex_swaps.tx_hash,
    fact_transactions.tx_fee
    FROM polygon.defi.ez_dex_swaps AS ez_dex_swaps
    JOIN polygon.core.fact_transactions AS fact_transactions
    ON ez_dex_swaps.tx_hash = fact_transactions.tx_hash
    WHERE ez_dex_swaps.symbol_in IN ('USDT', 'USDC', 'EURS', 'DAI', 'UST', 'BUSD', 'TUSD')
    AND ez_dex_swaps.block_timestamp >= '{{ start_date }}'
    AND ez_dex_swaps.block_timestamp < '{{ end_date }}'
    )

    SELECT
    (SELECT SUM(tx_fee) FROM all_swaps) AS total_fees,
    (SELECT SUM(tx_fee) FROM stablecoin_swaps) AS stablecoin_fees,
    (SELECT SUM(tx_fee) FROM stablecoin_swaps) / (SELECT SUM(tx_fee) FROM all_swaps) * 100 AS stablecoin_fee_percentage;

    QueryRunArchived: QueryRun has been archived