> 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/how-it-works/orderbook-vs-amm.md).

# Order Book vs. Automated Market Maker

PreToke prices trades using two complementary mechanisms. Understanding both helps explain why your market orders sometimes fill at slightly different prices than the last displayed quote.

## The Order Book (CLOB)

This works exactly like a traditional exchange: traders place **limit orders** — "I'll buy 100 YES shares at $0.55" or "I'll sell 50 NO shares at $0.40" — and the order book matches compatible buy and sell orders directly against each other, peer to peer.

Three ways two orders can match:

* **Normal match** — a BUY and a SELL on the *same* outcome cross. A straightforward transfer of an existing outcome-token position from seller to buyer.
* **Mint match** — a BUY on YES and a BUY on NO cross (their prices sum to $1.00 or more). Rather than one side "selling" to the other, the platform creates ("mints") a brand-new complete set of YES+NO tokens straight from collateral and hands one side to each buyer. This is only possible because a complete set of YES+NO is, by definition, worth exactly $1 — so two buyers whose combined price meets or exceeds $1 can always be satisfied this way.
* **Merge match** — the mirror image: a SELL on YES and a SELL on NO cross (their prices sum to $1.00 or less). Their combined tokens are merged back into collateral and the proceeds are split between them.

## The Automated Market Maker (AMM)

Not every market has enough resting orders to fill your trade instantly at a fair price — especially for newer or lower-volume markets. To guarantee you can always trade, the platform also runs an **automated market maker** based on the **Logarithmic Market Scoring Rule (LMSR)**, a well-established pricing model used by prediction markets for over a decade.

In plain terms: the AMM always has a price to quote, funded by a pool of collateral (the "funding" or liquidity parameter). The more you buy of one outcome, the more its price rises; the more you sell, the more it falls — this is what keeps the AMM's prices responsive to demand even without a matching counterparty.

## How your order picks between them

When you place a **market order**, the platform automatically compares what price the order book can offer versus what the AMM can offer, and routes your order (or splits it) to get you the best overall blended price — you don't have to choose between the two yourself. This routing shows up in your trade confirmation as the trade's **venue**: `CLOB` (order book only), `AMM` (market maker only), or `HYBRID` (a bit of both).

**Limit orders**, by contrast, always go to the order book — that's what lets you name your own price and wait for it.

For the exact math behind the AMM's pricing (the LMSR cost function), see the [LmsrMarketMaker contract reference](/smart-contracts/lmsr-market-maker.md).


---

# 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/how-it-works/orderbook-vs-amm.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.
