Table of Contents
Since the early days of Bitcoin, exchanges have played a vital role in matching cryptocurrency buyers and sellers. If these forums did not attract a global user base, we would have much less liquidity and no way to agree on the correct asset price.
Traditionally, centralized actors have dominated this area. However, with the rapidly evolving stack of available technologies, an increasing number of tools for decentralized trades have emerged.
In this article, we’ll dive into Decentralized Exchanges (DEX), trading venues where no middleman is required.
Definition of Decentralized Exchanges
In theory, any peer-to-peer exchange could constitute decentralized commerce (see, for example, Atomic Swaps Explained). But in this article, we are primarily interested in a platform that emulates the functions of centralized exchanges. The main difference is that their backend exists on a blockchain. No one is taking care of your funds, and you don’t need to trust the exchange as long as you do with centralized offers, if at all.
How a Centralized Exchange Works
With your typical centralized exchange, you deposit your money – either fiat (by wire transfer or credit / debit card) or cryptocurrency. When you deposit crypto, you give up control of it. Not from a usability point of view, because you can still trade or withdraw it, but from a technical point of view: you cannot spend it on the blockchain.
You don’t own the private keys to the funds, which means when you withdraw, you are asking the exchange to sign a transaction on your behalf. When you trade, transactions don’t happen on a chain. Instead, the exchange allocates balances to users in its own database.
The overall workflow is incredibly streamlined as slow blockchains don’t hamper trading and everything happens in a single entity system. Cryptocurrencies are easier to buy and sell, and you have more tools at your disposal.
This comes at the expense of independence: you have to trust the exchange with your money. As a result, you expose yourself to counterparty risk. What if the team ran away with your hard-earned BTC? What if a hacker paralyzes the system and drains 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 that mitigate data breaches.
How a Decentralized Exchange Works
DEXs are similar to their centralized counterparts in some ways, but very different in others. Note first of all that there are several types of decentralized exchanges available to users. The common theme between them is that orders are executed on a chain (with smart contracts) and that users do not sacrifice the custody of their funds at any time.
Some work has been done on cross-chain DEXs, but the most popular revolves around assets on a single blockchain (like Ethereum or Binance Chain).
On-chain order books
In some decentralized exchanges, everything is done in chain (we’ll talk about hybrid approaches shortly). Each order (as well as the modification and cancellation) is written to the blockchain. This is arguably the most transparent approach, as you don’t trust a third party to pass the commands to you and there is no way to hide them.
Unfortunately, it is also the least practical. Since you have every node in the network save 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 the experience can be overwhelming as well.
Some identify the front operation as a defect in this model. Front running occurs in the markets when an insider is made aware of a pending trade and uses that information to complete a trade before the trade is processed. The lead runner therefore benefits from information not known to the public. Generally speaking, it is illegal.
Of course, if everything is published in a global ledger, there is no possibility of highlighting in the traditional sense. That said, another type of attack can be deployed: one where a miner sees the order before it is confirmed and makes sure that their own order is added to the blockchain first.
Examples of chain order book models include the DEX Stellar and Bitshares.
Off-chain order books
Off-chain backlog DEXs are still decentralized in some ways, but admittedly more centralized than the previous entry. Instead of every order being posted to the blockchain, they are hosted somewhere.
Or? It depends. You could have a centralized entity entirely responsible for the order book. If this entity is malicious, then it could gamble the markets to some extent (i.e. by filling orders or by distorting orders). However, you will still benefit from non-private storage.
The 0x protocol for ERC-20 and other tokens deployed on the Ethereum blockchain is a good example. Rather than acting as a single DEX, it provides a framework for parties called “relays” to manage off-chain order books. By taking advantage of smart contracts 0x and some other tools, hosts can tap into a combined pool of liquidity and relay orders between users. The transaction is not executed on chain until the parties are matched.
These approaches are superior in user-friendliness to those that rely on chain order books. They don’t face the same constraints in terms of speed because they don’t use blockchain as much. Still, trade needs to be tuned to it, so the off-chain order book model is still inferior to centralized trade in terms of speed.
Off-chain order book implementations include Binance DEX, IDEX, and EtherDelta.
Automated Market Makers (AMM)
Tired of reading the term “backlog”? Great, because the Automated Market Maker (AMM) template does away with the idea altogether. It doesn’t require creators or takers, just users, game theory, and a bit of black magic.
The specifics of AMMs depend on the implementation – usually they string together a bunch of smart contracts and offer smart incentives to ensure user participation. We won’t go into these implementations in detail, but see What is Uniswap and how does it work? for an example of how Uniswap DEX works.
The AMM-based DEXs available today tend to be relatively user-friendly, integrating into wallets like MetaMask or Trust Wallet. As with other forms of DEX, however, a chain transaction must be performed to settle the transactions.
Projects working on this front include the aforementioned Uniswap and Kyber network (which operates the Bancor protocol), both of which facilitate the trading of ERC-20 tokens.
Pros of DEXs
1. No KYC – KYC / AML (Know Your Customer and Anti-Money Laundering) compliance is the norm for many exchanges. For regulatory reasons, individuals are often required to present identity documents and proof of address.
This is a privacy issue for some and an accessibility issue for others. What if you don’t have valid documents on hand? What if the information is disclosed in some way? Since DEXs are unauthorized, no one is verifying your identity. All you need is a cryptocurrency wallet.
However, there are some legal requirements when DEXs are partially managed by a central authority. In some cases, if the order book is centralized, the host must remain compliant.
2. No counterparty risk: The main attraction of decentralized cryptocurrency exchanges is that they don’t hold client funds. As such, even catastrophic breaches like Mount 2014. Gox hack will not endanger user funds or expose sensitive personal information.
3. Tokens not listed: Tokens that are not listed on centralized exchanges can still be traded freely on DEXs, provided there is both supply and demand.
Cons of DEXs
1. Usability: In reality, DEXs are not as user friendly as traditional exchanges. Centralized platforms offer real-time transactions that are unaffected by block times. For newcomers unfamiliar with non-custodial cryptocurrency wallets, CEXs offer a more forgiving experience. If you forget your password, you can simply reset it. However, if you lose your seed sentence, your funds are irretrievably lost in cyberspace.
2. Trading volumes and liquidity: The volume traded on CEXs always exceeds 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 very liquid market, offers and requests have little price difference, which means strong competition between buyers and sellers. In an illiquid market, you will have a harder time finding someone who is willing to trade the asset for a reasonable price.
DEXs are still relatively niche, so there isn’t always a supply or demand for the crypto assets you want to trade. You might not be able to find the trading pairs you want to use, and if you do, the assets might not trade for a fair price.
3. Fees – Charges aren’t always higher on DEXs, but they can be, especially when the network is congested or if you’re using a chain order book.
Numerous decentralized exchanges have emerged over the years, each repeating previous attempts to streamline the user experience and create more powerful trading platforms. Ultimately, the idea seems strongly aligned with the ethic of self-sovereignty: Like cryptocurrencies, users don’t need to trust a third party.
With the rise of DeFi, Ethereum-based DEXs have seen a massive increase in their use. If the momentum continues, we will likely see increased technological innovation across the industry.