Query editor
WITHr AS (SELECTreportTotalValue / 1e18 AS total_value_eth,reportInOutDelta / 1e18 AS unstaked_balance_eth,reportLiabilityShares,reportCumulativeLidoFees,reportSlashingReserve,evt_block_timeFROM lido_ethereum.vaulthub_evt_vaultreportappliedWHERE vault = 0x62e0d92cf7b8752b5292b9bcbbace4cfa1633428ORDER BY evt_block_time DESCLIMIT 1),rebased AS (SELECT(posttotalether * 1.0) / posttotalshares AS steth_per_shareFROM lido_ethereum.steth_evt_tokenrebasedWHERE evt_block_time <= (SELECT evt_block_time FROM r)ORDER BY evt_block_time DESCLIMIT 1),calc AS (SELECTtotal_value_eth,unstaked_balance_eth,(r.reportLiabilityShares * rebased.steth_per_share) / 1e18AS steth_liability,(r.reportCumulativeLidoFees + r.reportSlashingReserve) / 1e18AS fee_obligations_ethFROM rCROSS JOIN rebased)SELECTtotal_value_eth AS total_value_eth,steth_liability AS steth_liability,-- Locked by collateral using known reserve ratio = 3.5%steth_liability / (1 - 0.035) AS eth_locked_by_collateral,-- Available immediate withdrawalLEAST(unstaked_balance_eth,total_value_eth- (steth_liability / (1 - 0.035))- fee_obligations_eth) AS steth_available_for_immediate_withdrawalFROM calc;