{s}omniamarkets

@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / getBookTops

Function: getBookTops()

getBookTops(marketIds, indexerUrl): Promise<Record<string, BookTop>>

Defined in: query.ts:2718

Batch-fetch the top of book (best resting bid/ask + mid) for many binary markets in ONE round-trip — for list views that want a book-derived implied probability without an N+1 per-pool fan-out. Returns a map of lowercased marketId → BookTop; markets with an empty book are simply absent.

Orders are stamped with market_id at placement, so keying on the market is recycle-safe (a reused pool's prior-market orders never bleed in). On-chain expiry is LAZY (an expired maker keeps resting with no OrderExpired event), so this mirrors getBookLevels' now > expiry skip in the where clause.

Parameters

marketIds

string[]

indexerUrl

string

Returns

Promise<Record<string, BookTop>>