with poly_fees as (
SELECT
date_trunc('hour',block_timestamp) as time,
avg(tx_fee) as avg_fee_matic
from polygon.core.fact_transactions
where block_timestamp < CURRENT_DATE
group by time
order by time DESC
),
matic_price as (
SELECT
hour as time,
price as price
from ethereum.core.fact_hourly_token_prices
where symbol ILIKE 'MATIC'
group by 1,2
order by 1 desc
),
ethereum_fees as (
SELECT
date_trunc('hour',block_timestamp) as time,
avg(tx_fee) as avg_fee_eth
from ethereum.core.fact_transactions
where block_timestamp < CURRENT_DATE
group by time
order by time DESC
),
eth_price as (
SELECT
hour as time,
price as eth_price
from ethereum.core.fact_hourly_token_prices
where lower(symbol) = 'weth'