Query editor
WITH l1_fees_combined AS (SELECTDATE_TRUNC('Month', day) AS evt_day,name,SUM(data_fee_usd) AS l1_calldata_cost_usd,SUM(verification_fee_usd) AS l1_verification_cost_usdFROM rollup_economics_ethereum.l1_feesWHERE name = 'blast'AND day >= CURRENT_DATE - INTERVAL '6' monthGROUP BY 1, 2),rev AS (SELECTDATE_TRUNC('Month', day) AS evt_day,name,SUM(l2_rev_usd) AS l2_revenue_usdFROM rollup_economics_ethereum.l2_revenueWHERE name = 'blast'AND day >= CURRENT_DATE - INTERVAL '6' monthGROUP BY 1, 2),txns AS (SELECTDATE_TRUNC('Month', block_time) AS evt_day,COUNT(*) AS arb_transactionsFROM blast.transactionsWHERE to NOT IN (SELECT addressFROM labels.system_addressesWHERE blockchain = 'blast')AND block_time >= CURRENT_DATE - INTERVAL '6' monthGROUP BY 1),final AS (SELECTt.evt_day,t.arb_transactions,-f.l1_calldata_cost_usd AS l1_calldata_cost_usd,COALESCE(r.l2_revenue_usd, 0) AS l2_revenue_usd,-COALESCE(f.l1_verification_cost_usd, 0) AS l1_verification_cost_usd,CASEWHEN r.l2_revenue_usd IS NOT NULL THEN r.l2_revenue_usd - f.l1_calldata_cost_usd - COALESCE(f.l1_verification_cost_usd, 0)ELSE 0END AS margin_usdFROM l1_fees_combined fLEFT JOIN rev r ON f.evt_day = r.evt_dayRIGHT JOIN txns t ON t.evt_day = f.evt_day)SELECTevt_day,SUM(l1_calldata_cost_usd) OVER (ORDER BY evt_day) AS cumulative_l1_calldata_cost_usd,SUM(l2_revenue_usd) OVER (ORDER BY evt_day) AS cumulative_l2_rev_usd,SUM(margin_usd) OVER (ORDER BY evt_day) AS cumulative_margin_usdFROM finalORDER BY 1;