@somnia-chain/markets-sdk / index / quoteBinarySellOverBook
Function: quoteBinarySellOverBook()
quoteBinarySellOverBook(
book,side,quantity,oneCollateral,params):BinarySellQuote|null
Defined in: packages/sdk/src/derivedReads.ts:752
Build a market SELL that unwinds quantity of an outcome by crossing the
resting bids, with a slippage cushion below the best bid — the sell-side
sibling of quoteBinaryStakeOverBook.
Pinning the protective limit to the exact best bid means any tick of book churn between the quote and on-chain execution leaves the IOC uncrossable — a sell into a busy book fills nothing. The limit instead sits a cushion below the best bid, aligned DOWN to the tick grid (never below one tick): the order still fills each resting bid at its own price, best-first.
Unlike the buy side, quantity is NOT sized to the book — it's the
caller's position, lot-aligned. The quote walks the crossable bids and
reports fillableQuantity/estProceeds so a thin book surfaces as a
partial unwind up front rather than a silent IOC cancel.
Returns null when there's nothing to sell (including a position below
the pool's minQuantity) or no bid to cross — disable the Sell control
rather than sending a doomed order.
Parameters
book
The live four-sided book (NO sides pre-inverted).
side
"SELL_YES" (Up position) or "SELL_NO" (Down position).
quantity
bigint
Outcome-token quantity to sell, raw units (snapped down to the lot grid).
oneCollateral
bigint
10^quoteDecimals — one whole outcome share.
params
The pool's tick/lot grid + slippage policy.
Returns
BinarySellQuote | null