TL;DR
You probably already know how to use a cryptocurrency exchange. Sign up with your email, create a strong password, verify your account, and start trading crypto.
Decentralized exchanges are like that too, but without the need to register. In most cases, there are no crypto deposits or withdrawals. Trading occurs directly between two users' wallets, with limited (if any!) interference by third parties.
Decentralized exchanges can be a little more difficult to understand, and also may not always have the assets you want. However, as technology and interest develop, it is not impossible that this type of exchange will become an integral component in the crypto world.
Content
Introduction
Defining decentralized exchanges
How centralized exchanges work
How do decentralized exchanges work
Order book on-chain
Order book off-chain
Automated Market Makers (AMM)
DEX pros and cons
Pro DEX
Against DEX
Conclusion
Introduction
Since the early days of Bitcoin, exchanges have played an important role in matching buyers with sellers of cryptocurrencies. Without these forums attracting a global user base, we would have much worse liquidity, and no way to agree on the right price for an asset.
Traditionally, centralized players dominate this field. However, with the availability of rapidly developing technology, more and more decentralized trading tools continue to emerge.
In this article, we will study decentralized exchanges (DEX), trading places that do not require intermediaries.
Defining decentralized exchanges
In theory, a peer-to-peer exchange can be considered a decentralized exchange (see Explanation of Atomic Swap). However, in this article, we will focus primarily on platforms that mimic the functions of centralized exchanges. The main difference is that the DEX backend is on the blockchain. Nobody takes custodial rights to your funds, and you don't have to trust the exchange as much as you would a centralized exchange.
How centralized exchanges work
With the centralized exchange you're used to, you deposit money – either fiat (via bank transfer or credit/debit card) or crypto. When you deposit crypto, you relinquish control over that crypto. Not from a usage 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 do not have a private key to the funds, which means that when making a withdrawal, you are asking the exchange to sign the transaction on your behalf. When trading, transactions do not occur on-chain – instead, the exchange allocates balances to users in its own database.
The general workflow is very efficient, as the blockchain's low speed does not hinder trading, and everything happens within a single entity system. Cryptocurrencies are easier to buy and sell, and you have more tools available to use.
This method does come at the cost of freedom: you have to entrust your money to the exchange. As a result, you expose yourself to some counterparty risk. What if a team makes off with your hard-earned BTC? What if hackers cripple the system and drain funds on the exchange?
For many users, this is an acceptable level of risk. They only use reputable exchanges with a strong track record and preventive measures that mitigate data breaches.
How do decentralized exchanges work
DEXs are similar to centralized ones in some ways, but differ significantly in others. First of all, note that there are several types of decentralized exchanges available to users. The common denominator between all of them is that orders are executed on-chain (with a smart contract), and users never sacrifice custodial rights to funds.
Some already use cross-chain DEXs, but the most popular still revolve around assets on a single blockchain (such as Ethereum or Binance Chain).
Order book on-chain
On some decentralized exchanges, everything is done on-chain (we'll talk about the mixed approach in a moment). Every order (as well as changes and cancellations) is written to the blockchain. This is arguably the most transparent approach, as you are not trusting a third party to place the order for you, and there is no way to obscure it.
Unfortunately, it is also the most impractical. Because you're asking every node in the network to record orders forever, and eventually you have to pay a fee. You have to wait until the miners add your order to the blockchain, which can be a real hassle.
Some identify front running as a flaw in this model. Front running occurs in markets when insiders learn of pending transactions and use that information to execute trades before the transactions are processed. Therefore, Front runners benefit from information that is not known to the public. In general, this is illegal.
Of course, if everything is published on a global ledger, there is no opportunity for front running in the traditional sense. However, a different type of attack is possible: one where miners look at orders before they are confirmed, and ensure that their own orders are added to the blockchain first.
Examples of on-chain order book models include DEX Stellar and Bitshares.
➠ Want to own cryptocurrency? Buy Bitcoin (BTC) on Binance!
Order book off-chain
DEXs with off-chain order books are still decentralized in some ways, but are admittedly more centralized than on-chain types. Instead of being posted to the blockchain, each order is placed elsewhere.
Where? It depends. It could be in a centralized entity that is solely responsible for the order book. If the entity is malicious, then the market can be gamed to some extent (i.e., by front running or placing orders in the wrong positions). However, you will still get the benefits of non-custodial storage.
The 0x protocol for ERC-20 and other tokens used on the Ethereum blockchain is a good example of this. Rather than acting as a single DEX, the protocol provides a framework for parties known as “relayers” to manage order books off-chain. By leveraging the 0x smart contract and several other tools, hosts can utilize pooled liquidity pools and pass orders between users. Trades are only executed on-chain once the parties match.
This approach is superior from a usage perspective to those relying on on-chain order books. It doesn't face the same obstacles in terms of speed, because it doesn't use blockchain very often. However, trades must be completed on it, so the off-chain order book model still loses out in terms of speed when compared to centralized exchanges.
Off-chain order book implementations include Binance DEX, IDEX, and EtherDelta.
Automated Market Makers (AMM)
Tired of reading the term "order book?" Good, because the Automated Market Maker (AMM) model doesn't use that idea at all. This system doesn't require a maker or taker, just users, game theory, and a little black magic formula.
The specifics of an AMM depend on its implementation – generally, this type of exchange chains together many smart contracts and offers smart incentives to ensure user participation. We won't go into detail about this implementation, but take a look at What is Uniswap and How Does It Work? to observe an example and how the Uniswap DEX works.
The AMM-based DEXes available today tend to be relatively user-friendly, integrating with wallets such as MetaMask or Trust Wallet. However, like other DEXes, on-chain transactions must be made to complete trades.
Projects working on this front include Uniswap and Kyber Network (which utilizes the Bancor protocol), both of which facilitate trading of ERC-20 tokens.
DEX pros and cons
We have discussed some of the advantages and disadvantages of DEX in general. Let us learn more about.
Pro DEX
No KYC
KYC/AML (Know Your Customer and Anti-Money Laundering) compliance is mandatory on many exchanges. For regulatory reasons, each person must submit identity documentation and proof of address.
For some, it's a privacy issue, and for others, it's an accessibility issue. What if you don't have valid documents? What if the information is leaked? Well, because DEX is permissionless, no one checks your identity. All you need is a crypto wallet.
However, there are several legal requirements that must be met if the DEX is partially run by a centralized authority. In some cases, if the order book is centralized, the host must remain compliant.
No counterparty risk
The main attraction of decentralized cryptocurrency exchanges is that they do not store user funds. Thus, even catastrophes like the hacking of Mt. Gox 2014 will not endanger user funds or reveal sensitive personal information.
Unlisted tokens
Tokens that are not listed on a centralized exchange can still be traded freely on DEX, as long as there is supply and demand.
Against DEX
Usage
In fact, unlike traditional exchanges, DEXs are not nearly as user-friendly. The centralized platform offers real-time trading that is not affected by block times. For newcomers unfamiliar with non-custodial crypto wallets, CEX provides a simpler and more helpful experience. If you forget your password, you can reset it. However, if you lose your seed phrase, your funds will be lost forever in cyberspace, irrevocable.
Voume trading in likuiditas
The volume traded on DEX is still smaller than CEX. Perhaps more importantly, CEXs tend to have greater liquidity as well. Liquidity is a measure of how easily you can buy or sell an asset at a fair price. In a highly liquid market, bid and ask have a small price difference, indicating high competition between buyers and sellers. In an illiquid market, you will have a harder time finding someone willing to trade assets at a reasonable price.
DEXs are still relatively unfamiliar, so, there isn't always supply or demand for the crypto assets you want to trade. You may not be able to find the trading pair you want to use, and if you do, the asset may not trade at a reasonable price.
Cost
Fees are not always higher on DEXs, but they can be, especially when the network is congested, or if you use an on-chain order book.
Conclusion
Many decentralized exchanges have emerged in recent years, each repeating previous efforts to simplify the user experience and build more robust trading tools. Ultimately, the idea seems perfectly aligned with the ethos of self-sovereignty: as with cryptocurrencies, users don't need to trust third parties.
With the rise of DeFi, Ethereum-based DEXs have seen a huge increase in usage. If this momentum continues, we will likely witness increased technological innovation across the blockchain industry.
➠ Do you have questions about the exchange? Visit Ask Academy!

