import { Hex } from 'viem'; import { VaultBasicInfo, VaultRegistryReader } from '../../clients/eth/types'; /** * Ethereum block confirmations required before the Pre-PegIn BTC transaction * may be broadcast. * * 8 exceeds the deepest reorg ever observed on Ethereum (7, pre-merge, caused * by a client bug), and costs ~1.6 min at 12s slots. Deliberately not the * `safe` block tag: a full epoch (~12.8 min) was rejected as too slow for the * benefit. This is a liveness guard against an orphaned registration, not a * theft mitigation — every Pre-PegIn HTLC spend path requires the depositor's * own BTC key regardless. */ export declare const PEGIN_ETH_CONFIRMATIONS = 8; /** * The vault is not registered on-chain, and stayed that way past the grace * window — long enough that a lagging backend has been ruled out. Retrying * will not help. */ export declare class PeginRegistrationMissingError extends Error { constructor(message: string); } /** The registration did not reach the required depth within the budget. */ export declare class PeginRegistrationNotFinalError extends Error { constructor(message: string); } export declare function isPeginRegistrationMissingError(err: unknown): err is PeginRegistrationMissingError; export declare function isPeginRegistrationNotFinalError(err: unknown): err is PeginRegistrationNotFinalError; export interface RegistrationDepthParams { /** Current chain tip block number. */ currentBlock: bigint; /** Block number the registration was mined at (`VaultBasicInfo.createdAt`). */ createdAtBlock: bigint; } /** * Confirmations accrued by a registration: the mining block counts as the * first confirmation, so `tip === createdAt` is 1. * * Clamped at 0. A reorg between the tip read and the vault read can surface a * `createdAt` above the tip already in hand; a negative depth must never * propagate into a comparison. */ export declare function computeRegistrationConfirmations(params: RegistrationDepthParams): number; export interface RegistrationDepthProgress { /** Shallowest depth across every vault being waited on. */ confirmations: number; required: number; } export interface WaitForPeginRegistrationDepthParams { vaultRegistryReader: VaultRegistryReader; /** * Chain-tip reader. A thunk rather than a `PublicClient` so this module has * no viem-client dependency and stays testable with two plain fakes — the * same shape `verifyRegisteredVaultVersions` uses for its reader. */ getBlockNumber: () => Promise; /** Vaults registered by the same transaction; the shallowest one gates. */ vaultIds: readonly Hex[]; required?: number; pollIntervalMs?: number; timeoutMs?: number; signal?: AbortSignal; onProgress?: (progress: RegistrationDepthProgress) => void; } export interface PeginRegistrationDepthResult { confirmations: number; /** * The final observation for the shallowest vault. Callers that gated on * `status` before the wait should re-assert it against this — the wait can * span minutes, and a vault can leave PENDING in that time. */ basicInfo: VaultBasicInfo; } /** * Poll until every vault's registration is at least `required` blocks deep. * * A read that comes back empty is treated as "not visible yet", not as * "absent": both callers reach this having already proven the registration * exists, so an empty read means a lagging RPC backend or a reorg, and both * resolve on their own. * * @throws {PeginRegistrationMissingError} if no vault has ever been observed and the grace window is spent. * @throws {PeginRegistrationNotFinalError} on timeout. * @throws if aborted. */ export declare function waitForPeginRegistrationDepth(params: WaitForPeginRegistrationDepthParams): Promise; //# sourceMappingURL=peginRegistrationDepth.d.ts.map