lidoWithdrawals finalization time
    Updated 4 days ago
    -- retrieves the minimum and maximum withdrawal IDs for the last 7 days
    with finalized_ids AS (
    SELECT
    BLOCK_TIMESTAMP
    , DECODED_LOG:from AS "from"
    , DECODED_LOG:to AS "to"
    FROM ethereum.core.ez_decoded_event_logs
    WHERE CONTRACT_ADDRESS = '0x889edc2edab5f40e902b864ad4d7ade8e412f9b1' --Lido withrawal queue
    AND EVENT_NAME = 'WithdrawalsFinalized'

    )
    -- aggregates data from previous CTE
    , aggr_finalized_ids AS (
    SELECT
    MIN("from") AS min_id
    , MAX("to") AS max_id
    FROM finalized_ids
    WHERE BLOCK_TIMESTAMP::date >= date_trunc('day', CURRENT_DATE - interval '7 day')
    )
    -- gets withdrawal records within the range defined by the minimum and maximum IDs
    , requested_ids AS (
    SELECT
    BLOCK_TIMESTAMP
    , DECODED_LOG:requestId AS requestId
    , DECODED_LOG:amountOfStETH AS amountOfStETH
    FROM ethereum.core.ez_decoded_event_logs
    WHERE CONTRACT_ADDRESS = '0x889edc2edab5f40e902b864ad4d7ade8e412f9b1'
    AND EVENT_NAME = 'WithdrawalRequested'
    AND DECODED_LOG:requestId >= (SELECT min_id FROM aggr_finalized_ids)
    AND DECODED_LOG:requestId <= (SELECT max_id FROM aggr_finalized_ids)

    )
    -- time difference between withdrawal request and finalization
    , latency AS (
    SELECT
    r.requestId
    Last run: 4 days ago
    MEDIAN_HOURS
    AVERAGE_HOURS
    1
    144147.729753
    1
    18B
    30s