> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polynode.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript Settlement Stream

> Consume acknowledged settlement subscriptions with reconnect replay, deduplication, and overflow visibility.

The event WebSocket carries pending settlements, confirmation updates, Chainlink prices, combo lifecycle events, wallet activity, and other product events. `send()` resolves only after the server acknowledges the subscription.

## Subscribe

```typescript theme={null}
import { PolyNode } from 'polynode-sdk';

const apiKey = process.env.POLYNODE_API_KEY;
if (!apiKey) throw new Error('Set POLYNODE_API_KEY');
const pn = new PolyNode({ apiKey });

const sub = await pn.ws
  .subscribe('settlements')
  .status('all')
  .minSize(100)
  .send();

console.log({
  subscriptionId: sub.id,
  warnings: sub.warnings,
});

sub.on('settlement', (event) => {
  console.log('pending', event.tx_hash, event.taker_size);
});

sub.on('status_update', (event) => {
  console.log('confirmed', event.tx_hash, event.block_number);
});

sub.on('*', (event) => {
  if (event.event_type === 'unknown') {
    console.log('new event type', event.wire_event_type, event.raw);
  }
});

sub.onOverflow((notice) => {
  console.error('consumer fell behind', notice);
});

pn.ws.onReplay((notice) => {
  console.warn('reconnect replay', notice);
});
```

## Presets and filters

Current presets are `settlements`, `trades`, `prices`, `dome`, `fills`, `combos`, `redemptions`, `redemption`, `deposits`, `blocks`, `wallets`, `markets`, `large_trades`, `global`, `oracle`, and `chainlink`.

Builder filters include wallets, tokens, market IDs, slugs, condition IDs, side, direction, status, size bounds, event types, initial snapshot count, reconnect `since`, Chainlink feeds and TWAP windows, combo and leg IDs, event IDs, module IDs, and action.

```typescript theme={null}
const fills = await pn.ws
  .subscribe('fills')
  .wallets(['0x...'])
  .conditionIds(['0x...'])
  .since(Date.now() - 30_000)
  .send();
```

## Reconnect behavior

When the socket reconnects, the SDK resubscribes with a cursor based on the latest accepted timestamp, requests a small overlap, and deduplicates the overlap. This is best-effort replay within the service's retained history; it is not an unlimited delivery guarantee. Treat `notice.guaranteed` as `false` and backfill through REST if your application requires durable completeness.

The async-iterator queue is bounded. If the consumer cannot keep up, `onOverflow` reports dropped events rather than hiding the loss.

Short-form rotation is different: it deliberately closes its dedicated socket at each market boundary and reconnects to subscribe to the next market and Chainlink selection. See [TypeScript short-form](/sdks/ts/short-form).

## Cleanup

```typescript theme={null}
sub.unsubscribe();
pn.ws.disconnect();
```

See the [shared settlement guide](/sdks/websocket-streaming) for acknowledgement fields, replay semantics, and event handling patterns.
