What Is a Decentralized Exchange (DEX)?
Home
Articles
What Is a Decentralized Exchange (DEX)?

What Is a Decentralized Exchange (DEX)?

Beginner
Published Sep 28, 2020Updated Feb 1, 2023
9m

TL;DR

You probably know the drill with cryptocurrency exchanges. Sign up with your email, come up with a strong password, verify your account, and start trading cryptocurrency.

Decentralized exchanges are like that, minus the hassle of sign-ups. In most cases, there’s no depositing or withdrawing crypto. The trade happens directly between two users’ wallets, with limited (if any!) input from a third-party.

Decentralized exchanges can be a bit trickier to get the hang of, and they might not always have the assets you want. But, as the tech and interest in it grow, these may very well become integral components in the cryptocurrency sphere.


Contents


Introduction

From the early days of Bitcoinexchanges have played a vital role in matching cryptocurrency buyers with sellers. Without these forums attracting a global user base, we’d have much poorer liquidity and no way to agree on the correct price of assets.

Traditionally, centralized players have dominated this field. However, with the rapidly-evolving stack of technologies available, a growing number of tools for decentralized trades have emerged.

In this article, we’ll take a dive into decentralized exchanges (DEXs), trading venues where no intermediaries are required.


Defining decentralized exchanges

In theory, any peer-to-peer swapping could constitute a decentralized trade (see, for instance, Atomic Swaps Explained). But in this article, we’re primarily interested in a platform that emulates the functions of centralized exchanges. The key difference is that their backend exists on a blockchain. No one takes custody of your funds, and you don’t need to trust the exchange to the extent that you do with centralized offerings, if at all.


How a centralized exchange works

With your typical centralized exchange, you deposit your money – either fiat (via bank transfer or credit/debit card) or cryptocurrency. When you deposit crypto, you give up control of it. Not from a usability standpoint, as you can still trade it or withdraw it, but from a technical standpoint: you cannot spend it on the blockchain.

You don’t own the private keys to the funds, which means that when you withdraw, you ask the exchange to sign a transaction on your behalf. When you’re trading, transactions don’t occur on-chain – instead, the exchange allocates balances to users in its own database.

The general workflow is incredibly streamlined because the slow speeds of blockchains don’t impede trading, and everything occurs in a single entity’s system. Cryptocurrencies are easier to buy and sell, and you have more tools available to you.

This does come at the cost of independence: you need to trust the exchange with your money. As a result, you expose yourself to some counterparty risk. What if the team runs off with your hard-earned BTC? What if a hacker cripples the system and drains the funds?

For many users, this is an acceptable level of risk. They simply stick to reputable exchanges with strong track records and precautions that mitigate data breaches.


How a decentralized exchange works

DEXs are similar to their centralized counterparts in some ways but significantly different in others. Let’s first note that there are a few different types of decentralized exchanges available to users. The common theme among them is that orders are executed on-chain (with smart contracts) and that users do not sacrifice custody of their funds at any point.

Some work has been done on cross-chain DEXs, but the most popular ones revolve around assets on a single blockchain (such as Ethereum or Binance Chain).


On-chain order books

In some decentralized exchanges, everything is done on-chain (we’ll talk about hybridized approaches shortly). Every order (as well as alteration and cancellation) is written to the blockchain. This is arguably the most transparent approach, as you’re not trusting a third party to relay the orders to you, and there’s no way to obfuscate them. 

Unfortunately, it’s also the most impractical. Since you’re asking every node on the network to record the order forever, you end up paying a fee. You need to wait until a miner adds your message to the blockchain, meaning the experience can be cumbersome, too. 

Some identify front running as a flaw in this model. Front running occurs in markets when an insider is aware of a pending transaction and uses that information to place a trade before the transaction is processed. The front runner, therefore, benefits from information not known to the public. Generally speaking, this is illegal. 

Of course, if everything is published on a global ledger, there’s no opportunity to front run in the traditional sense. That said, a different kind of attack can be deployed: one where a miner sees the order before it’s confirmed, and ensures that their own order gets added to the blockchain first.

Examples of on-chain order book models include the Stellar and Bitshares DEXs.


➠ Looking to get started with cryptocurrency? Buy Bitcoin (BTC) on Binance!


Off-chain order books

Off-chain order book DEXs are still decentralized in some regards, but they’re admittedly more centralized than the previous entry. Instead of every order being posted to the blockchain, they’re hosted somewhere. 

Where? That depends. You could have a centralized entity completely in charge of the order book. If that entity is malicious, then they could game the markets to an extent (i.e., by front running or misrepresenting orders). However, you would still benefit from non-custodial storage.

The 0x protocol for ERC-20 and other tokens deployed on the Ethereum blockchain is a good example of this. Rather than act as a singular DEX, it provides a framework for parties known as “relayers” to manage off-chain order books. Leveraging 0x smart contracts and some other tools, hosts can tap into a combined liquidity pool and relay orders between users. The trade is only executed on-chain once the parties are matched.

These approaches are superior from a usability perspective than those that rely on on-chain order books. They don’t face the same constraints in terms of speed, as they don’t use the blockchain as much. Still, the trade must be settled on it, so the off-chain order book model is still inferior to centralized exchanges in terms of speed.

Implementations of off-chain order books include Binance DEX, IDEX, and EtherDelta.


Automated Market Makers (AMM)

Fed up of reading the term “order book?” Great, because the Automated Market Maker (AMM) model does away with the idea altogether. It doesn’t require makers or takers, just users, game theory, and a bit of formulaic black magic. 

The specifics of AMMs depend on the implementation – generally, they string together a bunch of smart contracts and offer clever incentives to ensure user participation. We won’t detail these implementations, but check out What Is Uniswap and How Does It Work? for an example of how the Uniswap DEX works.

The available AMM-based DEXs today tend to be relatively user-friendly, integrating with wallets like MetaMask or Trust Wallet. As with other forms of DEXs, though, an on-chain transaction must be made to settle trades.

Projects working on this front include the aforementioned Uniswap and Kyber Network (which taps into the Bancor protocol), both facilitating the trade of ERC-20 tokens.


Pros and cons of DEXs

We’ve touched on some of the advantages and drawbacks of DEXs in broad strokes in the previous sections. Let’s delve into them a bit more.


Pros of DEXs

No KYC

KYC/AML (Know Your Customer and Anti-Money Laundering) compliance is the norm for many exchanges. For regulatory reasons, individuals must often submit identity documentation and proof of address.

This is a privacy concern for some and an accessibility concern for others. What if you don’t have valid documents on hand? What if the information is somehow leaked? Since DEXs are permissionless, no one checks your identity. All you need is a cryptocurrency wallet.

However, there are some legal requirements when DEXs are partially run by a central authority. In some cases, if the order book is centralized, the host must remain compliant.


No counterparty risk

The primary appeal of decentralized cryptocurrency exchanges is that they don’t hold customers’ funds. As such, even catastrophic breaches like the 2014 Mt. Gox hack won’t put users’ funds at risk or expose any sensitive personal information.


Unlisted tokens

Tokens that aren’t listed on centralized exchanges can still be traded freely on DEXs, provided there’s supply and demand.


Cons of DEXs

Usability

Realistically, DEXs aren’t nearly as user-friendly as traditional exchanges. Centralized platforms offer real-time trades that are unaffected by block times. For newcomers unfamiliar with non-custodial cryptocurrency wallets, CEXs provide a more forgiving experience. If you forget your password, you can simply reset it. If you lose your seed phrase, however, your funds are irretrievably lost in cyberspace.


Trading volumes and liquidity

The volume traded on CEXs still dwarfs that of DEXs. Perhaps more importantly, CEXs tend to have greater liquidity, too. Liquidity is a measure of how easily you can buy or sell assets at a reasonable price. In a highly liquid market, bids and asks have little difference in price, signifying high competition between buyers and sellers. In an illiquid market, you’ll have a more difficult time finding someone that wants to trade the asset for a reasonable price.

DEXs are still relatively niche, so there isn’t always supply or demand for the crypto assets you wish to trade. You may not be able to find the trading pairs you want to use, and if you do, assets might not trade at a fair price. 


Fees

Fees aren’t always higher on DEXs, but they can be, particularly when the network is congested or if you’re using an on-chain order book.


Closing thoughts

Many decentralized exchanges have emerged over the years, each iterating on previous attempts to streamline the user experience and build more powerful trading venues. Ultimately, the idea seems heavily aligned with the ethos of self-sovereignty: as with cryptocurrencies, users don’t need to trust a third party. 

With the rise of DeFi, Ethereum-based DEXs have seen a massive uptick in usage. If the momentum continues, we’ll likely witness increased innovation in the technology across the entire industry.