Decentralized exchanges allow users to swap cryptocurrency assets by using smart contracts and on-chain transactions to reduce or eliminate the need for an intermediary. In this post we’ll explain the differences between centralized and decentralized exchanges, go-into how decentralized exchanges work and analyze the different models that exist. For those who are not interested in those explanations but just want to know the top decentralized exchanges, we have compiled a shortlist below.
Some of the most popular decentralized exchanges are:
To initiate a trade within a centralized exchange you first have to deposit the funds that you want to trade (fiat or crypto) which are then held in custody by the exchange. After you have deposited funds with the exchange your account balance is credited by the amount you deposited and you are eligible to make a trade.
Let’s say your account was credited with US dollars and you now want to buy Ether. To do that, you have to create a buy offer indicating how many US dollars you are willing to bid for the amount of Ether you wish to purchase. This buy offer, once submitted, is added to the exchange’s order book. Simply put, an order book is just a list of buy (bid) offers and sell (ask) offers for a given trading pair (e.g ETH/USD).
BTC/EUR order book as seen on Blockchain.com
The exchange then uses a piece of software called a matching engine to match your buy offer with a corresponding sell offer. If you are willing to buy one Ether for $200 and there is a seller willing to sell one Ether at that price the two orders will be matched and executed. My account will be credited with 1 Ether and debited $200 and the sellers account will be debited by one Ether and credited $200.
The whole logic is orchestrated on the centralized servers of the exchange and it’s important to understand that this is happening off-chain, meaning it’s happening within the exchange and doesn’t involve the Blockchain! Only when you withdraw Ether from your exchange’s account to your Ethereum wallet or to another exchange where you have an account, a transaction will be submitted to the Blockchain.
While Centralized Exchanges (CEXs) like Kraken or Coinbase are convenient to use, allow for fiat deposits, large trades and plenty of liquidity, it’s easy to see why some people are uncomfortable using them. Here’s why:
Centralized exchanges carry a lot of risk because users do not have ownership of their assets in exchanges. In 2019, over $290 million worth of cryptocurrencies were stolen and over 500,000 login information were leaked from centralized exchanges.
Moreover, centralized exchanges are operated by companies, which evidently have to abide by regulations in the countries they operate in. This means that they have to identify users, freeze account balances if requested by authorities and do many other things that come with being regulated.
Another drawdown of centralized exchanges is that if a new project wants to list their token they have to pay a listing fee to the exchange. Decentralized exchanges allow projects to create a market for their token on a decentralized exchange without asking anyone for permission.
Lastly, centralized exchanges can not be used in certain applications where decentralization is a crucial feature. That’s why decentralized exchanges are necessary building blocks for Decentralized Finance (DeFi) applications built on Ethereum. If, for instance, the Ether collateral backing a Compound loan drops in value, the Compound protocol would need to liquidate the Ether in order for the protocol to stay solvent.
If the Compound protocol had to sell these assets on Kraken, the Compound protocol would no longer be truly decentralized as it would be trivial for Kraken (or a government) to manipulate the protocol. A decentralized app simply can not rely on a piece of centralized infrastructure if it wants to remain decentralized!
Now that we have established how centralized exchanges work let’s look at decentralized exchanges and how the two differ from one another.
First, the backend that powers the exchange is not hosted on a centralized server. Instead, the core logic is programmed into smart contracts that exist on the Blockchain and the code is open-source so anyone can audit it or fork it.
It is therefore not uncommon for a DEX to have multiple user interfaces. Anyone with a solid understanding of how these smart contracts work can create their own frontend implementation. For example the Kyber Network has its own frontend at kyberswap.com/swap but is also accessible through InstaDapp, Argent and many other wallets and DeFi projects.
Second, decentralized exchanges are non-custodial, meaning that you initiate the trade using your own non-custodial wallet and remain in control of the funds throughout the whole trade. Your funds are not held in custody by the exchange. All you need to use a decentralized exchange is a wallet. They require no sign-up, identification or similar procedure. This also means anyone can use it, regardless of their geographical location.
Lastly, because decentralized exchanges are decentralized, you will not be able to deposit fiat or buy crypto with fiat. You can only swap assets that are on-chain like for example ETH for DAI. The only exception to this rule is when a decentralized exchange is integrated into a wallet like Argent or Authereum/, which offers fiat deposits through a partnership with a payment processor. However, this is a service that is completely separated from the decentralized exchange.
There are two kinds of DEXs - order book-based DEXs and liquidity pool-based DEXs.
However, one of the biggest problems facing order book-based DEXs is liquidity and transaction throughput. Speed matters a lot for order-book exchanges because traders want to update their offers frequently when prices fluctuate. However, since updating their offers requires broadcasting a transaction to the Ethereum network, the whole process is rather slow and costly compared to centralized exchanges. Likewise, users may have to wait a long time for their orders to be filled in the order book if the network is congested. That being said, order-book based decentralized exchanges like DyDx and DexBlue have improved a lot in the last few years and there are a lot of technologies like Optimistic Rollups on the horizon to seep up Ethereum transactions.
To solve some of the issues with order-book decentralized exchanges, liquidity pools-based DEXs were introduced. Liquidity pools are essentially reserves of tokens in smart contracts and users can buy or sell tokens instantly from the available tokens in the liquidity pool. The price of the token is determined algorithmically.
Because Liquidity pools are so different from traditional exchanges it’s worth taking a closer look at them.
The particular pricing algorithm used by Uniswap is called the Constant Product Market Maker Model. It was pioneered by Uniswap and is now studied by finance scholars outside of the crypto space. In a nutshell, it ensures the value of each reserve stays constant even as the ratios of the assets in the liquidity pool change.
If you want to buy ETH using DAI through Uniswaps’ ETH-DAI liquidity pool containing 1000 ETH and 100,000 DAI at the time of your purchase, you may send 100.01 DAI to the Uniswap smart contract to get 1 ETH in return. Once the swap has taken place, the liquidity pool is left with 999 ETH and 100,100.01 DAI and the price for ETH will be slightly higher for the next person wanting to buy.
If the Uniswap price for ETH differs from the price on other exchanges (e.g Coinbase), there’s an opportunity for traders to arbitrage. Let’s say the price for ETH on another exchange is 150 DAI. People would naturally buy ETH on Uniswap for DAI to profit from this relatively cheaper price. This would add DAI and remove ETH from the liquidity pool, shifting the ratio until there’s no arbitrage possibility left. The moment the liquidity reserve would contain 122,550 DAI and 817 ETH the price would reach 150 DAI and be back in line with the rest of the market.
To finish, anyone can provide liquidity to a Liquidity reserve. Liquidity providers are paid a transaction fee of 0.3% per trade, which is shared amongst them to their share of the liquidity pool. If you’re interested in providing liquidity to Uniswap, the DeFi project Zerion provides a simple interface allowing you to do it in a very beginner-friendly way. They also wrote a tutorial post explaining how to do it.
Conclusion As you can see decentralized exchanges are fascinating from a technological standpoint. They are increasingly becoming a viable option for many crypto users. As we saw they have some downsides related to transaction speed but also many advantages over centralized exchanges. Today, many heavy crypto users rely exclusively on decentralized exchanges for their trading activity. Uniswap and Kyber for example each had more than $200m of trading volume in April 2020 and their volumes keep increasing each month.
They’re also becoming easier to use by the day and with the rise of DeFi they’re an essential piece of infrastructure. With scalability improvements and ETH 2.0 on the horizon we think the future is bright for decentralized exchanges.
I am passionate about Bitcoin and Ethereum and want to on-board new people to crypto.