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

# lifecycle

> Market creation and preparation events from the Polymarket NegRisk adapter, CTF base layer, module, and exchange contracts.

The `lifecycle` channel sends every market setup and preparation event: markets, events, conditions, questions, tokens, and combinatorial conditions being made ready to trade. They come from the NegRisk adapter, the CTF base layer, the module contracts, and the exchange contracts. We decode each one and send it after the transaction is confirmed on-chain.

<Note>
  Settlement events (resolutions, reported outcomes, pauses) moved to the
  [`resolution`](/websockets/channels/resolution) channel. This channel is now
  setup and preparation only.
</Note>

## Subscribe

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

With no filters, you get every confirmed lifecycle event from all markets.

## Filters

| Filter       | Type       | Required | Description                                                          |
| ------------ | ---------- | -------- | -------------------------------------------------------------------- |
| `market_ids` | `string[]` | No       | Condition/market IDs as hex strings. Keeps events for those markets. |
| `token_ids`  | `string[]` | No       | Token IDs as decimal strings. Keeps events for the listed tokens.    |

`market_ids` and `token_ids` are one axis. `wallets` and `min_usd` are ignored here. See [Filters](/websockets/filters) for the combination rule.

## Events

This channel sends all seven market and condition preparation events. See [Onchain Data](/concepts/onchain-data) for the part each event plays in the market lifecycle.

| Event                            | `data.type`                        | Description                                                                                                        |
| -------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `MarketPrepared`                 | `market_prepared`                  | A NegRisk market set up. Links a market id to its oracle, fee bips, and setup data.                                |
| `EventPrepared`                  | `event_prepared`                   | A new event set up in a BinaryModule or NegRiskModule. Carries the event id, condition count, and legacy event id. |
| `ConditionPreparation`           | `condition_preparation`            | A new CTF condition set up. Links the condition id to its oracle, question id, and outcome slot count.             |
| `TokenRegistered`                | `token_registered`                 | An exchange token pair registered. Maps token0 and token1 to a condition id, which links fills to markets.         |
| `NegRiskQuestionPrepared`        | `neg_risk_question_prepared`       | A NegRisk question set up in a market. Links a question to its market id and index.                                |
| `CombinatorialConditionPrepared` | `combinatorial_condition_prepared` | A new combinatorial condition set up. Carries the condition id and the leg position id array.                      |
| `MigrationConditionRegistered`   | `migration_condition_registered`   | A condition registered for migration. Maps a v2 condition id to its legacy condition id.                           |

## 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": "lifecycle",
  "confirmed": true,
  "data": {
    "type": "condition_preparation",
    "conditionId": "0x…",
    "oracle": "0x…",
    "…": "…"
  }
}
```

### `market_prepared`

`MarketPrepared` on the NegRiskAdapter. A neg-risk market set up, linked to its oracle, fee, and raw setup data.

```json theme={null}
{
  "type": "market_prepared",
  "marketId": "0x…",
  "oracle": "0x…",
  "feeBips": "0x…",
  "data": "0x…"
}
```

| Field      | Solidity type   | Description                                       |
| ---------- | --------------- | ------------------------------------------------- |
| `type`     | string          | `market_prepared`.                                |
| `marketId` | `bytes32` (hex) | Neg-risk market id being prepared.                |
| `oracle`   | `address` (hex) | Oracle that will report outcomes for this market. |
| `feeBips`  | `uint256` (hex) | Market fee in basis points.                       |
| `data`     | `bytes` (hex)   | Raw setup data passed at market creation.         |

### `event_prepared`

`EventPrepared` on the BinaryModule / NegRiskModule. A new event scaffold, with its condition count and legacy id.

```json theme={null}
{
  "type": "event_prepared",
  "eventId": "0x…",
  "conditionCount": "0x…",
  "legacyEventId": "0x…"
}
```

| Field            | Solidity type   | Description                         |
| ---------------- | --------------- | ----------------------------------- |
| `type`           | string          | `event_prepared`.                   |
| `eventId`        | `bytes29` (hex) | Module event id being prepared.     |
| `conditionCount` | `uint256` (hex) | Number of conditions in the event.  |
| `legacyEventId`  | `bytes32` (hex) | Matching id from the legacy system. |

### `condition_preparation`

`ConditionPreparation` on ConditionalTokens. A new CTF condition registered with its oracle, question, and outcome slot count.

```json theme={null}
{
  "type": "condition_preparation",
  "conditionId": "0x…",
  "oracle": "0x…",
  "questionId": "0x…",
  "outcomeSlotCount": "0x2"
}
```

| Field              | Solidity type   | Description                                               |
| ------------------ | --------------- | --------------------------------------------------------- |
| `type`             | string          | `condition_preparation`.                                  |
| `conditionId`      | `bytes32` (hex) | Condition id being set up.                                |
| `oracle`           | `address` (hex) | Oracle that will report the outcome.                      |
| `questionId`       | `bytes32` (hex) | Question id linked to this condition.                     |
| `outcomeSlotCount` | `uint256` (hex) | Number of outcome slots (for example `"0x2"` for binary). |

### `token_registered`

`TokenRegistered` on the exchange. Maps the two outcome-token ids to a condition id, which is how fills link back to a market.

```json theme={null}
{
  "type": "token_registered",
  "token0": "0x…",
  "token1": "0x…",
  "conditionId": "0x…"
}
```

| Field         | Solidity type   | Description                      |
| ------------- | --------------- | -------------------------------- |
| `type`        | string          | `token_registered`.              |
| `token0`      | `uint256` (hex) | First outcome-token id.          |
| `token1`      | `uint256` (hex) | Second outcome-token id.         |
| `conditionId` | `bytes32` (hex) | Condition both tokens belong to. |

### `neg_risk_question_prepared`

`QuestionPrepared` on the NegRiskAdapter. A question added to a neg-risk market, with its index and raw setup data.

```json theme={null}
{
  "type": "neg_risk_question_prepared",
  "marketId": "0x…",
  "questionId": "0x…",
  "index": "0x…",
  "data": "0x…"
}
```

| Field        | Solidity type   | Description                                 |
| ------------ | --------------- | ------------------------------------------- |
| `type`       | string          | `neg_risk_question_prepared`.               |
| `marketId`   | `bytes32` (hex) | Neg-risk market the question belongs to.    |
| `questionId` | `bytes32` (hex) | Question id being prepared.                 |
| `index`      | `uint256` (hex) | Question index within the market.           |
| `data`       | `bytes` (hex)   | Raw setup data passed at question creation. |

### `combinatorial_condition_prepared`

`CombinatorialConditionPrepared` on the combinatorial module. A combinatorial condition set up over a set of leg position ids.

```json theme={null}
{
  "type": "combinatorial_condition_prepared",
  "conditionId": "0x…",
  "legs": ["0x…", "0x…"]
}
```

| Field         | Solidity type     | Description                                     |
| ------------- | ----------------- | ----------------------------------------------- |
| `type`        | string            | `combinatorial_condition_prepared`.             |
| `conditionId` | `bytes31` (hex)   | Combinatorial condition id being set up.        |
| `legs`        | `uint256[]` (hex) | Position ids that make up the condition's legs. |

### `migration_condition_registered`

`MigrationConditionRegistered` on a module. Maps a v2 condition id to its legacy condition id so positions can migrate.

```json theme={null}
{
  "type": "migration_condition_registered",
  "v2ConditionId": "0x…",
  "legacyConditionId": "0x…"
}
```

| Field               | Solidity type   | Description                       |
| ------------------- | --------------- | --------------------------------- |
| `type`              | string          | `migration_condition_registered`. |
| `v2ConditionId`     | `bytes31` (hex) | Condition id in the v2 system.    |
| `legacyConditionId` | `bytes32` (hex) | Matching id in the legacy system. |

## Pending feed

Set `confirmed: false` on your subscribe to get the pending feed of this channel — the same payload shape for pending transactions sent to the NegRisk adapter, CTF, module, and exchange contracts, 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": "lifecycle",
  "confirmed": false
}
```
