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

# Architecture overview

> How ordr.trade's on-chain program is put together

ordr.trade is a single Solana program written in [Pinocchio](https://github.com/anza-xyz/pinocchio), a
lightweight framework with almost no overhead. Several of its hottest
instructions, the ones a market maker calls most often while quoting, such as
`update_mid`, are hand written in low level assembly instead of normal Rust,
so they cost as little computing power as possible.

The program is built around five pieces of on-chain state.

| Account | Belongs to | What it holds |
| - | - | - |
| **Market** | One maker, one trading pair | The maker's mid price, tick size, lot size, and a sequence number, plus the addresses of that maker's own bid and ask books |
| **Bid / Ask slab** | One maker, one side of one market | The maker's resting orders on that side, stored as a sorted tree |
| **Vault** | One maker | The token accounts that back every market that maker runs, across every pair |
| **Market registry** | One operator, one trading pair | An optional list of which Shard Books that operator wants aggregators to find |

The two ideas that shape everything else in the program are:

1. **Every maker runs their own Shard Book.** There is no single shared order
   book that every market maker writes to. A maker's market account, and the
   bid and ask books that go with it, belong only to that maker. This is
   explained in full on the [Shard Books](https://docs.ordr.trade/architecture/shard-books.md) page.
2. **Orders are priced as an offset from a mid price, not as an absolute
   price.** Moving the mid moves every resting order at once, in a single
   cheap instruction. This is explained on the [Shard Books](https://docs.ordr.trade/architecture/shard-books.md)
   page too.

From there:

* A maker's funds live in one shared [vault](https://docs.ordr.trade/architecture/vault.md), not split
  up per market.
* A taker's order is filled by the [Matching Engine](https://docs.ordr.trade/architecture/matching-engine.md),
  which can settle against several Shard Books in a single instruction and
  includes two protections against toxic flow.
* Every price update carries a [sequence number](https://docs.ordr.trade/architecture/sequencing-and-ace.md),
  and lands with help from Jito's ACE, so a maker's reprice can never be
  rolled back by a late or replayed transaction.
* [Market registries](https://docs.ordr.trade/architecture/market-registries.md) give indexers and
  aggregators a single on-chain place to discover which Shard Books belong to
  which operator, for a given pair.

The program is deployed at
[`ordrpjZ3rA7sSq7tfGe3FPj5EbKrpwXXao8vHDKtkdg`](https://solscan.io/account/ordrpjZ3rA7sSq7tfGe3FPj5EbKrpwXXao8vHDKtkdg).


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