The article aims to provide an overview of different decentralized exchange (DEX) mechanisms, such as the order book and automated market maker (AMM) models. If you are unfamiliar with decentralized finance (DeFi), check out our introductory articles on DeFi, cryptocurrency, and AMMs. You can also read our Twitter Spaces transcript for “In the House #3: DEXs after CeFi”, a panel discussion with representatives of GMX, dYdX, and Ouroboros Capital.

What Are DEXs?

DEXs are peer-to-peer (P2P) marketplaces that connect buyers and sellers of crypto through smart contracts instead of intermediaries or custodians in a trustless and non-custodial manner.

In traditional finance (TradFi), traders buy and sell securities through brokers or banks that guarantee the safety and security of transactions. In crypto, trading is facilitated by centralized exchanges (CEXs) and DEXs. Like TradFi, CEXs such as Binance and Coinbase operate with a central body facilitating crypto trades while providing custody of assets to guarantee the safety and security of funds. On the other hand, DEXs promote self-custody, where users trade directly from their wallets, securing their funds with private keys. DEXs also democratize financial services while protecting user information privacy because there is no need for know-your-customer (KYC) and anti-money laundering (AML) processes typically required by CEXs and TradFi platforms. DEXs are built on Layer-1 blockchains such as Ethereum, Avalanche, and BNB Chain.

Read our comparison between CEXs and DEXs here!

Types of DEXs

In this article, we will expound on the three types of DEXs: order book, AMM, and hybrid DEXs.

Order Book DEXs

DEXs using central limit order book (CLOB) models are similar to CEXs and TradFi systems in the way they match buyers and sellers. Order books also display the price and quantity of crypto trading pairs on their interface and all transactions on a public ledger. Order book DEXs are less capital efficient, especially in illiquid markets where finding matching orders quickly can be difficult due to low trading volumes, possibly leading to higher slippage. They can be further broken down into on-chain and off-chain order book DEXs.

On-chain Order Book DEXs

With on-chain order book DEXs, all orders and transactions are recorded on the blockchain. This allows for greater transparency and decentralization since every transaction is reflected publicly. However, it can be expensive and slow because every transaction needs to be validated on-chain. Gridex Protocol is an example of an order book DEX that runs entirely on-chain.

Off-Chain Order Book DEXs

Off-chain order book DEXs offload on-chain trading activity by matching trades and holding trade information, such as positions and prices of assets, off-chain. This means that only the transaction for the final trading settlement will be carried out on-chain, allowing for faster transaction speeds and reduced gas fees. However, this brings about the risk of centralization since the order book and matching engines may be managed by single entities off-chain. dYdX announced that it sought to solve this centralization issue in dYdX V4.

dYdX

dYdX is an example of an off-chain order book DEX that offers perpetual futures trading for over 35 cryptocurrencies and is one of the biggest DEXs in terms of trading volume and market share. Each asset has its own order book with ask and bid prices listed, similar to CEXs. Although dYdX is a decentralized platform, it relies on a centralized system for its order book and matching engine since matching is facilitated off-chain. dYdX V4 aims to achieve full decentralization of the protocol.

Track your dYdX positions with Treehouse APIs, which provide DeFi analytics and comprehensive historical and current portfolio data. Contact us if you are interested!

AMM DEXs

AMMs use smart contracts to automate transactions, allowing users to trade their tokens with liquidity pools automatically rather than being matched directly with a buyer or seller. AMMs were popularized by Uniswap and pioneered by Bancor. Since then, AMM-based DEXs have dominated the total value locked (TVL) charts including protocols such as Curve, PancakeSwap, and Balancer.

Despite its convenience, users are met with high gas fees when swapping tokens, as well as huge slippage when trying to fill their orders. This problem is accentuated in smaller liquidity pools with wider bid-ask spreads. Developers have found a way to reduce the costs and slippage through an improved AMM mechanism — concentrated liquidity market makers (CLMMs).

CLMM DEXs

CLMMs, known as the next generation of AMMs, improve capital efficiency by allowing liquidity providers (LPs) to set a price range within which they would like to provide liquidity. Concentrated liquidity price ranges mitigate the problem of inefficiency that arises because traditional AMMs distribute liquidity evenly across the entire price curve though some assets fluctuate across a limited price range. However, the downside is that LPs will not earn any fees if the token price is outside the set range. CLMM DEXs include Uniswap, Trader Joe, and Orca.

Uniswap Case Study

Uniswap is a relevant case study since V1 and V2 make use of the traditional AMM mechanism, while V3 uses a CLMM model. Built on Ethereum, it uses smart contracts to automate the price-matching process, allowing users to swap ERC-20 tokens by interacting directly with the smart contracts and liquidity pools without intermediaries. Uniswap V1 and V2 use the constant product formula model to establish asset prices using the following equation:

x × y = k

“x” and “y” represent the amounts of each token in a pair, while “k” is the product or constant.

In Uniswap V1 and V2, LPs must add liquidity to a pool in a 1:1 ratio, such that the relative value of each asset in the pool does not change in proportion to the other. With this model, liquidity is distributed evenly across the price curve to handle prices from 0 to infinity. This results in capital inefficiency as most assets do not move within a huge price range. For example, stablecoin pools such as USDC/USDT/DAI trade within a very small price range most of the time, between $0.99 to $1.01.

Uniswap V3

Uniswap V3 was developed with improvements to increase returns for LPs and traders, minimize slippage, and manage downside risks. It uses the CLMM mechanism, allowing LPs to decide the price range which they want to provide liquidity for, concentrating their capital within specified ranges where most of the trading volume occurs. Thus, users can earn more trading fees while experiencing lower slippage than in V1 and V2…

Enjoyed reading this? Read the full piece here to learn more about Uniswap V3 and hybrid DEXs such as Drift.

Disclaimer

This publication is provided for informational and entertainment purposes only. Nothing contained in this publication constitutes financial advice, trading advice, or any other advice, nor does it constitute an offer to buy or sell securities or any other assets or participate in any particular trading strategy. This publication does not take into account your personal investment objectives, financial situation, or needs. Treehouse does not warrant that the information provided in this publication is up to date or accurate.

Treehouse APIs provide you with DeFi analytics through comprehensive current and historical data for your DeFi portfolios to meet your monitoring, trading, and reporting needs. Contact us if you are interested, or check out our integration with CryptoSheets! Otherwise, visit Treehouse Academy, Insights, and Treehouse Daily for in-depth research.

Are Order Books or AMMs Better for Decentralized Exchanges (DEXs)? was originally published in CryptoStars on Medium, where people are continuing the conversation by highlighting and responding to this story.