HOOK use-orderbook
useOrderbook
Subscribes to the L2 orderbook for a prediction market coin via WebSocket. Returns { bids: BookLevel[], asks: BookLevel[], spread: number|null, midPrice: number|null, isLoading, error }. Pass { bids, asks } as bookData to TradeForm. Call as useOrderbook(coin) with HIP4Provider or useOrderbook(client, coin).
Install
$
npx shadcn@latest add https://ui.purrdict.xyz/r/use-orderbook.json Signature
useOrderbook(client?: HIP4Client, coin: string) Returns
{ bids, asks, spread, midPrice } Usage
// Explicit client
const { bids, asks } = useOrderbook(client, market.yesCoin)
// Or with HIP4Provider
const { bids, asks } = useOrderbook(undefined, market.yesCoin) Dependencies
npm packages
Registry components