Query editor
with block_data as (SELECTtime as block_time, number as block_number, base_fee_per_gas / 1e9 as base_fee_per_gas_gweiFROM base.blocks blWHEREtime >= NOW() - INTERVAL '60' DAY), trxn_data as (SELECTt.hash, t.block_time, t.index, SUM(t.l1_fee / 1e18) as l1_fees_paid_eth, SUM(t.gas_used * b.base_fee_per_gas_gwei) / 1e9 as l2_base_fees_paid_eth, SUM(t.gas_used * (t.gas_price / 1e18 - b.base_fee_per_gas_gwei / 1e9)) as l2_priority_fees_paid_eth, SUM(t.gas_used * t.gas_price / 1e18) as total_l2_fees_paid_ethFROM base.transactions tJOIN block_data bON b.block_time = t.block_timeWHEREt.block_time >= NOW() - INTERVAL '60' DAYAND t.gas_price != 0GROUP BY 1,2,3)SELECTa.tx_hash, t.index, a.block_time, a.trade_path, a.start_amount_usd, a.end_amount_usd, a.profit_usd, SUM((t.l1_fees_paid_eth +t.total_l2_fees_paid_eth) * p.price) as total_gas_paid_usd, SUM(a.profit_usd) - SUM((t.l1_fees_paid_eth +t.total_l2_fees_paid_eth) * p.price) as profit_usd_after_gasFROM query_4459753 aJOIN trxn_data tON t.hash = a.tx_hashJOIN prices.usd pON DATE_TRUNC('minute', t.block_time) = p.minuteAND p.contract_address = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2GROUP BY 1,2,3,4,5,6,7ORDER BY profit_usd DESC