WebSocket Events
Message envelope
All business updates arrive on the Socket.IO event message with this shape (names match lib/types.ts in this repo and the SDK typings):
interface IntegrationWsMessageBaseData {
externalUserId: string;
integrationId: string;
userId?: number | string;
}
interface IntegrationWsMessage<T = IntegrationWsMessageBaseData> {
action: string;
data: T;
}Base fields on every data payload:
externalUserId— external user id from your systemintegrationIduserId— optional (internal or external id depending on payload)
Payload types by action
Each action narrows data beyond the base fields. TypeScript names below are IntegrationWs* in lib/types.ts.
action | data type | Notable fields |
|---|---|---|
strategyUpdate | IntegrationWsStrategyUpdateData | strategyId, event (literal halted, resumed, or archived), strategy |
swap | IntegrationWsSwapData | step (literal scheduled, executing, completed, or failed), swapId, chainId, optional type, amount, txSignature, balanceUpdated, error |
depositStart | IntegrationWsDepositStartData | depositId, phase, chainId, chainType, depositAddress |
depositStep | IntegrationWsDepositStepData | step (string); server may add more keys ([key: string]: unknown) |
withdrawStart | IntegrationWsWithdrawStartData | withdrawId, phase, chainId, tokenAddress, amount, receiverAddress |
withdrawStep | IntegrationWsWithdrawStepData | step (string); additional keys allowed |
executionStep | IntegrationWsExecutionStepData | strategyId, step, chainId, type (buy or sell) |
Listen for message
Use the same socket.io-client options as Connect — Client options (path, transports, reconnection, etc.).
curl
Event streams are not available via plain curl. Use socket.io-client or the SDK (other tabs).
The polling probe on Connect only checks reachability, not business events.
Action catalog
The broadcaster emits message with action set to one of the IntegrationWsAction string literals:
strategyUpdateswapdepositStartdepositStepwithdrawStartwithdrawStepexecutionStep
Server-side emit shape: socket.to(integrationId).emit("message", { action, data }).
Typed handlers (SDK options)
The SDK maps each action to an optional typed callback:
| Method | action |
|---|---|
onStrategyUpdate | strategyUpdate |
onSwap | swap |
onDepositStart | depositStart |
onDepositStep | depositStep |
onWithdrawStart | withdrawStart |
onWithdrawStep | withdrawStep |
onExecutionStep | executionStep |
onAction(name, cb) | custom action string |
onMessage(cb) | full envelope: action + data |
Node.js
socket.on("message", (msg) => {
switch (msg.action) {
case "swap":
console.log("swap", msg.data.swapId, msg.data.step);
break;
case "executionStep":
console.log("execution", msg.data.strategyId, msg.data.step);
break;
default:
console.log(msg.action, msg.data);
}
});Unsubscribe
SDK handlers return an unsubscribe function:
const off = ws.onSwap((data) => {});
off();With raw socket.io-client, use socket.off("message", handler) or keep a named handler reference.