How Do Decentralized Exchanges Work?

Table of Contents

There are several DEX designs, each offering a different benefits and trade-offs in terms of feature-sets, scalability, and decentralization. The two most common types are order book DEXs and automated market makers (AMMs). DEX aggregators, which parse through multiple DEXs on-chain to find the best price or lowest gas cost for the user’s desired transaction, are also a widely used category.

One of the main benefits of DEXs is the high degree of determinism achieved by using blockchain technology and immutable smart contracts. Whereas in centralized exchanges (CEXs), such as Coinbase or Binance, the platform facilitates trading using the internal matching engine of the exchange, DEXs execute trades through smart contracts and on-chain transactions. Furthermore, DEXs allow users to maintain full custody of their funds via their self-hosted wallets during trading.

DEX users are typically required to pay two types of fees—network fees and trading fees. Network fees refer to the gas cost of the on-chain transaction while trading fees are collected by the underlying protocol, its liquidity providers, token holders, or a combination of these entities as specified by the design of the protocol.

The vision behind many DEXs is to have permissionlessly accessible, end-to-end on-chain infrastructure with no central points of failure and decentralized ownership across a community of distributed stakeholders. This typically means protocol administrative rights are governed by a decentralized autonomous organization (DAO), made up of a community of stakeholders, which votes on key protocol decisions. 

However, maximizing the decentralization of the protocol while keeping it competitive in a crowded DEX landscape isn’t an easy feat, as the core development team behind the DEX is generally able to make more informed decisions about mission-critical protocol functionality than a distributed set of stakeholders. Even so, many DEXs opt for a distributed governance structure in an attempt to increase censorship resistance and long-term resiliency.

Order Book DEXs #

An order book—a real-time collection of open buy and sell orders in a market—is a foundational pillar of electronic exchanges. Order books allow an exchange’s internal systems to match buy and sell orders.

Fully on-chain order book DEXs have been historically less common in DeFi, as they require every interaction within the order book to be posted on the blockchain. This requires either far higher throughput than most current blockchains can handle or significant compromises in network security and decentralization. As such, early examples of order book DEXs on Ethereum had low liquidity and suboptimal user experience. Even so, these exchanges were a compelling proof of concept for how a DEX could facilitate trading using smart contracts. 

With scalability innovations such as layer-2 networks like optimistic rollups and ZK-rollups and the launch of higher-throughput and app-specific blockchains, on-chain order book exchanges have become more feasible and now attract a considerable amount of trading activity. Additionally, hybrid order book designs have become more popular, where the order book management and matching processes take place off-chain while the settlement of trades occurs on-chain.  

Some popular order book DEXs include 0x, dYdX, Loopring DEX, and Serum.

Powered by BetterDocs