![Orderbook vs AMMs | Waffle Capital](/blogPictures/004-orderbook-vs-amm/Orderbook vs AMM Article.png)
The Role of Exchanges
An exchange is a marketplace where securities, commodities, derivatives, and other financial instruments are traded. Beyond facilitating trade, exchanges also play a crucial role in determining price movements and helping companies raise capital. This is enabled through liquidity. To understand liquidity, envision trying to sell lemonade in a small town on an empty street versus at a bustling city fair. The more people around, the easier it is to sell the lemonade at the desired price. Similarly, for any asset or financial instrument, the more liquidity, the better the trading experience.
Centralized vs. Decentralized Exchanges
Centralized Cryptocurrency Exchanges (CEXs) operate on a traditional model; they hold custody of user funds, match buy and sell orders, and facilitate the exchange of assets. Some benefits of CEXs include their user-friendliness, high liquidity, variety of trading pairs, and vehicles to move between crypto and fiat. However, these come at enormous costs: centralized control and no direct (private key) access to your funds ("Not your keys, not your crypto"). In response, Decentralized Cryptocurrency Exchanges (DEXs) have emerged, operating without a central authority and allowing users to trade directly with each other through smart contracts. Various models of exchanges, both centralized and decentralized, are discussed below.
The Orderbook Model
Orderbook exchanges are veterans of traditional finance (TradFi), having been battle-tested for decades. They operate like an auction house, where buyers place orders at every price they are willing to buy at, and the order book exchange does the same for sellers. Eventually, some of these buy and sell orders will match up at the same price, and that’s where trades happen.
![Orderbook Model | Waffle Capital](/blogPictures/004-orderbook-vs-amm/Orderbook vs AMM Article 2.png)
Example of an orderbook | source:FreeCodeCamp
In addition to organic buyers and sellers placing their orders at various prices, centralized market-makers fill the order book with more orders that reflect live market conditions. The impact of this boost in liquidity from centralized players makes it easier for users of the exchange to find their desired prices. In return for boosting liquidity, these market-makers earn a small portion of fees from each trade and often also take a fee from the exchange.
The benefits of the orderbook model are multifold and applicable to both TradFi and Decentralized Finance (DeFi). Firstly, it provides unmatched transparency as everyone can view all buy and sell orders at all times. Additionally, it excels in efficient price discovery, aggregating all real-time supply and demand to reflect the ‘true market price’. Moreover, the model can easily be scaled to accommodate additional financial products such as derivatives, enabling a thriving financial ecosystem. Lastly, the orderbook's structured format is ideal for automation, seamlessly integrating with various trading algorithms and systems to facilitate sophisticated strategies.
The million ADA question then is, why didn’t DEXs directly replicate this model on-chain? To answer, let’s follow the route that was taken instead.
The Automated Market Maker (AMM) DEX
The AMM model is at the forefront of DeFi, having introduced one of the first mechanisms for individuals to trade assets in a decentralized way. Uniswap was the pioneer of the model, having launched on Ethereum in 2018 and introducing concepts such as pooled liquidity and pricing using the constant product model.
Reverting to the lemonade example, let’s assume that there are 10 jars of lemonade on a table and $100. In an order book model, Bob would approach the stand and say that he is willing to buy a jar of lemonade for $5. Unfortunately, as each jar is worth $10, Bob does not get any lemonade. However, with the AMM model, Bob can take the same $5 and now receive a fraction of 1 jar of lemonade. This is because in an AMM model, orders are priced and filled based on how much money and how many jars of lemonade remain on the table. In contrast, the order book model prices assets and fills orders based on who is willing to buy/sell and for how much.
Note that in real life, financial instruments are often divisible, and that this example was to illustrate the different mechanisms of filling orders and pricing.
Within the AMM model, instead of centralized market-makers adding the liquidity, any individual can now deposit equal amounts of lemonade and dollars to provide liquidity and reap the benefits in trading fees. This model was fantastic for decentralization as it eliminated the need for centralized market-makers. However, it introduced new difficulties that the industry continues to grapple with today. For instance, all liquidity providers face impermanent loss.
Moving forward, how did the AMM model become so widespread in DeFi when it’s faced with such a large complication (impermanent loss)? Back to the order books!
Order Books Continued
Let me preface by saying that Order Books haven’t been prevalent in the DeFi space at all up until 2023 and even then, the decentralized equivalent of the model is not as well understood as the AMM model. This is because, historically, AMM-based protocols have been easier to implement on account-based blockchains such as Ethereum. They incur fewer transaction costs, have quicker settlement speeds, and are less complex to build. Additionally, as my initial example illustrated, in order book exchanges, liquidity is distributed across the prices that users are willing to buy and sell at. Matching these orders involve complex operations and concurrent matching engines that make them technically and economically unviable for account-based ledgers (the model used by Ethereum, Solana, and most other Blockchains). However, in a UTXO based ledger (the model used by Bitcoin and Cardano), the concurrency required for such an order book matching engine is a base feature of the ledger.
However, even beyond technical capability, a hurdle that still somewhat exists is populating the orderbook without over-reliance on a centralized institution and market-maker. Taking a look at the Orderbook DEX landscape on Cardano, Axo Trade and Genius Yield are both live with their exchanges and are now currently navigating how to attract liquidity.
In either case, I am of the personal opinion that a centralized market maker will hardly hurt the landscape of decentralized finance as there are still a multitude of different DEXs and even DEX aggregators to cherry the cake!
DEX Aggretors
Owing to the innumerable different DEXs within the Cardano ecosystem and wider DeFi landscape, liquidity is incredibly fragmented. In response, the concept of DEX aggregators has emerged. For instance, depending on liquidity, some DEXs cannot facilitate large transactions. Now a user might be willing to split their trade amongst all of these different DEXs and pay each transaction fee separately. However, aggregators are a user-friendly way to bring all of this information, execution, and liquidity together to get users the best prices with the least effort.
Conclusion
Overall, there is no right or wrong way to swap an asset. The wide array of choices are a byproduct of innovation - especially as the entire DeFi industry evolves into a serious contender to TradFi. As far as users are concerned, there is a natural gravitation towards the cheapest and most straightforward option available. In the past, this has been the AMM DEX. However, the tides may soon be shifting with institutions likely to prefer the Order Book for its advanced functionality and battle-tested nature. In either case, it is without a doubt that AMMs, Order Books, and the aggregators built on top will all continue to innovate, bridge the functionality gap, and offer new and improved frontiers for decentralized trading.