streamAccountUpdates() emits full account snapshots for one or more traders. It combines subgraph polling, Alchemy contract-log overlays, 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.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
alchemyApiKey can be provided when creating the client or when starting the stream. The stream throws if no Alchemy API key is available.
Response schema
positions, orders, and limits use the same SDK-formatted objects returned by getOpenPositions, getOrders, and getOpenOrders.