# Matching Engines

<figure><img src="https://2957186996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIoU8ZN5MuT4QwECWHCYJ%2Fuploads%2F4CYANlHD4OAgzjhP8NNq%2F30.png?alt=media&#x26;token=d8ed3647-198f-497d-94ad-f8c7ca6cba8d" alt=""><figcaption></figcaption></figure>

Matching engines are one of the most important pieces of any exchange. They’re the behind-the-scenes system that takes your buy or sell order and makes sure it actually finds a match.

All this magic is handled by the core infrastructure powering every exchange.

### **What Is a Matching Engine?**

A matching engine is the brain of an exchange, a system that pairs buyers and sellers. Think of it as your personal shopper, but digital, fast, and impartial.

Its role on the exchange? Scan the order book, find compatible orders, and execute trades in real time. It does this constantly, even when thousands of orders are entering the pipeline every second.

### **How It Works**

Imagine a live auction with buyers and sellers shouting prices. Now replace that chaos with code. On an exchange, every buy or sell order goes into an order book. The matching engine watches this book 24/7 and instantly connects overlapping orders.

Example:

* A buyer places a bid for ETH at $2,000
* A seller is offering ETH at $2,000
* The engine says “deal,” connects the orders, and the trade happens

Simple on the surface, but there’s a lot happeningh under the hood.

### **Matching Rules**

Not all trades are treated equally. Matching engines follow specific rules (called algorithms) to decide **which** orders get filled first when there are multiple buyers or sellers.

Here are a few common ones:

#### **First-In, First-Out (FIFO)**

Also known as “first come, first served.” If two traders place the same order at the same price, the one who placed it earlier gets filled first. It’s the most widely used and considered the fairest.

#### **Pro-Rata**

This one gives priority based on order size. If multiple traders want to fill the same price level, those with larger orders get a bigger share.

#### **Time-Weighted Average Price (TWAP)**

TWAP breaks a large order into smaller ones and executes them over time. This smooths out market impact and helps get a better average price. It’s often used by institutions or bots.

### **Why Matching Engines Matter**

<figure><img src="https://2957186996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIoU8ZN5MuT4QwECWHCYJ%2Fuploads%2FJmPkRs0SoiavugtWJ7JW%2F34.png?alt=media&#x26;token=3f2aa248-420f-4088-bc45-297d80582be1" alt=""><figcaption></figcaption></figure>

They’re the silent MVPs behind every successful trade. Here’s why they’re critical:

* **Speed:** High-frequency traders operate in milliseconds. A fast engine prevents delays and slippage.
* **Fairness:** Clear matching rules (like FIFO) create a level playing field.
* **Liquidity:** Matching engines keep markets fluid by constantly pairing buyers and sellers. Without them, trading would stall.

### **Final Thoughts**

You might not see it, but the matching engine is always working behind the scenes, scanning orders, pairing trades, and keeping the market alive — a key feature every trader should consider when choosing where to trade.

**About Kuma**

Kuma is a double-down bet on what works for decentralized trading: speed, security, and transparency. From the team behind the No.1 DEX from 2017-2019, and powered by Berachain’s Proof-of-Liquidity, Kuma delivers one-click onboarding, seamless mobile trading via Kuma Connect, and gas-free settlement. Traders of all sizes have an edge thanks to millisecond execution and complete control of their funds.

🌎 [Website](https://kuma.bid/)

📣 [Discord](http://discord.gg/kumadotbid)

🐦 [Twitter](https://x.com/kumadotbid)

💬 [Telegram](https://t.me/kumadotbid)
