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@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 a 300
millisecond coalescing duration.
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@f subscription
type:object