Learn everything about decentralized exchanges: How do they work, which variants are there, and which exchanges are trustworthy at all?
Ever since the Bitcoin revolution began, crypto exchanges have played an essential role in bringing cryptocurrency buyers and sellers together. Without these forums attracting a global user base these days, there would be much less liquidity and no way for buyers and sellers to agree on a suitable price of assets.
Traditionally, outside of cryptocurrencies and just in terms of equity trading, centralized players have dominated this field. But just in the last decade, new technologies have been developed that, together with a growing number of tools, have made decentralized trading possible.
Reason enough to take a closer look at “Decentralized Exchanges” (DEX) and shed more light on what a decentralized exchange is, and which reputable providers define the market.
What is a decentralized exchange? – Definition and explanation of a DEX
Decentralized exchanges (often referred to as “DEXs”) are autonomous decentralized applications (dApps) that allow buyers or sellers of cryptocurrencies to trade cryptocurrencies without having to relinquish control of their assets to an intermediary.
This type of infrastructure is completely different from traditional centralized exchanges, where users hand over their assets to the crypto exchange, which acts as a custodian and essentially issues promissory bills that users can trade on the platform.
DEXs were originally designed to eliminate the need for an authority to oversee and approve trading within a given exchange. Using intelligent contracts (also called smart contracts), DEXs operate automated order books and trading operations. This makes them “true” peer-to-peer platforms with no third-party providers.
How do decentralized exchanges work?
In a typical centralized exchange, the asset in question is directly deposited – either in fiat (via bank transfer or credit/debit card) or in cryptocurrency. When cryptocurrencies are deposited, users lose control over them – although not from a usage standpoint, because of course cryptocurrencies can still be withdrawn and traded. However, control is lost from a technical standpoint: the cryptocurrency in question can no longer be spent on the blockchain.
Of course, this brings security risks: the team behind the crypto exchange could disappear along with the many crypto assets. A hack could also cause the assets to disappear. For many users, however, this is an acceptable risk, as they simply stick to reputable, well-known exchanges with a solid track record and precautions to prevent data breaches.
Decentralized exchanges are quite like their centralized counterparts in some respects but differ greatly in others. It is important to note that there are a few different types of decentralized exchanges. What they all have in common is that orders are executed on a blockchain (using smart contracts) and that users do not have to give up custody of their funds at any point.
There are a few variants to cross-blockchain DEXs, but the most popular variants revolve around assets on a single blockchain (like Ethereum or Binance Chain).
Decentralized off-chain exchanges
Off-chain DEXs are still decentralized in some ways, but they are admittedly more centralized the on-chain variants. Namely, instead of each order being published on the blockchain, it is hosted in a fixed location.
Where exactly that location is depending on several factors: Off-chain exchanges may have a centralized entity that fully manages the order book. If this entity is malicious, it could manipulate the markets to some degree (for example, by so-called front running or misrepresenting orders). However, users would still benefit from non-custodial storage.
The 0x protocol for ERC-20 and other tokens used on the Ethereum blockchain is a good example of this. It does not act as a singular decentralized exchange but provides a framework for parties known as “relayers” to manage off-chain order books.
Trading off the blockchain
Using 0x smart contracts and various other digital tools, hosts can access a combined liquidity pool and route orders between individual users. Trades are not executed on the chain until the parties are matched.
These approaches are much better than those that rely on “on-chain order books,” particularly in terms of usability. They are not subject to the same speed constraints because they do not make such heavy use of the blockchain. However, trades must still be processed through the blockchain, so the off-chain order book model is still inferior to centralized exchanges in terms of speed.
Decentralized on-chain exchanges
In some of the decentralized exchanges, all orders are executed directly through the blockchain. Thus, every order is written directly to the blockchain as are cancellations and modifications. This is the most transparent approach, as users do not have to rely on a third party to forward the orders. In addition, there is no way to obfuscate the orders. Unfortunately, it is also the most impractical option.
Namely, since every node in the network is required to record a particular job forever, users must pay a fee. In addition, users must wait for a miner to post the message to the blockchain, which can also be tedious and takes time.
Front-running as a problem
Some see front-running as a sometimes-major vulnerability: front-running occurs in markets when an insider knows about a pending transaction and uses that information to place a trade before the transaction is processed. The “front-runner” thus profits from knowledge that is not available to the public. While this is illegal, it is not always easy to prove.
Of course, if everything is published in a global ledger, there is no possibility for a front-run in the traditional sense. However, another type of attack can be carried out: For example, a miner sees the order before it is confirmed and ensures that his own order is added to the blockchain first.
Decentralized Exchanges and Automated Market Makers (AMM)
Automated market makers have been particularly popular since 2020 and contributed significantly to the DeFi boom. They are used by many popular DEX platforms because AMMs do not require traditional order books. Instead, they use smart contracts to create liquidity pools that automatically execute trades based on certain parameters.
The AMM-based DEXs available today tend to be relatively user-friendly and integrate with most popular wallets such as MetaMask. However, as with other forms of DEXs, an on-chain transaction must be executed to settle the trade.