> For the complete documentation index, see [llms.txt](https://haiko-docs.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://haiko-docs.gitbook.io/docs/protocol/amm/execution-and-order-matching.md).

# Execution & Order Matching

At its core, Haiko's AMM protocol is a matching engine between two groups of users: traders and liquidity providers.&#x20;

It routes incoming swaps from traders to the best source of liquidity, searching across all liquidity positions and limit orders, and settles trades by transferring token balances between buyers and sellers.

Incoming swaps consume or dispense liquidity by changing the mix of base and quote tokens deposited in a market. thereby affecting the market price. You can learn more about the precise relationship between liquidity, token balances, and market prices in [Liquidity Math](/docs/developers/advanced-concepts/liquidity-math.md).

## Positions & Orders

To facilitate efficient matching, prices in Haiko are partitioned into price intervals called limits. Limits define valid price points at which liquidity positions and limit orders can be placed.

Limits work in the same way as Uniswap's [ticks](https://docs.uniswap.org/concepts/protocol/concentrated-liquidity#ticks), except they have a minimum increment of `1.00001` (rather than `1.0001`) to allow for more precise price points.&#x20;

You can learn more about different Position Types [here](/docs/protocol/amm/position-types.md).

## Swap Execution

Swaps are executed using a matching algorithm based on a tree data structure, optimising execution efficiency against storage rewrite costs.&#x20;


---

# 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://haiko-docs.gitbook.io/docs/protocol/amm/execution-and-order-matching.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.
