DEX Wars: an analysis of the AMM vs CLOB debate

Astroport
10 min readSep 12, 2022

--

Introduction

Automated Market Makers (AMMs) have dominated the recent DeFi landscape — more than 300 projects have forked the Uniswap code and countless more have implemented their own version of the novel AMM. The majority of on-chain spot trading volume still takes place on AMMs. And there are even more token pairs on AMMs than there are on centralized exchanges.

But a new (and for some old) narrative is emerging. This is especially the case in the Cosmos ecosystem. With the rise of order book specific blockchains like Sei, Injective, Kujira, and dYdX coming to Cosmos, there is a rising question of the value proposition of AMMs and how they are positioned to compete with central-limit order books (CLOBs).

In the first half of this article, we compare AMMs with CLOBs on various core debates. In the second half, we discuss possible integrations between the two models. Overall, AMMs and CLOBs serve different purposes and don’t necessarily need to compete. Moreover, the best DEX model might require a combination of the two.

What is an Automated Market Maker?

An Automated Market Maker (AMM) is a set of smart contracts enabling exchange of tokens, using the relative balance of assets in “liquidity pools” to determine market prices. In the case of constant product AMMs, the price of one token relative to another is calculated by the ratio of each type of tokens in the pool and a constant product formula. When a user deposits tokens to a constant product pair, their liquidity is spread out across all possible ranges in the price curve [0, ∞]. When a user swaps and adds/removes tokens from a pool, the ratio between the two tokens gets recalculated and the price updates according to its position in the curve at the time. For stableswap AMMs, liquidity is still spread across all possible price ranges, but it tends to concentrate more closely around the 1:1 exchange rate.

Arbitrageurs also play a key role in price discovery. If an asset is listed higher in a centralized exchange, the user could buy the asset from the AMM and sell it off through the CEX. On the other hand, if the asset is listed lower in a CEX, a user can buy the asset and sell it off to the AMM. In either case, the distribution of tokens in the pool gets rebalanced until the AMMs price matches external price conditions.

What is a Central Limit Order Book?

A Central Limit Order Book (CLOB) is an exchange model which aggregates limit orders and matches buyers with sellers. Although CLOBs are relatively new to DeFi, they have been around in traditional finance for decades. They are also commonly used in crypto centralized exchanges. The rarity of on-chain CLOBs is mostly due to the fact that they require substantially more transactions than AMMs, making speed and cost a key factor that has prevented the growth of CLOBs as DEXs.

When it comes to price discovery, CLOBs take a different approach from AMMs. Instead of calculating the price by the ratio of tokens in a liquidity pool, price is determined by the lowest asking price (sell order) on an order book. The more limit orders from market participants sitting on both sides of the book, the more liquidity that a pair has. This often means narrow spreads between the ask and bid price, resulting in more efficient trading at certain price ranges.

Comparing AMMs and CLOBs

TLDR

Capital Efficiency

Given the differences in market price design, there are considerable implications for capital efficiency. Even though price is determined across an indefinite curve in constant-product AMMs, capital is not always used in all ranges. For example, it is unlikely that Ethereum will trade at 1 USDC in the next week from posting this article. However, a constant product formula, by design, allocates capital even for such extreme cases. Moreover, if the AMM does not generate enough fees, positions may become subject to a phenomenon called impermanent loss.

On the other hand, CLOBs are made up of limit orders. Buy and sell limit orders sit on an order book and make up the “liquidity” in a CLOB. Given the flexibility of limit orders, price is able to concentrate around certain ranges. When ask and bid orders become closer to each other, the spread is narrow and the pair is more liquid. If buy and sell orders overlap, the CLOB is able to execute the trade without much, if any, slippage. This makes CLOBs ideal for “fat-tail” assets like Bitcoin and Ethereum. But, when liquidity is low, spreads becomes higher and there are often not enough limit orders on the book to fill trades. This makes the flexible price discovery of AMMs ideal for “long-tail” assets.

However, with the introduction of concentrated liquidity in Uniswap v3, liquidity providers can specify a price range. For example, a user could provide liquidity to the USDC/USDT pair and specify a price range of $0.99 and $1.01. While the user would still make fees under a traditional AMM when trades happen, not all of the users capital would be deployed at those levels. On the other hand, concentrated liquidity makes the users capital more efficient by allocating 100% of it to the specified price range, maximizing the trading fees that could be generated.

Moreover, unlike CLOBs, concentrated liquidity-based AMMs are simply aggregations of constant product curves, which means we can still preserve the flexibility of indefinite price discovery for extreme and volatile edge cases. For example, in the case of the LUNA/UST collapse, it would be useful to swap out of your assets without worrying about your trade not being filled.

Market Making

Perhaps one of the most important contributions of AMMs is the democratization of market making. As the name suggests, market making becomes “automated”. What does this mean?

A user simply has to deposit liquidity to a pool, and their assets get distributed along an indefinite price range (constant product) or a specified price range (in the case of concentrated liquidity). This makes bootstrapping a pair extremely accessible and efficient to the average user. In many cases, AMM UIs even have options to bootstrap a pool with no code at all.

On the other hand, market making for CLOBs is highly sophisticated and requires active participation. Not only would a user have to create various limit orders on both sides of the order book, but they would also have to account for the volume to deposit at each level. As a result, market making for CLOBs has largely been relegated to dedicated market makers, institutional players, centralized parties, sophisticated traders, and the like.

Of course, concentrated liquidity also requires active participation. Some even argue that an extreme version of concentrated liquidity ends up looking a lot like a CLOB. This would mean placing various LP positions of different sizes across the price curve, similar to an order book. At the same time, such extreme version is not necessary for the average user to leverage the capital efficiency of concentrated liquidity and become a market maker.

Incentive Structures

Another difference between the two models is the incentive structure. AMMs rely on incentivizing liquidity pools and swap fees. If swap fees are not sufficient to overcome impermanent loss, then fewer users are willing to deposit liquidity. In turn, this means more slippage and even less trading, creating a compounding effect. This is why incentives are used to attract liquidity. If fees from trading volume or incentives are higher than impermanent loss, then this attracts more LPs, which in turn provides better slippage and increases trading, generating more fees in a virtuous cycle.

When it comes to AMM and tokenomics design, a lot of factors need to be considered to make sure the right balance of incentives is reached. The protocol still needs to generate revenue, and this means that in the long run fees need to make up for incentives deployed. Otherwise, incentives would simply contribute to an inflationary token.

CLOBs take a completely different approach to incentives. If a user places a market order, this means they are taking liquidity from the order book, and they are usually subject to a taker fee. But if a user places a limit order, this means they are providing liquidity to the order book, and can receive a maker fee if their order is filled. Since impermanent loss is not a concern, incentives are less of an issue here. However, it could be argued that CLOBs can incentivize limit orders similar to AMMs via a governance token. This would, for example, help bootstrap tokens with wide spreads and low liquidity.

Order Types

Perhaps the rise of perps and derivatives has something to do with the recent momentum for CLOBs. One thing is for sure: CLOBs, out of the box, have more flexibility for different order types. For example, limit orders are already integral to the design, but other types such as stop losses, trailing stops, options, leverage, etc. can be integrated.

On the other hand, while it is not impossible for an AMM to offer limit orders, it is a comparable challenge. Especially when we get to further customized order types and leverage.

Pair Types

While CLOBs may be optimized for trading, AMMs are optimized for liquidity. Nowhere is this more evident than the ability for a 3/4pool. With CLOBs, the order book is between a pair of tokens, which makes having more than two tokens in a pair impossible. Why does this matter?

Thinking back to capital efficiency, say you needed liquidity between USDC / USDT / DAI. Under a CLOB, you would need at least two pairs, for example USDC/USDT and USDC/DAI to trade across all three markets. In the case of USDT to DAI, you would have to trade for USDC first and then swap for DAI, making the trade less efficient. In contrast, AMMs could be engineered to pool liquidity from all 3 stablecoins creating a more efficient aggregation and distribution of liquidity.

MEV Attacks

The risk of an MEV attack is often brought up as a challenge to AMMs. While frontrunning and sandwiching is a real concern for AMMs, it’s not entirely an intrinsic problem. For example, there are AMMs working on zero-knowledge solutions to encrypt transaction data before it is confirmed by validators and made public. Osmosis comes to mind in this case. Another example is Secret Network which uses trusted enclaves to execute encrypted transactions. In the same way, it could be argued that most order books are off-chain and present a security risk, but, this too, is not an intrinsic property of an order book. Obviously, AMMs are building towards MEV solutions in the same way that CLOBs are building towards an on-chain future. That being said, MEV attacks are not exclusive to AMMs and market orders placed on a CLOB are suceptible to frontrunning as well.

AMM <> CLOB Integrations

In this section, we will briefly cover some existing integrations between AMMs and CLOBs.

Serum / Raydium / Atrix

Serum is a CLOB on the Solana blockchain. The protocol itself doesn’t have a dedicated front-end of its own. Instead, the protocol focuses on the infrastructure layer, allowing other projects to compose and build on top of Serum.

Two of these projects are Raydium and Atrix. They function like regular AMMs with liquidity pools except that they plug into Serum to provide liquidity in the form of limit orders on the book in exchange for maker fees. Atrix seems to take a heavier focus on market making, as they have eliminated all swap fees from their protocol and generate their revenue entirely from providing liquidity to Serum.

With this hybrid model, users can get features from both DEXs. Trades still happen primarily through an order book, maximizing capital efficiency. However, AMMs bootstrap liquidity and serve as decentralized market makers for CLOBs.

Demex

In many ways, Demex is similar to the previous example. The main difference is that while Serum is focused on the order book itself, leaving liquidity and market making for other projects, Demex creates an all-in-one solution. Demex hosts its own order book but it also has liquidity pools like an AMM that feed limit orders into the order book itself. This doesn’t mean Demex has a better design; there are advantages to the composable strategy of Serum. The purpose is simply to shed light to how other projects are integrating AMMs and CLOBs.

Conclusion

For how long AMMs have been around, they are quickly adapting and evolving to overcome their deficiencies. But what is the unique value proposition for AMMs? What sets AMMs apart from CLOBs? As hinted before in this article, it seems like CLOBs are the preferred solution for trading. They offer the order type flexibility and low slippage that traders need. With the increasing adoption of DeFi, it also makes sense that institutional players are more likely to leverage tools from traditional finance. But CLOBs suffer from one main problem: democratizing liquidity.

Instead of optimizing for trading, AMMs can optimize for liquidity. After all, liquidity is still king in DeFi. To integrate with CLOBs, AMMs could serve as decentralized market makers, spreading liquidity across an order book, and focus on market maker fees. This would remove the need for sophisticated or centralized market makers in favor of automated and permissionless protocols to pool liquidity. So far, we have seen some of these integrations, but there is still more that can be done to optimize AMMs as hubs for liquidity.

--

--

Astroport
Astroport

Written by Astroport

An automated, decentralised exchange protocol on the Terra blockchain. http://astroport.fi

Responses (1)