Order-books vs AMMs [Archive]

Decentralization is eating up all industries that have been reliant on custodians and third parties for storage and transfer of value. Everything about how present-day finance functions falls in this category. The illustrious rise of DeFi as a category over the past few years has only made this thesis stronger. As of today, more than $100 Bn worth of assets are locked in DeFi apps across Ethereum. TVL can be considered analogous to AUM of an asset management company or book-size of a lender etc.

Using blockchain to decentralize asset exchange was one of the first use cases of DeFi. Bitcoin tried to decentralize currency via blockchain, Ethereum allowed creation of multiple currencies and then naturally came up currency or rather token exchanges.

Problems plaguing centralized exchanges

  • Order data feeds are owned and licensed by a centralized entity

    • Risk of front-running by big players (NSE Scam)

    • Central point of failure of the core execution infra

  • Many intermediaries are required for ancillary operations but end up becoming centralized gatekeepers of user data and access

    • Depositories for asset custody

    • Clearing house for trade settlement

    • Broker for seamless execution and value-added services (leverage)

  • Permissioned listing of new assets

Decentralized Exchanges or DEXs try to solve some of these problems via blockchain technology. The goal of a DEX is to allow users to exchange tokenized assets in a more efficient and permissionless (non-custodial) way. Some projects do this by making existing trade execution models more transparent while others build new execution models ground up.

The two most prominent models of exchange design often center around the order book model and the automated market maker (AMM). Before comparing, let’s understand how they exactly work.

Most traditional exchanges like the NYSE, CME etc. follow an orderbook based model.

Automated Market Maker Model

The AMM exchange design works in such a way that all users trade with a pool of assets rather than directly interacting peer-to-peer. The AMM design, therefore, requires no order matching engine.

It can be thought of as the user always trading against a bot.

  • The bot follows a standard trading algorithm and uses the assets in the pool as its trading capital.

  • Every trade the user places is surely filled by the bot irrespective of the slippage and a price is discovered deterministically.

  • Since the bot is trading both assets from the pool, it can be categorized as a market-making bot.

Different AMMs have different price discovery algorithms. Uniswap pioneered the constant product method: xy = K where K is the total liquidity value in the pool and x, y represent relative quantities of the asset. If a user comes to an AMM DEX requesting to trade asset 1 for asset 2, the bot removes asset 1 from the pool and puts some asset 2 in the pool. This changes the ratio of x and y and hence the price of asset 1 (in terms of asset 2) updates

Hence if an AMM bot were to be interpreted as a bid-ask market maker, this is how the market depth chart would look like

  • Linear rather than granular

  • Uniform liquidity for all price ranges

Which approach is better?

Short answer, depends on the use-case.

To understand in-depth we’ll have to zoom out first, irrespective of the case, an efficient market for exchanging assets has to optimize for two things:

  • Availability of the asset

  • Accurate price of the asset

From the outset it seems, AMMs are better from both perspectives. Liquidity as well as fair price discovery on the blockchain. However, crypto markets are volatile and edge cases need to be considered:

  • Since AMMs are deterministic, they don’t allow for intelligent liquidity provisioning. LPs always have to be the counterparty in all scenarios. This exposes them to a lot of risk in volatile markets for a small part of the txn fee

  • Legacy AMMs equally distribute liquidity across the price curve (to ensure asset availability), therefore slippage is higher compared to order book models

Particularly because of these issues, AMMs haven’t been able to onboard institutional off-chain market makers as LPs and also haven’t been able prove themselves. in practice for more levered products like perpetual and options.

For some markets, availability might be a priority (long-tail assets, recently listed ERC20 tokens) while for some price accuracy is important (bluechip coins being traded frequently across CEXs, price parity on-chain is key)

There are other methods coming up to aggregate liquidity in a more competitive way (Auctions, RFQs for large complex orders). Uniswap V3 has enabled range-bound liquidity provisioning which is somewhat analogous to limit orders in a CLOB.

I think Uniswap V3 was a pivotal innovation in DEX infra.

I subscribe to the theory that in the end, all approaches will end in the same result, market makers providing intelligent liqudity (limit orders on CLOB or via Uniswap V3) and HODLers sacrificing slippage cost to acquire assets (ie market orders in a CLOB with high spread, Users swapping assets from small LP pools)

However it pans out, we’re just getting started in DeFi, lots more to come on top of these primitives. :)


The team at 0x liquidity has written a great piece on this, it covers other methods beyond AMMs and CLOBs as well as how the size of your trade also impacts what DEX would be optimum for getting the best execution

Link: DeFi Market Making

Subscribe to Nirvana Research
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.