Résumé
You probably have some experience with crypto exchanges. Sign up with your email address, create a strong password, verify your account and start trading cryptocurrencies.
Decentralized exchanges do the same thing, minus the hassle of registrations. In most cases, there is no deposit or withdrawal of cryptocurrency. The trade takes place directly between the wallets of two users, without the participation of a third party.
Decentralized exchanges can be a little trickier to get to grips with, and they don't always have the assets you want. But as the technology and interest in it develops, these elements may well be integrated into the cryptocurrency sphere.
Contents
Introduction
Define what a decentralized exchange is
How a centralized exchange works
How a decentralized exchange works
On-chain order book
Off-chain order book
Automated Market Maker (AMM)
Advantages and Disadvantages of DEXs
The advantages of DEXs
The disadvantages of DEXs
To conclude
Introduction
Since the early days of Bitcoin, exchanges have played a vital role in matching cryptocurrency buyers with sellers. Without these meeting places attracting a global user base, we would have much less liquidity and no way to agree on the correct price of assets.
Centralized players have always dominated this area. However, with the rapid evolution of available technologies, a growing number of tools for decentralized exchanges have emerged.
In this article, we will discuss decentralized exchange platforms (DEX), where no intermediary is necessary.
Define what a decentralized exchange is
In theory, any peer-to-peer exchange could constitute a decentralized trade (see, for example, Atomic Swaps Explained). But in this article, we are mainly interested in a platform that emulates the functions of centralized exchanges. The main difference is that their backend exists on a blockchain. No one has custody of your funds and you don't need to trust the exchange as much as you do with centralized alternatives, if at all.
How a centralized exchange works
With your typical centralized exchange, you deposit your money, either fiat (by bank transfer or credit card) or cryptocurrencies. When you deposit cryptocurrencies, you give up control of them. Not from a usability point of view, because you can always trade or withdraw it, but from a technical point of view: you cannot spend it on the blockchain.
You do not own the private keys to the funds, which means that when you make a withdrawal, you are asking the exchange to sign a transaction on your behalf. When you trade, transactions do not take place on-chain. Instead, the exchange assigns balances to users in its own database.
The overall workflow is incredibly streamlined, as the slow speed of blockchains does not hinder trading and everything happens within a single entity's system. Cryptocurrencies are easier to buy and sell, and you have more tools at your disposal.
This comes at the cost of independence: you must entrust your money to the exchange. As a result, you are exposed to certain counterparty risks. What happens if the team runs away with your hard-earned BTC? What if a hacker cripples the system and steals the funds?
For many users, this is an acceptable level of risk. They just stick to reputable exchanges with a solid track record and precautions to limit data breaches.
How a decentralized exchange works
DEXs are similar to their centralized counterparts in some ways, but are significantly different in others. Let us first note that there are several types of decentralized exchanges available to users. What they have in common is that orders are executed on-chain (using smart contracts) and that users do not sacrifice custody of their funds at any time.
Efforts are being made to develop cross-chain DEXs, but the most popular revolve around assets from a single blockchain (like Ethereum or Binance Chain).
On-chain order book
In some decentralized exchanges, everything is done on-chain (we will talk about hybrid approaches soon). Each order (as well as any modification or cancellation) is recorded on the blockchain. This is arguably the most transparent approach, as you are not trusting a third party to place the orders, and there is no way to block them.
Unfortunately, it is also the least practical. Since you're asking every node on the network to record the order forever, you end up paying a fee. You have to wait for a miner to add your message to the blockchain, which means it can also be awkward to use.
Some consider that front running is a fault of this model. Front running occurs in the markets when an insider knows of a pending trade and uses this information to make a trade before it is processed. The front runner, therefore, benefits from information not known to the public. Generally speaking, it is an illegal activity.
Of course, if everything is public, there is no possibility of front running in the traditional sense. That said, another type of attack can be deployed: a miner sees the order before it is confirmed and ensures that their own order is added to the blockchain first.
Examples of on-chain order book models include Stellar DEXs and Bitshares.
➟Do you want to get started with cryptocurrencies? Buy Bitcoin (BTC) on Binance!
Off-chain order book
Off-chain order book DEXs are still decentralized in some ways, but admittedly they are a bit more centralized than traditional DEXs. Instead of publishing each order on the blockchain, they are hosted somewhere.
Where are they? It depends. You could have a centralized entity entirely in charge of the order book. If this entity is malicious, then it could game the markets to an extent (i.e., by executing or misrepresenting orders). However, you can still benefit from custody of your assets.
The 0x protocol for ERC-20 and other tokens deployed on the Ethereum blockchain is a good example of this. Rather than acting as a single DEX, it provides a framework for parties called “relayers” to manage order books off-chain. By leveraging 0x smart contracts and other tools, hosts can leverage a combined liquidity pool and relay orders between users. The transaction is only executed on-chain once the parties are matched.
These approaches are ergonomically superior to those that rely on on-chain order books. They don't face the same speed constraints because they don't use blockchain as much. Nevertheless, the transaction must be settled on the blockchain, so the off-chain order book model is still inferior to centralized exchanges in terms of speed.
Off-chain order book implementations include Binance DEX, IDEX, and EtherDelta.
Automated Market Maker (AMM)
Are you tired of reading the term “order book”? Perfect, because the automated market maker model (AMM) changes everything. This doesn't require makers or takers, just users, game theory and a bit of algorithmic black magic.
The specifics of automated market makers depend on their implementation. In general, they group together several smart contracts and offer advantages to guarantee user participation. We will not detail these implementations, but you can consult the article What is Uniswap and how does it work? for an example of how the Uniswap DEX works.
AMM-based DEXs available today tend to be relatively user-friendly, integrating with wallets like MetaMask or Trust Wallet. As with other forms of DEX, however, an on-chain transaction must be made to settle transactions.
Projects working on this front include the aforementioned Uniswap and Kyber Network projects (which leverage the Bancor protocol), both facilitating the trading of ERC-20 tokens.
Advantages and Disadvantages of DEXs
We've covered some of the pros and cons of DEXs in broad outlines in the previous sections. Let's look in a little more detail.
The advantages of DEXs
No KYC
Compliance with KYC/AML (Know Your Customer and anti-money laundering) standards is the norm for many exchanges. For regulatory reasons, people are often required to present identity documents and proof of address.
This is a privacy issue for some people and an accessibility issue for others. What happens if you don't have valid documents? What happens if your information leaks? Since DEXs are permissionless, no one verifies your identity. You just need to have a crypto wallet.
However, there are certain legal requirements when DEXs are partially managed by a central authority. In some cases, if the order book is centralized, the host must be compliant.
No counterparty risk
The main advantage of decentralized exchanges is that they do not hold customer funds. Therefore, even catastrophic hacks such as Mt. Gox in 2014 cannot impact DEX users.
Unlisted tokens
Tokens that are not listed on centralized exchanges can still be freely traded on DEXs, provided there is supply and demand.
The disadvantages of DEXs
Usability
In reality, DEXs are nowhere near as user-friendly as traditional exchanges. Centralized platforms offer real-time transactions that are not affected by block times. For newcomers who are unfamiliar with crypto wallets, CEXs offer a more forgiving experience. If you forget your password, you can simply reset it. However, if you lose your mnemonic phrase, your funds are irretrievably lost in cyberspace.
Trading volumes and liquidity
The volume traded on CEXs is always greater than that of DEXs. Perhaps more importantly, CEXs also tend to have greater liquidity. Liquidity is a measure of how easily you can buy or sell assets at a reasonable price. In a highly liquid market, supply and demand have little difference in price, which means strong competition between buyers and sellers. In an illiquid market, you will have a harder time finding someone willing to trade the asset at a reasonable price.
DEXs are still relatively specialized, so there isn't always supply or demand for the cryptoassets you want to trade. You may not find the trading pairs you want to use, and in this case, the assets may not be traded at a fair price.
Costs
Fees are not always higher on DEXs, but they can be, especially when the network is crowded or if you use an on-chain order book.
To conclude
Many decentralized exchanges have emerged over the years, each of them building on previous attempts to streamline the user experience and create more powerful trading venues. Finally, the idea seems strongly aligned with the ethics of self-sovereignty: as with cryptocurrencies, users do not need to trust a third party.
With the rise of DeFi, Ethereum-based DEXs have seen a massive increase in usage. If the momentum continues, we will likely see increased technological innovation across the sector.
➠ Do you have any other questions about exchanges? See you on Ask Academy!
