Messages
{
"op": "sub",
"id": 3,
"t": "l2Book@f@500",
"m": "0x8121EE960066e4344A213F9aC7502395502aEe7a",
"feedEpoch": 0,
"n": 20,
"g": "sf",
"sf": 5,
"mt": 2,
"e": false
}Exchange WebSocket methods
L2 book stream
Receive complete finalized order-book snapshots on a fixed cadence.
WSS
/
ws
l2Book@f@<coalesceMs>
Subscribe
{
"op": "sub",
"id": 3,
"t": "l2Book@f@500",
"m": "0x8121EE960066e4344A213F9aC7502395502aEe7a",
"feedEpoch": 0,
"n": 20,
"g": "sf",
"sf": 5,
"mt": 2,
"e": false
}
n is depth per side from 1 through 200. Grouping g is none, tick,
or sf. Use tk with tick grouping, sf and optional mt with significant
figures, and e=true for active/passive decomposition.
Decoded event
The shape below is the innermessage returned by decodeExchangeWsEnvelope
or decodeExchangeWsMessage. Every binary socket message also carries an outer
id: bigint, matching your subscription ID. Use it to route snapshots, replay,
and live updates. See binary subscription envelopes.
type ExchangeWsL2Grouping =
| { kind: "none" }
| { kind: "nativeTick"; tickSize: bigint }
| {
kind: "significantFigures";
figures: number;
mantissa: number | null;
};
interface ExchangeWsCompactL2Level {
price: bigint;
totalBase: bigint;
}
interface ExchangeWsExtendedL2Level extends ExchangeWsCompactL2Level {
activeBase: bigint;
passiveBase: bigint;
activeOrderCount: number;
}
interface ExchangeWsL2BookFrameBase {
wireVersion: 1;
feedEpoch: bigint;
view: "finalized";
kind: "l2Book";
marketAddress: string;
marketSeq: bigint;
globalSeq: bigint;
stateHead: { blockNumber: bigint; blockId: string };
durationMs: bigint;
maxDepthPerSide: number;
grouping: ExchangeWsL2Grouping;
}
type ExchangeWsL2BookFrame =
| (ExchangeWsL2BookFrameBase & {
levelFormat: "compact";
bids: ExchangeWsCompactL2Level[];
asks: ExchangeWsCompactL2Level[];
})
| (ExchangeWsL2BookFrameBase & {
levelFormat: "extended";
bids: ExchangeWsExtendedL2Level[];
asks: ExchangeWsExtendedL2Level[];
});
tickSize in protocol ticks.Messages
{
"op": "sub",
"id": 3,
"t": "l2Book@f@500",
"m": "0x8121EE960066e4344A213F9aC7502395502aEe7a",
"feedEpoch": 0,
"n": 20,
"g": "sf",
"sf": 5,
"mt": 2,
"e": false
}l2Book@f subscription
type:object