watchTpSlNotifications
Subscribe to live TP/SL notifications for one SubAccount.
Reuses the defilytics-protocol subscribe-frame builder and the SDK’s shared socket pool, so many watchers across the app share one underlying connection per (wsUrl, appName, account) triple. The channel is scoped by the chain’s tpsl.appName (e.g. Hyper-EVM_COH-Low-Cap_Production), distinct from the quote-state notifications stream. Inbound report frames are parsed by parseTpSlFrame into TpSlNotifications before your handler fires.
This is a subscribe function, not a query — there are no query options. For a React binding, use useWatchTpSlNotifications.
import { watchTpSlNotifications } from "@symmio/trading-core";
const unwatch = watchTpSlNotifications(config, {
account: subAccount,
onNotification: (frame) => {
console.log(frame.conditionalOrderType, frame.state, frame.successful);
},
onStatusChange: (status) => console.log(status),
onError: (err) => console.error(err),
});
// later, dispose (idempotent):
unwatch();Parameters
accountAddressrequiredSubAccount address to subscribe for.
Called for every normalized TP/SL report.
chainIdnumberoptionalTarget chain id. Defaults to the config’s defaultChainId.
onStatusChange(s: SocketStatus) => voidoptionalCalled whenever the underlying connection status changes. SocketStatus is "connecting" | "open" | "reconnecting" | "closing" | "closed".
onError(e: SymmError) => voidoptionalCalled on a transport or parse error; does not stop the subscription.
Returns
UnwatchTpSlAn idempotent disposer. Call it to stop the subscription; the pooled socket closes when the last watcher releases.
Throws
Throws a SymmError synchronously when the chain has no tpsl config or no WebSocket implementation is available.
Related
- WebSocket concept — pool, reconnect, and the
SocketStatuslifecycle. parseTpSlFrame— the per-frame parser used internally.TpSlNotification— the delivered payload shape.