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.
The two ideas that shape everything else in the program are:
- 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 page.
- 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 page too.
- A maker’s funds live in one shared vault, not split up per market.
- A taker’s order is filled by the Matching Engine, 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, 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 give indexers and aggregators a single on-chain place to discover which Shard Books belong to which operator, for a given pair.
ordrpjZ3rA7sSq7tfGe3FPj5EbKrpwXXao8vHDKtkdg.
