Matching Algorithm
The order book uses a ladder matching algorithm that ensures the taker receives the best execution. This is different from single-price-per-trade matching algorithms that are employed elsewhere. Order matching is atomic (in the same blockchain transaction as the incoming taker order): the orderbook will never have overlapping orders from two sides. Orders in the book at the same price are sorted by time priority, the earliest orders at the same price are matched first.
For example: The book contains two buy orders, one at $100, quantity 2, another at $101, quantity 3. A sell order comes in that’s priced at $99, quantity 4. Two trades are created: one trade at $101, quantity 3, and another at $100, quantity 1.
If the exchange did not implement this algorithm, a secondary smart contract could break incoming orders atomically and automatically, as the order book is fully lit. To prevent flow re-routing and provide the same outcome for all users, the exchange must therefore implement this algorithm.
Last updated
Was this helpful?

