> For the complete documentation index, see [llms.txt](https://docs.pretoke.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pretoke.xyz/smart-contracts/error-codes.md).

# Error Codes Reference

Consolidated reference for every on-chain error code across the protocol's contracts. Codes are namespaced by range to avoid collisions between contracts.

## ConditionRegistry (`RegistryErrors`)

| Code   | Name                       | Trigger Condition                                                                                                                        |
| ------ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| 100    | `NotOwner`                 | Sender is not the contract owner (reserved for admin operations)                                                                         |
| 0xFFFF | `InvalidMessage`           | Unrecognized op-code; `transfer_notification` sender is not the registered Jetton wallet; forward\_payload op is not `OP_SPLIT_POSITION` |
| 200    | `InvalidOutcomeCount`      | `outcomeSlotCount < 2` in PrepareCondition                                                                                               |
| 201    | `ConditionAlreadyExists`   | Attempting to prepare a condition with a `condition_id` that already exists in storage                                                   |
| 202    | `ConditionNotFound`        | Referenced `conditionId` does not exist (ReportPayouts, SplitPosition, MergePositions, RedeemPositions)                                  |
| 203    | `ConditionAlreadyResolved` | Reporting payouts for a condition whose `payoutDenominator` is already non-zero                                                          |
| 204    | `InvalidOracle`            | Reserved — oracle identity is validated implicitly via `condition_id` derivation from sender address                                     |
| 205    | `AllZeroPayouts`           | All payout numerator values sum to zero in ReportPayouts                                                                                 |
| 206    | `InvalidPartition`         | Partition validation fails: `partitionCount < 2`, an index set is 0, an index set >= `fullIndexSet`, or index sets overlap               |
| 207    | `InsufficientBalance`      | User's position balance is less than the requested split/merge amount                                                                    |
| 208    | `ConditionNotResolved`     | Redeeming positions from a condition with `payoutDenominator == 0`                                                                       |
| 209    | `InvalidIndexSet`          | In RedeemPositions: an index set is 0 or >= `fullIndexSet`                                                                               |
| 210    | `InsufficientGas`          | Message value is less than 0.1 TON (100,000,000 nanotons)                                                                                |

See [ConditionRegistry](/smart-contracts/condition-registry.md) for full context.

## LmsrMarketMaker (`MarketErrors`)

| Code   | Name                       | Trigger Condition                                                                                                                |
| ------ | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| 300    | `NotOwner`                 | Sender is not the contract owner (Pause, Resume, Close, ChangeFee, ChangeFunding, WithdrawFees)                                  |
| 301    | `MarketAlreadyInitialized` | InitMarket called when `stage != 255`                                                                                            |
| 302    | `ZeroFunding`              | InitMarket called with `amount == 0`                                                                                             |
| 303    | `MarketNotRunning`         | Trade or Pause attempted when `stage != 0`                                                                                       |
| 304    | `MarketNotPaused`          | Resume or ChangeFunding attempted when `stage != 1`                                                                              |
| 305    | `MarketClosed`             | Close, ChangeFee, or WithdrawFees attempted when `stage == 2`                                                                    |
| 306    | `InvalidTradeAmounts`      | Number of int64 values in `outcomeTokenAmounts` doesn't match `atomicOutcomeSlotCount`                                           |
| 307    | `CollateralLimitExceeded`  | Buy trade total cost exceeds the specified `collateralLimit`                                                                     |
| 308    | `InsufficientCollateral`   | Buy trade Jetton `amount` is less than the computed `totalCost`                                                                  |
| 309    | `ZeroFundingChange`        | ChangeFunding called with `fundingChange == 0`                                                                                   |
| 310    | `InsufficientGas`          | Message value is less than 0.2 TON (200,000,000 nanotons)                                                                        |
| 0xFFFF | `InvalidMessage`           | Unrecognized op-code; sender is not the configured Jetton wallet; forward\_payload op is neither `OP_INIT_MARKET` nor `OP_TRADE` |

See [LmsrMarketMaker](/smart-contracts/lmsr-market-maker.md) for full context.

## Fixed-Point Math Library

| Code | Trigger Condition                      | Function                 |
| ---- | -------------------------------------- | ------------------------ |
| 400  | Division by zero (`b == 0`)            | `fixed_div`              |
| 401  | Non-positive logarithm input (`x ≤ 0`) | `fixed_log2`, `fixed_ln` |
| 402  | Empty array (`count == 0`)             | `fixed_max`              |

See [Fixed-Point Math Library](/smart-contracts/fixed-point-math.md) for full context.

***

All contract-level errors surface to the platform's off-chain services as a failed transaction; the settlement service retries transient failures automatically (see [How Trades Settle On-Chain](/how-it-works/settlement-explained.md)) and logs permanent failures (e.g. insufficient balance, invalid partition) for investigation rather than blindly retrying them.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.pretoke.xyz/smart-contracts/error-codes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
