Users of cryptocurrency exchanges require confidence that the exchange is fair, accurate, and solvent. In order to operate effectively, an exchange must meet two key requirements. Firstly, the exchange’s price should eventually become identical to the market price of the asset, as determined by an external market. This process is known as price discovery and ensures that the exchange’s price is fair and accurately reflects the market value of the asset.
Secondly, the exchange must not become insolvent at any point in time. This requirement is known as the “no credit” requirement in financial markets, which means that the exchange should not allow Liquidity Providers (LPs) to take credit. In other words, the exchange must ensure that it has sufficient funds to ute trades and that it does not rely on borrowing to cover any shortfalls.
One type of exchange mechanism used in financial markets is a Limit Order Book (LOB), where market participants submit orders to buy or sell security at a specified price. LOBs have been used for decades in traditional financial markets and have become the dominant method of trading cryptocurrencies on centralised exchanges.
LOBs are a type of exchange mechanism used in financial markets to match buyers and sellers of securities. LOBs were first introduced in the 1970s and have since become the dominant method of trading in many financial markets.
According to a 2019 report by the Bank for International Settlements (BIS), LOBs account for the majority of trading volume in most major currency pairs. For example, LOBs account for around 75-80% of the trading volume in the euro-dollar and dollar-yen currency pairs. According to data from CryptoCompare, LOBs accounted for around 90% of trading volume on centralised exchanges during the bull market in 2021.
In a LOB, market participants submit orders to buy or sell a security at a specified price. These orders are recorded and organised by price and time in the LOB. When a buy order matches a sell order at a given price, a trade is uted and the order is removed from the LOB.
LOBs are widely used in centralised exchanges, such as the New York Stock Exchange and NASDAQ. In the cryptocurrency space, LOBs have become the dominant method of trading cryptocurrencies, with some of the most popular cryptocurrency exchanges, such as Gate.io and Coinbase, using LOBs to match buyers and sellers of cryptocurrencies.
LOBs use mathematical formulas to match orders and ute trades. The mathematical formula used by LOBs is essentially an equation that defines the relationship between the quantity of an asset that a buyer or seller is willing to trade and the price they are willing to pay or receive. This formula is used to determine the priority of each order in the LOB, and to match orders when there is overlap between buy and sell orders.
Here are a few examples of formulas that can be used in limit order books (LOBs):
Time priority formula:
In this formula, the priority of an order in the LOB is based on the time it was placed. The formula can be written as:
Priority = Time of Order Placement
This formula prioritises orders based on their time of entry, with earlier orders being uted first. This is a simple formula that is commonly used in LOBs.
Price-time priority formula:
In this formula, the priority of an order is based on both its price and time of placement. The formula can be written as:
Priority = Price of Order + (Time of Order Placement x Constant)
The constant in the formula is used to adjust the weight given to time relative to price. This formula prioritises orders based on both price and time, with higher-priced orders and earlier-placed orders being uted first.
Volume priority formula:
In this formula, the priority of an order is based on its volume (i.e., the quantity of assets being bought or sold). The formula can be written as:
Priority = Volume of Order
This formula prioritises larger orders over smaller ones, with orders of greater volume being uted first.
The choice of formula used in a Limit Order Book (LOB) can depend on a variety of factors, such as the type of asset being traded, the needs of the market participants, and the specific implementation of the LOB.
That being said, Time Priority and Price-Time Priority formulas are among the most commonly used in traditional financial markets. Time Priority is a simple and intuitive formula that prioritises orders based on their time of entry, while Price-Time Priority takes both price and time into account, allowing for a more nuanced approach to matching orders.
These are just a few examples of the types of formulas that can be used in LOBs. The specific formula used can vary depending on the exchange and the assets being traded, and can be customised to meet the needs of the market participants.
However, LOBs face challenges when implemented in decentralised environments, such as the Ethereum blockchain, due to storage and computation limitations. These limitations can make it prohibitively expensive to implement a LOB, and can result in liquidity problems in thin markets.
In finance, a thin market is a market where there are relatively few buyers and sellers for a particular asset. Thin markets can have less liquidity than more active markets, which can make it more difficult for buyers and sellers to find a counterparty to trade with, and can result in wider bid-ask spreads (i.e., the difference between the highest price a buyer is willing to pay for an asset and the lowest price a seller is willing to accept).
In the context of cryptocurrency trading, thin markets can be a particular challenge for Limit Order Books (LOBs), which rely on a sufficient number of buyers and sellers to create a liquid market. In thin markets, LOBs can face liquidity problems, which can result in slower ution times and wider bid-ask spreads. This has led to the development of alternative exchange mechanisms, such as Automated Market Makers (AMMs), that can provide guaranteed liquidity even in thin markets.
AMMs use mathematical formulas to provide guaranteed liquidity to traders, and are less expensive to use than LOBs.
The most well-known and widely-used AMM is Uniswap, which uses a Constant Function Market Maker (CFMM) to match trades. In a CFMM, liquidity providers (LPs) deposit two different assets into a pool, and the price of the assets is determined by a simple formula (such as x * y = k). When a trader wants to swap one asset for another, they do so at the price determined by the formula.
Despite the challenges faced by LOBs in decentralised environments, some decentralised exchanges (DEXes) still use LOBs. For example, some DEXs use a hybrid model that combines LOBs with off-chain matching to provide fast and efficient trading while minimising gas fees on the Ethereum network.
Overall, LOBs and AMMs are both important exchange mechanisms used in traditional and decentralised financial markets. While LOBs are best-suited for centralised environments, they face challenges when implemented in decentralised environments. AMMs, on the other hand, offer guaranteed liquidity and are less expensive to use than LOBs, making them a popular alternative in decentralised environments. As the cryptocurrency market continues to evolve, it will be interesting to see how LOBs and AMMs continue to be used and adapted to meet the needs of traders and investors.
Disclosure: This article was written in partnership with DWF Labs, a market maker and Gate.io institutional client. For more information on DWF Labs, visit www.dwf-labs.com