Messages
{
"op": "sub",
"id": 7,
"t": "userBalances@f@300",
"u": 2,
"feedEpoch": 0,
"seq": 2951
}Exchange WebSocket methods
User balances stream
Follow replayable balance updates with periodic full snapshots.
WSS
/
ws
userBalances@<p|v|f>[@<coalesceMs>]
(feedEpoch, globalUserSeq). Without seq, it
sends a complete finalized balance snapshot, replays retained updates after
that snapshot, and then joins live delivery. It also sends a complete snapshot
every five seconds by default. Incremental updates default to 300 milliseconds.
Market makers seeking earlier updates can use @p or @v in production,
provided they track tentative state by block ID and reconcile branchDropped.
Use @f when finalized state is required. Initial snapshots are finalized;
periodic snapshots use the selected view.
Durations are internally floored: 0–99 → immediate, 100–299 → 100 ms,
300–499 → 300 ms, and 500 or greater → 500 ms. The default is 300 ms.
Use @0 for delivery without intentional batching; @1 has the same behavior.
Periodic full snapshots remain enabled. See delivery cadence and branch
reconciliation for the view semantics and
delivery cadence for limits.
Subscribe
{"op":"sub","id":7,"t":"userBalances@f@300","u":2,"feedEpoch":0,"seq":2951}
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.
interface ExchangeWsUserBalancesFrameBase {
wireVersion: 1;
feedEpoch: bigint;
view: "finalized";
kind: "userBalances";
userId: bigint;
globalUserSeq: bigint | null;
globalSeq: bigint | null;
previousGlobalUserSeq: bigint | null;
balances: Array<{
tokenAddress: string;
freeBalance: bigint;
reservedBalance: bigint;
}>;
}
type ExchangeWsUserBalancesFrame =
| (ExchangeWsUserBalancesFrameBase & {
snapshot: true;
stateHead: { blockNumber: bigint; blockId: string } | null;
})
| (ExchangeWsUserBalancesFrameBase & {
snapshot: false;
sourceBlock: { blockNumber: bigint; blockId: string };
});
stateHead; an incremental frame has sourceBlock. Replace local balance
state when snapshot=true.
For an explicit replay cut R, accept the first publication when
globalUserSeq > R and previousGlobalUserSeq is null or at most R.
After that sparse bridge, every subsequent previousGlobalUserSeq must equal
the last accepted globalUserSeq exactly.Messages
{
"op": "sub",
"id": 7,
"t": "userBalances@f@300",
"u": 2,
"feedEpoch": 0,
"seq": 2951
}userBalances subscription
type:object