> ## 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 Types

> Narrow event unions, preserve unknown additive messages, and keep exact numeric wire values.

Event messages use a discriminated `event_type` union:

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

function handleEvent(event: PolyNodeEvent): void {
  switch (event.event_type) {
    case 'settlement':
      console.log(event.tx_hash, event.taker_size);
      break;
    case 'status_update':
      console.log(event.tx_hash, event.block_number);
      break;
    case 'price_feed':
      console.log(event.feed, event.price, event.twap_window_seconds);
      break;
    case 'unknown':
      console.log(event.wire_event_type, event.raw);
      break;
    default:
      console.log(event.event_type);
  }
}
```

The union includes fills, settlements, trades, status updates, blocks, position changes, deposits, splits, merges, conversions, redemptions, combo execution/status/lifecycle/approval events, oracle events, Chainlink price feeds, and an `unknown` variant.

Unknown additive events and fields are preserved so a compatible server addition does not require dropping the payload. Treat `unknown` as observable data, not as a fatal protocol error.

Orderbook `price` and `size` values and perps prices/quantities are exact decimal strings. Keep them as strings or convert with a decimal library; do not use JavaScript `number` for exact accounting.

V3 generic calls return wire JSON. Supply a type argument only when your application owns and validates the corresponding schema:

```typescript theme={null}
type Stats = { trades: string; wallets: string };
const stats = await pn.v3.execute<Stats>('GET /v3/stats');
```

See [event reference](/websocket/events/settlement), [orderbook protocol](/orderbook/overview), and [perps channels](/perps/websocket/channels) for wire fields.
