Query editor
with optimism as (selectday, AVG(transaction_fee) as op_transaction_feesfrom (select*, DATE_TRUNC('day', block_time) as day, (gas_used * gas_price + l1_fee) / CAST(10e17 as DOUBLE) as transaction_feefrom optimism.transactions)group by1), arbitrum as (selectDATE_TRUNC('day', block_time) as day, AVG(transaction_fee) as arb_transaction_feesfrom (select*, ((gas_used + gas_used_for_l1) * effective_gas_price) / CAST(10e17 as DOUBLE) as transaction_feefrom arbitrum.transactions)group by1), ethereum as (selectDATE_TRUNC('day', block_time) as day, AVG(transaction_fee) as eth_transaction_feesfrom (select*, casewhen (type = 'Legacy'or type = 'AccessList')then (gas_price * t.gas_used) / CAST(1e18 as DOUBLE)when type = 'DynamicFee'and base_fee_per_gas + max_priority_fee_per_gas <= max_fee_per_gasthen ((base_fee_per_gas + COALESCE(max_priority_fee_per_gas, 0)) * t.gas_used) / CAST(1e18 as DOUBLE)when type = 'DynamicFee'and base_fee_per_gas + max_priority_fee_per_gas > max_fee_per_gasthen (max_fee_per_gas * t.gas_used) / CAST(1e18 as DOUBLE)end as transaction_feefrom ethereum.transactions as tleft join ethereum.blocks as b on block_number = number)group by1), eth_price as (selectDATE_TRUNC('day', minute) as day, AVG(price) as eth_pricefrom prices.usdwhere symbol = 'WETH'group by1)selecto.*, a.arb_transaction_fees, e.eth_transaction_fees, (e.eth_transaction_fees - o.op_transaction_fees) / CAST(e.eth_transaction_fees as DOUBLE) * 100 as optimism_savings, (e.eth_transaction_fees - a.arb_transaction_fees) / CAST(e.eth_transaction_fees as DOUBLE) * 100 as arbitrum_savings