streamAccountUpdates() emits full account snapshots for one or more traders. It combines subgraph polling, contract-log overlays read over your RPC, and live price repricing so market opens and full closes can appear before subgraph indexing catches up.
OstiumSubgraphClient require a user address array.
Multiple addresses
Pass one or more addresses inuser to subscribe to accounts on a single stream. The stream uses one WebSocket, one poll loop, and one price feed regardless of how many addresses you watch — far cheaper than opening one stream per trader.
positions, orders, and limits. Duplicate addresses are de-duplicated, and stream.users returns the subscribed addresses.
Optimistic opens
For market opens, add an optimistic overlay immediately after submission and reconcile it once you know the on-chain order id.extractOrderIdFromReceipt() decodes the current Trading contract’s market-open and market-close initiation events, plus older PriceRequested receipts. The returned id matches the base-10 Order.oid and Fill.oid format used by SDK reads.
addOptimisticOpen() only supports market open orders. When streaming multiple addresses, pass the owning address as the third argument (addOptimisticOpen(params, result, '0xTraderA')); it is optional and defaults to the sole subscribed address when streaming one trader.
Parameters
RPC configuration
The stream needs a WebSocket Arbitrum RPC endpoint. It makes only standard JSON-RPC calls, so any node works:alchemyApiKey remains fully supported — it builds the Alchemy URLs for you:
rpcWsUrl in browser code — it keeps a vendor key out of your bundle.
Either can be set when creating the client or per stream call, where the per-call value wins. With neither, the stream throws OstiumSubgraphError with code INVALID_CONFIG.
rpcHttpUrl is optional. These reads resolve in order: rpcHttpUrl, then the Alchemy URL when alchemyApiKey is set, then rpcUrl, then the public Arbitrum RPC.
pollIntervalMs defaults to 3000. Sub-second open/close confirmations come from the Alchemy event watchers (which also trigger an immediate poll), so the timer poll only paces reconciliation of changes with no watcher — limit fills, partial closes, TP/SL edits, and liquidations. Pass a lower value to restore a faster cadence. All subscribed traders are fetched in a single batched subgraph query per poll.
The contract-log WebSocket reconnects indefinitely with a 2-second delay. Fast-overlay positions seed rollover from the pair accumulator at the open block, so streamed PnL and liquidation estimates stay aligned with the eventual indexed position.
Response schema
positions, orders, and limits use the same SDK-formatted objects returned by getOpenPositions, getOrders, and getOpenOrders.