UNPKG

@moonwell-fi/moonwell-sdk

Version:

TypeScript Interface for Moonwell

15 lines 863 B
import type { PublicClient } from "viem"; /** * Find the block number on a chain whose timestamp is the latest one ≤ the target unix timestamp. * * Uses interpolation search anchored on the latest block and block 1: each iteration * narrows the range by reading one block and projecting the target via the slope of the * remaining range. Converges in ~3–5 RPC calls even on chains with variable block times. * * Assumes block 1 exists on the chain — true for every EVM chain Moonwell supports. * * Returns the latest block if `targetTimestamp` is at or after the head, and block 1 * if it is before block 1's timestamp. On a chain with only block 0, returns block 0. */ export declare function getBlockNumberAtTimestamp(publicClient: PublicClient, targetTimestamp: bigint): Promise<bigint>; //# sourceMappingURL=getBlockNumberAtTimestamp.d.ts.map