mo115Total fees
    Updated 2025-05-16
    -- forked from Total fees @ https://flipsidecrypto.xyz/edit/queries/a452fca8-aa8b-4e3f-b376-a87fa947fd60

    with total as ((with ar as (With Arbitrum as (with arbitrum_fees as
    (select
    date_trunc('day',BLOCK_TIMESTAMP) as date,
    FROM_ADDRESS as address,
    sum (TX_FEE) as gas_paid
    from arbitrum.core.fact_transactions
    where FROM_ADDRESS = lower('{{ADDRESS}}')
    group by 1,2),
    ETH as (select date_trunc ('day',HOUR) as date, avg(PRICE)as price
    from ethereum.price.ez_prices_hourly
    where SYMBOL = 'WETH'
    group by 1)
    select a.date, address,gas_paid as gas_paid_ETH, (gas_paid*price) as gas_paid_USD
    from arbitrum_fees a left join ETH e on a.date=e.date)
    select 'Arbitrum' as network , sum(gas_paid_ETH)as Token , sum(gas_paid_USD)as USD, (USD/Token) as AVERAGE_Token_PRICE
    from Arbitrum),
    ETHt as (select date_trunc ('day',HOUR) as date, avg(PRICE)as pricet,'Arbitrum' as network
    from ethereum.price.ez_prices_hourly
    where SYMBOL = 'WETH'
    and date = current_date
    group by 1)
    select a.NETWORK,TOKEN,USD,(TOKEN*pricet) as current_price_usd,(current_price_usd-USD)as diff,AVERAGE_Token_PRICE
    from ar a left join ETHt t on a.NETWORK=t.NETWORK)

    UNION

    (with op as (With optimism as (with optimism_fees as
    (select
    date_trunc('day',BLOCK_TIMESTAMP) as date,
    FROM_ADDRESS as address,
    sum (TX_FEE) as gas_paid
    from optimism.core.fact_transactions
    where FROM_ADDRESS = lower('{{ADDRESS}}')
    group by 1,2),
    Last run: about 1 month ago
    TOTAL_USD_PAID
    CURRENT_PRICE_TOTAL_USD
    TOTAL_DIFF
    1
    244267.881519343475689.97192408231546.030365779
    1
    53B
    23s