Skip to main content
useLiquidationFeed returns the newest persisted liquidation events for one margin pair and merges the public WebSocket stream into the same list.
The hook requests the newest REST page on mount, even before the WebSocket connects, and subscribes to market_liquidations:{tradingPairId} for live updates. When the server confirms or restores the subscription, it pages through the full gap from the latest seen event timestamp; if there is no checkpoint, it reads only the newest page. A gap read stops once it has fetched the newest 500 events, the most the hook keeps. Because storage can lag the live stream, the hook repeats the read from the newest stored event it has seen, waiting 1, 2, 4 and then 8 seconds after each read finishes (so roughly 1, 3, 7 and 15 seconds after the first). It stops early once stored history contains the first live event received after the subscription was confirmed, or, when no live event has arrived, once two repeats in a row find nothing new. It merges recovered rows with live updates, deduplicates by eventId, and keeps the newest 500 events, dropping older ones. The stream has no snapshot. Timestamps are Unix milliseconds, sizes and prices are decimal strings, and markNotional uses the event’s captured mark in the quote asset.