Centralized exchanges (CEX) still make up the vast majority of trading activity in the cryptocurrency markets. But what’s actually going on in the background?
We’ve collected the most fundamental building blocks that make up a centralized exchange that you need to know about before you start trading.
Matching engine
Also sometimes referred to as the order matching system, the matching engine is essentially the brain of the exchange. This system matches buy and sell orders with each other. In other words, it ensures that buyers and sellers can meet in the market and execute their trades.
Traditionally, on the stock markets and CEXs in crypto, this is done using a central server that belongs to the exchange. Ideally, this system should also ensure that whenever traders put on an order, they should get the best execution available in the given market. The internal systems of the exchange should also make sure that the assets are settled after a trade is executed, i.e., the balances of the buyer and seller are updated to reflect the new values.
A performant matching engine is key for an exchange’s robustness and efficiency. If it isn’t able to handle the required throughput, the market essentially falls apart. This can lead to large deficits in the system, many traders getting wrongly liquidated, or even trading being halted for prolonged periods.
When it comes to traditional markets, high-frequency trading firms are competing on sub-millisecond timescales. We’re talking about one-thousandth of a second. A small advantage for one firm over the others could mean billions of dollars of difference. The matching engine needs to be able to cater to this demand.
That being said, the cryptocurrency markets aren’t at this level of efficiency yet. Even so, just a few seconds of outage can lead to hundreds of millions of dollars of losses that otherwise wouldn’t happen. Latency and resolution are key, and matching engines need to keep up with a never-ending arms race for quicker execution.
As a side note, have you ever come across those old photos of traders shouting on the trading floor? That’s called the open outcry system, and it’s what was replaced by electronic matching engines starting from the 1980s.
Central limit order book (CLOB)
The central limit order book (CLOB) is a collection of the currently open orders on the exchange. The matching engine uses the order book to match orders, and this is the dominant way of facilitating electronic exchange.
Remember the public outcry system from above? An order book is quite similar in concept, but instead of shouting, you’re telling the order book your desired transaction details. For example, if you send a market order, you’re saying: “I’d like to buy or sell right now, give me the best execution price”.
The “top” of the order book is the lowest ask (sell order) and the highest bid (buy order), and that’s where buyers and sellers meet. The difference between the lowest ask and the highest bid is called the bid-ask spread. Naturally, the smaller this spread is, the more liquid and efficient the market may be, and the better execution you may get (though there are other factors).
As we’re only dealing with numbers, the order book is transparent, and openly available for everyone to see – though there are some exchanges that allow for hidden orders. There also exist special kinds of markets called dark pools that operate with hidden order books.
It’s worth noting that automated market makers (AMM) like Uniswap, Sushi, and PancakeSwap don’t use a CLOB. Instead, they use an algorithm to determine pricing.
Hot wallets and cold storage
Centralized exchanges have to hold and custody user funds. Users deposit their crypto to the exchange, and the exchange’s internal systems ensure that each individual user’s balance is correct. Naturally, this creates counterparty risk, as you have to trust the exchange not to lose your funds. It also creates a giant bullseye on the exchange, as their systems have to securely hold billions of dollars of their customers’ funds.
Most exchanges are quite secretive about how they store customer funds – and for good reason. Due to the significant risks involved, many of them also involve third-party custodians to minimize the chance of a loss of user funds. But generally, they tend to have funds separated into hot wallets and cold storage.
Hot wallets are typically a small portion of the entire capital pool, and they are used to ensure that there are funds available when a customer makes a withdrawal request. Cold storage funds are safely tucked away in separate wallets that can’t be accessed at all times, only when a customer wants to make a large withdrawal.
Even so, it’s crucial for you to use a safe email address, turn on two-factor authentication (2FA), and possibly use hardware authentication devices such as a YubiKey.
Fiat on-ramps and off-ramps
Not all CEXs offer this functionality, but the biggest ones tend to provide a way to move between crypto and the fiat world. You can use your debit card, connect your bank account, or use a peer-to-peer (P2P) marketplace to move funds between the two financial systems.
With the widespread adoption of stablecoins like USDC and USDT, dealing with the bridges between these two worlds is less of an issue than it used to be even just a few years ago. Back then, it was a challenge for a cryptocurrency exchange to obtain the necessary licenses to offer trading in fiat currencies. This is why one of the primary uses of stablecoins for exchanges was a form of regulatory arbitrage. Customers still wanted to have the option to park their assets denominated in fiat at times, and stablecoins were a great way to do that without the exchange having to deal with fiat money.
Now, however, the biggest CEXs all allow for ways to convert between fiat and crypto.
Liquidation engine
If we’re talking about an exchange that also offers margin trading or futures, there needs to be a robust system that handles liquidations. You see, liquidations are a difficult thing to deal with. If the matching engine isn’t able to handle everything that’s going on in a turbulent market, it can lead to large losses to many traders, but also, in the absolute worst case, could even bankrupt the entire exchange.
If the liquidation engine isn’t able to properly liquidate traders, there may be a huge deficit in the system, i.e., a negative balance. And someone has to pay for it! In some cases, this is the exchange itself, in others, it’s handled by socialized losses. This means that the most profitable traders get chipped away from their profits to cover the deficit in the system. This used to happen in the cryptocurrency space more than you might think, and it shows why a robust liquidation system is crucial for an exchange’s good performance.
Market makers
So far, we’ve talked about the infrastructure components of a CEX. While these are all required to kickstart an exchange business, there’s a crucial element that’s also needed – liquidity.
You see, you can build the greatest technology, but if liquidity is low, you won’t attract many traders. Many newly launched exchanges fall into this death spiral of sorts. No one trades on their exchange, because.. no one trades on their exchange.
It’s crucial for CEXs to make good connections with market making firms that provide liquidity to their books. As a result, it’s quite common to see exchanges offering fee discounts for market makers.
But what exactly is a market maker? It’s a firm (or an individual) that specializes in quoting prices for both the buy and the sell side, hoping to make a profit on the bid-ask spread. In other words, the market maker is willing to buy and sell large amounts of the asset at the same time, effectively making the order books more liquid for traders.
Market making strategies can be quite complex and are usually safely kept under wraps. It’s a highly competitive industry. The bottom line, is though, that the exchange benefits from the liquidity market makers provide, and they make a profit through applying their strategy to the market.
So, these are some of the basic components of an exchange. There can be others including margin systems, borrow-lending, integrations with DeFi, but these are the core concepts you need to understand.