m0rt3zaSushiSwap transaction fee stats
    Updated 2022-10-26
    WITH eth_prices as (
    SELECT hour, price
    FROM optimism.core.fact_hourly_token_prices
    WHERE symbol = 'ETH'
    ), eth_fees as (
    SELECT
    sum(b.tx_fee * price) as total_eth_fee,
    avg(b.tx_fee * price) as avg_fee_usd
    FROM ethereum.sushi.ez_swaps as a JOIN
    ethereum.core.fact_transactions as b ON a.tx_hash = b.tx_hash JOIN
    eth_prices as c ON date_trunc(hour, a.block_timestamp) = c.hour
    WHERE a.block_timestamp > '2022-06-01'
    ), op_fees as (
    SELECT
    sum(b.tx_fee * price) as total_eth_fee,
    avg(b.tx_fee * price) as avg_fee_usd
    FROM optimism.sushi.ez_swaps as a JOIN
    optimism.core.fact_transactions as b ON a.tx_hash = b.tx_hash JOIN
    eth_prices as c ON date_trunc(hour, a.block_timestamp) = c.hour
    WHERE a.block_timestamp > '2022-06-01'
    )
    SELECT 'Ethereum' as network, total_eth_fee, avg_fee_usd
    FROM eth_fees
    UNION ALL
    SELECT 'Optimism' as network, total_eth_fee, avg_fee_usd
    FROM op_fees



    Run a query to Download Data