# GTO Mechanics

The limit order book is restricted to 100 bids and 100 asks. This fixed size data set enables fast, efficient trading on blockchain networks. However it also adds an attack vector where malicious actors could manipulate their orders to try and gain an advantage in the orderbook.

To mitigate this risk the contract algorithm optimizes for both price and volume.

<figure><img src="/files/VFOO65Jf2w3UPhZYGEWQ" alt=""><figcaption></figcaption></figure>

> Traders want the most volume possible at the most competitive price to reduce slippage.&#x20;

In traditional exchanges orders at the same price will get filled on a first in first out basis. However this is not optimal in an environment where we want to incentivize high volume orders for better liquidity.

ODEX prioritizes fills based on price first and volume second. If two bids are equal at the same price tick the bid with the highest volume will get filled first. Likewise orders which are far away from competitive pricing and for low volumes are cleared first to make way for more competitive incoming orders.

```
function highestBid() public view returns (uint, uint, address, uint) {
    uint index;
    for (uint i = 0; i < bids.length; i++)
        if (bids[i].price != 0 && (bids[i].price > bids[index].price || 
            bids[i].price == bids[index].price && bids[i].amount > bids[index].amount)) index = i;
    return (bids[index].amount, bids[index].price, bids[index].trader, index);
}
```

This creates a dynamic fixed size orderbook which is game theory optimal to incentivize competitive pricing and high volume orders.


---

# 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://odexfi.gitbook.io/docs/overview/gto-mechanics.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.
