# Match Limits

Matching is executed price-level by price-level in **O(1) gas**. Takers consume up to their remaining size at each level and stop once they are filled or when their slippage guard trips.

## Why There Is No Match Limit

* **Level batching** – `_matchAtPriceLevel` flushes all maker volume stored in `PriceLevelData` in one step, regardless of how many individual orders are resting at that price.
* **Deterministic gas** – each additional price level adds a predictable cost. There is no per-maker loop, so a surge of tiny orders at the same price cannot grief takers.
* **Simplified UX** – the execution levers are `ExecutionType` (`Standard`, `IOC`, `FOK`) and the price/amount bounds the taker sets.

## Interface Compatibility

* `createBuyOrder` / `createSellOrder` do not take any match-limit parameter, and `IOrderBook.OrderParams` omits that field.
* There is no `MatchLimitReached` event. Downstream systems should monitor `OrderReduced`, `OrderCancelled`, and taker execution events instead.

SDKs should not pass any match-limit argument; the call will revert if extra parameters are supplied.

## Current Gas-Safety Recommendations

1. **Choose the right execution type** – use `ExecutionType.IOC` when takers must avoid resting remainders, or `ExecutionType.FOK` when partial fills are unacceptable.
2. **Sanity-check limit prices** – even though per-level costs are flat, walking thousands of price levels can still burn gas. Keep reasonable price caps/floors in place.
3. **Simulate before submitting** – `previewTakerOrder` provides the exact levels touched and quote usage for a hypothetical trade. Front-ends should call it to surface worst-case depth.
4. **Cap off-chain loops** – indexers or bots that scan the book should continue to guard against pathological depth.

The result is a simpler runtime that honours familiar execution semantics without extra match-limit toggles.


---

# Agent Instructions: 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:

```
GET https://dbookio.gitbook.io/dbook/technical-documentation/orderbook-contract/match-limits.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
