Carefully! Lots of text.

You may be familiar with how a cryptocurrency exchange works. You just need to register using your email, create a password, confirm your account - and you can start trading cryptocurrency.

Decentralized exchanges work in a similar way, but require the user to register. Most often, they do not require you to enter or withdraw cryptocurrency. Trading occurs directly between the wallets of two users with limited (or possibly no) third party participation.

Decentralized exchanges can be a little more complicated to operate, and they don't always offer the assets you need. But as technology develops, they may well become an important part of the cryptocurrency industry.


Content

  • Introduction

  • Decentralized exchanges

  • How does a centralized exchange work?

  • How does a decentralized exchange work?

    • On-chain order books

    • Off-chain order books

    • Automated Market Makers (AMMs)

  • Pros and cons of DEX

    • Pros of DEX

    • Cons of DEX

  • Summary


Introduction

Since the earliest days of Bitcoin, exchanges have served as a communication channel for buyers and sellers of cryptocurrency. Without these exchanges attracting users from all over the world, the cryptocurrency market would have low liquidity and would not be able to offer a fair price for assets.

Traditionally, this area has been dominated by centralized players. However, as technology rapidly developed, more and more tools for decentralized trading appeared.

In this article, we will introduce decentralized exchanges (DEX) - trading platforms without intermediaries.


Decentralized exchanges

In theory, any peer-to-peer exchange could constitute decentralized trading (see How Atomic Swaps Work). But in this article, we are primarily interested in the platform itself, which offers the functions of centralized exchanges. The main difference is that their backend runs on the blockchain. No one will have access to your funds, and you will not need to trust the exchange to the same extent as you would when trading on a centralized exchange.


How does a centralized exchange work?

On a typical centralized exchange, users deposit money in either fiat currency (via bank transfer or credit/debit card) or cryptocurrency. After depositing cryptocurrency, the user loses control over it. It is possible to withdraw or exchange these funds, but from a technical point of view, they can no longer be spent on the blockchain.

Control over private keys is also limited, meaning that when withdrawing funds, you must request the exchange to sign the transaction on behalf of the user. During trading, transactions do not take place on-chain - instead, the exchange distributes balances to users in its own database.

The workflow is completely optimized, since the low speed of blockchains does not hinder trading and everything happens in a single system. Cryptocurrencies are easy to buy and sell, and users have more tools at their disposal.

However, for all this, you have to sacrifice independence and trust your funds to the exchange. As a result, you expose yourself to some risk. What if your BTC is stolen? What if a hacker attacks the system and takes over your funds?

Many users take this risk. They simply try to choose reliable exchanges with a good reputation and measures to prevent data leaks.


How does a decentralized exchange work?

DEXs have similar features to centralized exchanges, but also have significant differences. First of all, we note that users can choose between several types of decentralized exchanges. In each of them, orders are executed on-chain (using smart contracts), and users in no way sacrifice their independence.

Sometimes work is carried out on cross-chain DEXs, but usually all operations are associated with assets on a single blockchain (for example, Ethereum or Binance Chain).


On-chain order books

On some decentralized exchanges, all transactions are carried out on-chain (we will look at hybrid approaches later). Each order (as well as its changes and cancellations) is recorded on the blockchain. This is the most transparent approach since you are not trusting your orders to a third party.

Unfortunately, this is not entirely practical. Since every node on the network needs to record your order, you have to pay a fee. You will have to wait until the miner adds your order information to the blockchain, which can take a long time.

Some believe that frontrunning is a disadvantage of this model. It typically occurs in markets when insiders are aware of a pending transaction and use this information to complete a trade before processing the transaction. Thus, this user benefits from private information, which is actually illegal.

Of course, if everything is published to a global registry, frontrunning becomes impossible. However, another type of attack can be deployed: a miner sees your order before it is confirmed and adds his own order to the blockchain, ahead of you.

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


➟ Thinking about where to start working with cryptocurrencies? Buy Bitcoin (BTC) on Binance!


Off-chain order books

The off-chain order book of a DEX is decentralized in some ways, but still more centralized than others. Instead of placing every order on the blockchain, they place them in other places.

Where exactly? There are several options. You can work in a centralized system that is completely responsible for the order book. If this system is controlled by attackers, they can use the market to frontrun or distort orders. However, you will have the advantage of non-custodial storage.

One such example is the 0x protocol for ERC-20 and other tokens deployed on the Ethereum blockchain. Rather than acting as a separate DEX, it provides a structure for “relays” to manage off-chain order books. Using 0x smart contracts and some other tools, hosts can connect to a shared liquidity pool and transfer orders between users. A transaction on the chain is carried out only with the consent of the parties.

Such approaches are much more attractive from a usability perspective than relying on on-chain order books. They don't face the same limitations in terms of speed because they use blockchain less often. However, the trade must be completed online, so the off-chain order book model is still inferior to centralized exchanges in terms of speed.

Off-chain order books are implemented on Binance DEX, IDEX and EtherDelta.


Automated Market Makers (AMMs)

Tired of the term "order book"? Great, because the Automated Market Maker (AMM) model eliminates this idea entirely. It does not involve makers and takers - only users, game theory and a little magic.

The specifics of AMMs vary by implementation: they typically combine smart contracts and offer incentives for user engagement. We won't go into detail about the different options, but we'll look at the Uniswap DEX as an example. More information can be found in our article What is Uniswap and how does it work?

AMM-based DEXs available today tend to be user-friendly and integrate with wallets like MetaMask or Trust Wallet. However, as with other forms of DEX, trades must be transacted on-chain to settle.

Among the projects working in this direction and facilitating the trading of ERC-20 tokens are Uniswap and Kyber Network (which connect to the Bancor protocol).


Pros and cons of DEX

Previously, we outlined some of the advantages and disadvantages of DEXs. Let's take a closer look at them.


Pros of DEX

No need to undergo KYC verification

KYC/AML (Know Your Customer and Anti-Money Laundering) checks are mandatory for many exchanges. For regulatory reasons, users are required to provide identification documents and verify their address.

This is a privacy issue for some and an accessibility issue for others. What to do if you don’t have the necessary documents at hand? What to do if there is an information leak? Since DEXs are public, no one verifies your identity. All you need to get started is a cryptocurrency wallet.

However, there are a number of legal requirements due to which the DEX is partially managed by a central authority. If the order book is centralized, the user must comply with these requirements.


No risk of third party intervention

The main attraction of decentralized exchanges is that they do not store customer funds. Thus, even in the event of serious attacks, such as those on Mt. Gox, which occurred in 2014, your funds will not be at risk, and confidential information will not be transferred to third parties.


We have listed the token

Tokens that are not listed on centralized exchanges are available for trading on DEXs subject to supply and demand.


Cons of DEX

Ease of use

In reality, DEXs are not nearly as user-friendly as traditional exchanges. Centralized platforms offer trades in real time, eliminating the need for the user to wait for the lock time to expire. For beginners who are not familiar with cryptocurrency wallets, CEXs provide a simpler experience. If you have forgotten your password, you can easily reset it. However, if you lose your seed phrase, your funds will be lost forever in cyberspace.


Trading volumes and liquidity

Trading volume on CEX continues to outpace volume on DEX. Much more importantly, CEXs tend to have greater liquidity. Liquidity is a measure of how easily an asset can be bought and sold at a reasonable price. In a highly liquid market, bid and ask prices differ slightly, demonstrating high competition between buyers and sellers. In an illiquid market, you will have a harder time finding an offer at a reasonable price.

DEXs are still relatively niche, so there isn't always a supply and demand for the crypto assets you want. You may not be able to find some trading pairs, and if you do, it will most likely not be at a very fair price.


Commission

Fees are not always higher on DEXs, but they can cost a significant amount during periods of network congestion or when using an on-chain order book.


Summary

Over the years, many decentralized exchanges have emerged, each aiming to simplify the user experience and create more powerful trading platforms. Ultimately, this idea is very much in line with the principle of independence: as with cryptocurrencies, users do not need to trust a third party.

With the advent of DeFi, Ethereum-based DEXs have gained a lot of popularity. In the future, we are likely to witness many technological innovations in this industry.

➠ Still have questions about the exchange? Go to Ask Academy!