mo115Gas copy
    Updated 2023-04-26
    (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.core.fact_hourly_token_prices
    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.core.fact_hourly_token_prices
    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),
    ETH as (select date_trunc ('day',HOUR) as date, avg(PRICE)as price
    from ethereum.core.fact_hourly_token_prices
    Run a query to Download Data