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

# trading

> Confirmed order flow from the Polymarket exchange contracts — fills, matches, cancels, preapprovals, and trading pauses.

The `trading` channel sends every order-flow event from the Polymarket exchange contracts (CTFExchange and NegRiskCTFExchange, v1 and v2). We decode each one and send it after the transaction is confirmed on-chain.

<Note>
  Exchange fees are no longer on this channel. They moved to the
  [`fees`](/websockets/channels/fees) channel. ERC-1155 position transfers are
  on [`transfers`](/websockets/channels/transfers).
</Note>

## Subscribe

```json theme={null}
{
  "action": "subscribe",
  "id": "s1",
  "channel": "trading"
}
```

With no filters, you get every confirmed order-flow event from all markets. Add filters to narrow to certain traders, markets, tokens, or trade sizes.

## Filters

| Filter       | Type       | Required | Description                                                                                                                        |
| ------------ | ---------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `wallets`    | `string[]` | No       | Hex addresses (`0x…`). Empty or left out means all traders. Otherwise, only events where a listed address is the maker or taker.   |
| `market_ids` | `string[]` | No       | Condition IDs as `bytes32` hex strings. Keeps events for the listed markets.                                                       |
| `token_ids`  | `string[]` | No       | Token IDs as decimal strings. Keeps events for the listed outcome tokens.                                                          |
| `min_usd`    | `integer`  | No       | Smallest trade size in whole USD. Empty or left out means all sizes. Only kept if a fill's USD size is at or above this threshold. |

`market_ids` and `token_ids` are one axis — a market's condition id and its outcome token ids both identify it, so an event matches if it hits either list. All axes combine with AND: a wallet **and** a market **and** a size, if you set several. See [Filters](/websockets/filters) for the full combination rule.

```json theme={null}
{
  "action": "subscribe",
  "id": "s1",
  "channel": "trading",
  "filters": { "wallets": ["0x1234…abcd"], "min_usd": 100 }
}
```

<Note>
  `min_usd` is a `trading`-only filter. The `large_trades` channel was removed —
  subscribe to `trading` with `min_usd` to get only large fills.
</Note>

## Events

This channel sends all nine exchange order-flow events. See [Onchain Data](/concepts/onchain-data) for the part each event plays in the full order lifecycle.

| Event                         | `data.type`                     | Description                                                                          |
| ----------------------------- | ------------------------------- | ------------------------------------------------------------------------------------ |
| `OrderFilledV1`               | `order_filled_v1`               | A fill on exchange v1. Carries maker, taker, asset ids, and amounts.                 |
| `OrderFilledV2`               | `order_filled_v2`               | A fill on exchange v2. Also adds `side`, `tokenId`, `builder`, and `metadata`.       |
| `OrdersMatchedV1`             | `orders_matched_v1`             | The matched order pair around a v1 fill. Shows how taker intent met maker liquidity. |
| `OrdersMatchedV2`             | `orders_matched_v2`             | The matched order pair around a v2 fill. Also includes `side` and `tokenId`.         |
| `OrderCancelled`              | `order_cancelled`               | An order cancelled by its hash, before it filled.                                    |
| `OrderPreapproved`            | `order_preapproved`             | A v2 order preapproved for later execution, by its hash.                             |
| `OrderPreapprovalInvalidated` | `order_preapproval_invalidated` | A v2 order preapproval invalidated, by its hash.                                     |
| `TradingPaused`               | `trading_paused`                | An operator paused trading on an exchange. Carries the pauser address.               |
| `TradingUnpaused`             | `trading_unpaused`              | Trading resumed after a pause. Carries the pauser address.                           |

<Note>
  Do you want a trader's full activity, not just order flow? That means
  transfers, redemptions, splits, and position moves. Use the
  [`wallets`](/websockets/channels/overview#filter-channels) filter channel
  instead. It sends every event type that involves the address.
</Note>

## Payloads

Every frame wraps the event in the standard envelope (`type`, `id`, `channel`, `confirmed`, `data`) shown on [Frames](/websockets/frames). Below, each block is the `data` object for one event — its `type` discriminator plus every field the ABI decodes. A full frame looks like:

```json theme={null}
{
  "type": "event",
  "id": "s1",
  "channel": "trading",
  "confirmed": true,
  "data": {
    "type": "order_filled_v2",
    "orderHash": "0x…",
    "maker": "0x…",
    "…": "…"
  }
}
```

### `order_filled_v1`

`OrderFilled` on CTFExchange v1 / NegRiskCTFExchange v1. The v1 signature identifies both sides of the trade with asset ids, not a single `tokenId`.

```json theme={null}
{
  "type": "order_filled_v1",
  "orderHash": "0x…",
  "maker": "0x…",
  "taker": "0x…",
  "makerAssetId": "0x…",
  "takerAssetId": "0x…",
  "makerAmountFilled": "0x…",
  "takerAmountFilled": "0x…",
  "fee": "0x…"
}
```

| Field               | Solidity type   | Description                                         |
| ------------------- | --------------- | --------------------------------------------------- |
| `type`              | string          | `order_filled_v1`.                                  |
| `orderHash`         | `bytes32` (hex) | Hash of the filled order.                           |
| `maker`             | `address` (hex) | Maker address.                                      |
| `taker`             | `address` (hex) | Taker address.                                      |
| `makerAssetId`      | `uint256` (hex) | Asset id the maker gave. `0` means USDC collateral. |
| `takerAssetId`      | `uint256` (hex) | Asset id the taker gave. `0` means USDC collateral. |
| `makerAmountFilled` | `uint256` (hex) | Amount of the maker asset filled.                   |
| `takerAmountFilled` | `uint256` (hex) | Amount of the taker asset filled.                   |
| `fee`               | `uint256` (hex) | Fee recorded on the fill.                           |

### `order_filled_v2`

`OrderFilled` on CTFExchange v2 / NegRiskCTFExchange v2. The v2 signature replaces the asset-id pair with a `side` and a single `tokenId`, and adds `builder` and `metadata`.

```json theme={null}
{
  "type": "order_filled_v2",
  "orderHash": "0x…",
  "maker": "0x…",
  "taker": "0x…",
  "side": 0,
  "tokenId": "0x…",
  "makerAmountFilled": "0x…",
  "takerAmountFilled": "0x…",
  "fee": "0x…",
  "builder": "0x…",
  "metadata": "0x…"
}
```

| Field               | Solidity type   | Description                        |
| ------------------- | --------------- | ---------------------------------- |
| `type`              | string          | `order_filled_v2`.                 |
| `orderHash`         | `bytes32` (hex) | Hash of the filled order.          |
| `maker`             | `address` (hex) | Maker address.                     |
| `taker`             | `address` (hex) | Taker address.                     |
| `side`              | `uint8`         | `0` = buy, `1` = sell.             |
| `tokenId`           | `uint256` (hex) | Outcome token traded.              |
| `makerAmountFilled` | `uint256` (hex) | Amount the maker filled.           |
| `takerAmountFilled` | `uint256` (hex) | Amount the taker filled.           |
| `fee`               | `uint256` (hex) | Fee recorded on the fill.          |
| `builder`           | `bytes32` (hex) | Builder tag attached to the order. |
| `metadata`          | `bytes32` (hex) | Order metadata.                    |

### `orders_matched_v1`

`OrdersMatched` on the v1 exchanges. The match record around a v1 fill — the taker order hash and how much of each asset moved.

```json theme={null}
{
  "type": "orders_matched_v1",
  "takerOrderHash": "0x…",
  "takerOrderMaker": "0x…",
  "makerAssetId": "0x…",
  "takerAssetId": "0x…",
  "makerAmountFilled": "0x…",
  "takerAmountFilled": "0x…"
}
```

| Field               | Solidity type   | Description                                   |
| ------------------- | --------------- | --------------------------------------------- |
| `type`              | string          | `orders_matched_v1`.                          |
| `takerOrderHash`    | `bytes32` (hex) | Hash of the taker order that drove the match. |
| `takerOrderMaker`   | `address` (hex) | Maker of the taker order.                     |
| `makerAssetId`      | `uint256` (hex) | Asset id given by the maker side.             |
| `takerAssetId`      | `uint256` (hex) | Asset id given by the taker side.             |
| `makerAmountFilled` | `uint256` (hex) | Total maker asset filled across the match.    |
| `takerAmountFilled` | `uint256` (hex) | Total taker asset filled across the match.    |

### `orders_matched_v2`

`OrdersMatched` on the v2 exchanges. Like v1, but carries a `side` and single `tokenId` instead of the asset-id pair.

```json theme={null}
{
  "type": "orders_matched_v2",
  "takerOrderHash": "0x…",
  "takerOrderMaker": "0x…",
  "side": 0,
  "tokenId": "0x…",
  "makerAmountFilled": "0x…",
  "takerAmountFilled": "0x…"
}
```

| Field               | Solidity type   | Description                                   |
| ------------------- | --------------- | --------------------------------------------- |
| `type`              | string          | `orders_matched_v2`.                          |
| `takerOrderHash`    | `bytes32` (hex) | Hash of the taker order that drove the match. |
| `takerOrderMaker`   | `address` (hex) | Maker of the taker order.                     |
| `side`              | `uint8`         | `0` = buy, `1` = sell.                        |
| `tokenId`           | `uint256` (hex) | Outcome token matched.                        |
| `makerAmountFilled` | `uint256` (hex) | Total maker amount filled across the match.   |
| `takerAmountFilled` | `uint256` (hex) | Total taker amount filled across the match.   |

### `order_cancelled`

`OrderCancelled`. An order cancelled by its hash before it filled.

```json theme={null}
{ "type": "order_cancelled", "orderHash": "0x…" }
```

| Field       | Solidity type   | Description                  |
| ----------- | --------------- | ---------------------------- |
| `type`      | string          | `order_cancelled`.           |
| `orderHash` | `bytes32` (hex) | Hash of the cancelled order. |

### `order_preapproved`

`OrderPreapproved` (v2). An order preapproved for later execution, by its hash.

```json theme={null}
{ "type": "order_preapproved", "orderHash": "0x…" }
```

| Field       | Solidity type   | Description                    |
| ----------- | --------------- | ------------------------------ |
| `type`      | string          | `order_preapproved`.           |
| `orderHash` | `bytes32` (hex) | Hash of the preapproved order. |

### `order_preapproval_invalidated`

`OrderPreapprovalInvalidated` (v2). A preapproval revoked, by the order hash.

```json theme={null}
{ "type": "order_preapproval_invalidated", "orderHash": "0x…" }
```

| Field       | Solidity type   | Description                                          |
| ----------- | --------------- | ---------------------------------------------------- |
| `type`      | string          | `order_preapproval_invalidated`.                     |
| `orderHash` | `bytes32` (hex) | Hash of the order whose preapproval was invalidated. |

### `trading_paused`

`TradingPaused`. An operator paused trading on an exchange.

```json theme={null}
{ "type": "trading_paused", "pauser": "0x…" }
```

| Field    | Solidity type   | Description                  |
| -------- | --------------- | ---------------------------- |
| `type`   | string          | `trading_paused`.            |
| `pauser` | `address` (hex) | Address that paused trading. |

### `trading_unpaused`

`TradingUnpaused`. Trading resumed after a pause.

```json theme={null}
{ "type": "trading_unpaused", "pauser": "0x…" }
```

| Field    | Solidity type   | Description                   |
| -------- | --------------- | ----------------------------- |
| `type`   | string          | `trading_unpaused`.           |
| `pauser` | `address` (hex) | Address that resumed trading. |

## Pending feed

Set `confirmed: false` on your subscribe to get the pending feed of this channel — the same payload shape for pending exchange transactions, before they are in a block. Pending events are guesses. A transaction can be dropped, replaced, or reverted. See [Mempool](/websockets/mempool) for the full frame shape and how to handle it.

```json theme={null}
{
  "action": "subscribe",
  "id": "pending",
  "channel": "trading",
  "confirmed": false
}
```
