Skip to content

Tracking

trackOrderViaWebSocket accepts a serializable reference and emits the current state plus later status or transaction-hash changes. The compatibility name is stable; private mode uses browser SSE with a polling backstop, while Simple Bridge uses status polling.

import type {
  PrivateOrderReference,
  SilentSwapClient,
} from '@silentswap/sdk';
 
declare const client: SilentSwapClient;
declare const reference: PrivateOrderReference;
 
const unsubscribe = client.trackOrderViaWebSocket(
  reference,
  (state) => {
    console.log(state.status);
  },
  (error: unknown) => {
    console.error('tracking failed', error);
  },
);
 
unsubscribe;

Store and call unsubscribe when the owning screen unmounts. The watcher also closes on COMPLETED, FAILED, or ABORTED, and after its two-hour safety limit. It deliberately keeps watching DROPPED orders because a late source-chain deposit can resurrect them to OPEN.

Estimated payouts

While state.payoutsAreEstimates is true, the order is exact-input and still awaiting its deposit: every payout figure is a preview that the gateway event's credited amount will resize pro-rata. Render amounts with "≈" until the flag clears, so a number that is about to move is never shown as final.

import type { OrderState } from '@silentswap/sdk';
 
export function formatPayout(state: OrderState, amount: string): string {
  return state.payoutsAreEstimates ? `≈ ${amount}` : amount;
}

Use getOrder(reference) for one-shot private recovery after navigation. Do not start a second custom polling loop beside trackOrderViaWebSocket.