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

# Order Lifecycle

> Understand the complete order flow from creation and submission through matching and on-chain settlement, including order and trade states.

The Event Contracts CLOB uses a hybrid model: order matching happens off-chain for efficiency, while final asset delivery is executed on-chain. This page explains the complete lifecycle from order creation through settlement.

![Image](https://mintcdn.com/dexbuilder/HmQKrNhFx36mwspk/images/image-4.png?fit=max\&auto=format\&n=HmQKrNhFx36mwspk\&q=85\&s=6064e7ab0bef5d73b0e77485638f2c13)

## How Orders Work

At the protocol level, all CLOB orders can be treated as limit orders. What is commonly called a "market order" is effectively a sufficiently aggressive limit order that immediately crosses the order book.

Matching follows price priority, then time priority: better prices execute first, and at the same price, earlier orders execute first.

## Time-in-Force Options

Use these values in `order_type`. Set `order_mode` to `LIMIT` or `MARKET`.

| Type | Behavior | Typical Use |
| - | - | - |
| `GTC` | Good-Til-Cancelled; remains active until filled or manually cancelled | Resting orders, market making |
| `GTD` | Good-Til-Date; expires automatically at the specified time | Time-limited quotes |
| `FOK` | Fill-Or-Kill; must fill completely immediately or be fully cancelled | All-or-nothing execution |
| `FAK` | Fill-And-Kill; immediately fills what is available and cancels the rest | Fast liquidity taking |

### Post Only

A Post Only order is guaranteed to act only as a Maker. If it would immediately execute against an existing order when submitted, it is rejected rather than consuming liquidity.

## Full Lifecycle

**1. Create and Sign**

Construct the order parameters, including Token ID, side (`BUY` / `SELL`), price, quantity, expiration time, and timestamp, then sign the order with the trading wallet.

**2. Submit to the CLOB**

The CLOB verifies the signature, balance, and allowance, and validates trading rules such as tick size and minimum order size. Invalid orders do not enter the order book.

**3. Match or Rest on the Order Book**

Orders that can execute immediately are matched against existing liquidity. Orders that cannot execute immediately remain on the order book until filled, cancelled, or expired. Some markets may apply a Taker matching delay to protect Makers.

**4. Settle On-Chain**

After matching, the settlement contract validates the orders and atomically transfers outcome tokens and USDT.

**5. Confirm Completion**

After the on-chain transaction is confirmed, account balances, trade records, and positions are updated.

## REST Order States

REST order queries and the `status` filter use the following lowercase values. WebSocket order updates use a separate uppercase UI state.

| State | Meaning |
| - | - |
| `processing` | The order request is being processed, including cancellation in progress |
| `open` | The order is open, including partially filled orders with a remaining quantity |
| `matched` | The order has matched |
| `canceled` | The order was canceled or expired |
| `failed` | The order failed or was rejected |

## Trade States

| State | Meaning | Final State |
| - | - | - |
| `MATCHED` | Off-chain matching confirmed; awaiting on-chain settlement | No |
| `MINED` | Settlement transaction has been mined | No |
| `CONFIRMED` | Settlement is final and balances are updated | Yes |
| `RETRYING` | On-chain submission failed and the system is retrying | No |
| `FAILED` | Settlement ultimately failed | Yes |

## Maker and Taker

| Role | Description |
| - | - |
| Maker | Places resting orders and provides liquidity |
| Taker | Crosses the order book and consumes existing liquidity |

A Taker's actual execution price is the resting counterparty price on the order book. For example, if a buy order has a limit of `$0.55` and matches a sell order at `$0.52`, the execution price is `$0.52`.

## Cancelling Orders

Unfilled orders can usually be cancelled. Any portion that has already matched cannot be reversed; even if the remaining quantity is cancelled, the matched portion continues through settlement.

## Order Requirements

| Requirement | Description |
| - | - |
| Balance | Buying requires sufficient USDT; selling requires sufficient outcome tokens |
| Allowance | The relevant contract must be authorized to transfer the asset |
| API credentials | Private trading endpoints require valid authentication credentials |

The maximum size available for a new order must subtract the balance already reserved by existing open orders:

```text theme={null}
maxOrderSize = balance − ∑(openOrderSize − filledAmount)
```

## Next Steps

> [card] [Market Resolution](https://dexbuilder.mintlify.site/en/event-contracts/resolution.md)
>
> Learn how markets determine outcomes and how winning Tokens are redeemed.

> [card] [Place Orders](https://dexbuilder.mintlify.site/en/event-contracts/place-orders.md)
>
> View the trading API and order-placement flow.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.