with token_price as (
select
date_trunc('day', hour) as day,
avg(price) as price
from ethereum.core.fact_hourly_token_prices
where token_address is null
group by 1
)
select
date_trunc('day', block_timestamp) as date,
avg(price) * sum(tx_fee) as fee_usd
from optimism.core.fact_transactions join token_price on block_timestamp::date = day
where date >= '2022-01-01' and date < current_date
group by 1