Query editor
-- DUNE Query to fetch the latest ETH price in USD--> Provides a more granular view of network congestion and potential cost-effective transaction windows.--> Helps users decide the most economical time to make transactions.-- Fetch the latest Ethereum price in USD.WITH eth_price_usd AS (SELECT priceFROM prices.usdWHERE symbol = 'ETH'ORDER BY minute DESCLIMIT 1),-- Fetch the latest Optimism price in USD.op_price_usd AS (SELECT priceFROM prices.usdWHERE symbol = 'OP'ORDER BY minute DESCLIMIT 1),-- Fetch the latest Arbitrum price in USD.arb_price_usd AS (SELECT priceFROM prices.usdWHERE symbol = 'ARB'ORDER BY minute DESCLIMIT 1),-- CTE for Ethereum hourly average gas priceseth_hourly AS (SELECTDATE_TRUNC('hour', block_time) AS hour,AVG((gas_price/1e18) * gas_used) * (SELECT price FROM eth_price_usd) AS avg_eth_gas_price_usdFROM ethereum.transactionsWHERE DATE_TRUNC('day', block_time) = CURRENT_DATEGROUP BY DATE_TRUNC('hour', block_time)),-- CTE for Optimism hourly average gas prices using the given formulaoptimism_hourly AS (SELECTDATE_TRUNC('hour', block_time) AS hour,AVG((gas_price * gas_used + l1_fee)/1e18 * (SELECT price FROM eth_price_usd)) AS avg_optimism_gas_price_usdFROM optimism.transactionsWHERE DATE_TRUNC('day', block_time) = CURRENT_DATEGROUP BY DATE_TRUNC('hour', block_time)),-- CTE for Arbitrum hourly average gas prices using the given formulaarbitrum_hourly AS (SELECTDATE_TRUNC('hour', block_time) AS hour,AVG((gas_price + gas_used * effective_gas_price)/1e18 * (SELECT price FROM eth_price_usd)) AS avg_arbitrum_gas_price_usdFROM arbitrum.transactionsWHERE DATE_TRUNC('day', block_time) = CURRENT_DATEGROUP BY DATE_TRUNC('hour', block_time))