Query editor
/*This query calculates the median and average time to complete withdrawal processfor THE last 7 days*/-- This CTE retrieves the minimum and maximum withdrawal IDs for the last 7 dayswithfinalized_ids AS (SELECTMIN("from") AS MIN_id,MAX("to") AS MAX_idFROMlido_ethereum.WithdrawalQueueERC721_evt_WithdrawalsFinalizedWHEREdate_trunc('day', evt_block_time) >= date_trunc('day', now() - interval '7' day)),-- This CTE gets withdrawal records within the range defined by the minimum and maximum IDs.requested_ids AS (SELECT*FROMlido_ethereum.WithdrawalQueueERC721_evt_WithdrawalRequestedWHERErequestId >= (SELECTMIN_idFROMfinalized_ids)and requestId <= (SELECTMAX_idFROMfinalized_ids)),-- This CTE calculates the latency (time difference) between withdrawal request and finalizationlatency AS (SELECTrequested.requestId,requested.amountOfStETH / 1e18 AS amount,requested.evt_block_time AS request_time,finalized.evt_block_time AS finalized_time,date_diff('hour',requested.evt_block_time,finalized.evt_block_time) AS latency_hoursFROMrequested_ids requestedLEFT JOIN lido_ethereum.WithdrawalQueueERC721_evt_WithdrawalsFinalized finalized ON requested.requestId >= finalized."from"AND requested.requestId <= finalized."to")-- final select calculates the median and average latency in hoursSELECTapprox_percentile(latency_hours, 0.5) AS median_hours,AVG(latency_hours) AS average_hours