Crypto glossary

Matching engine

Definition

A matching engine is the core exchange software that pairs incoming buy and sell orders, usually by price-time priority, and records the resulting trades.

Every order sent to an exchange reaches the matching engine. It keeps the order book in memory, checks whether a new order crosses with resting orders on the other side and, if so, executes trades at the resting orders' prices. Under price-time priority, the best price fills first and, among orders at the same price, the earliest one fills first. Some venues use pro-rata or other allocation rules.

Speed and reliability define the quality of a centralized exchange. Top crypto exchanges process large numbers of orders per second with very low latency, and outages during volatile markets, when the engine is overloaded, have repeatedly left traders unable to close positions. On-chain order book DEXs implement matching inside smart contracts or specialised chains, while AMMs replace matching entirely with pricing formulas.

Because users cannot inspect a centralized engine, they must trust that it applies its rules fairly. Allegations of preferential treatment, hidden fees or the operator trading against customers have featured in several exchange scandals.

Example

Two traders send limit orders to buy BTC at the same price a millisecond apart. When a seller arrives, the matching engine fills the earlier order first under price-time priority.

Related terms