A DEX is a decentralized exchange, and is essentially a new type of pair matching that allows people to place orders and trade cryptocurrencies without an intermediary institution managing the ledger or controlling user funds.
Cryptocurrencies excited a lot of people because they created a way to trade value without the need for intermediaries. Blockchain technology allows strangers to trust one another without the need for a central institution. It’s an amazing technology with the potential to change the way we structure our economy and the way we think about trade.
The challenge, of course, is in order to enter the ecosystem you need to purchase some cryptocurrency using a currency you already have (dollars, euros, etc). Typically, you’d do so at one of the major exchanges, like Coinbase or Kraken. However, those are both centralized institutions.
They take your information, manage your accounts, and are vulnerable to slowdowns or outright attacks. Using centralized exchanges to buy cryptocurrency is an ironic experience. In order to enter a trustless, decentralized ecosystem, you have to trust a centralized institution.
DEXs seek to change that experience, offering users ways to find one another and trade directly on-chain. No major DEX has a fiat gateway so far, but many competitors have built decentralized exchanges that allow for crypto-to-crypto trading.
In order to understand DEXs, it’s important to realize that cryptocurrency exchanges exist on two basic axes: custody and centralization.
Custody refers to who holds the cryptocurrency on the exchange. When you buy a Bitcoin on Coinbase, for example, it shows up in your Coinbase account, but you don’t actually own and control that Bitcoin yet. You need to request a transfer off Coinbase to an external wallet address that you control before the Bitcoin is really yours. If Coinbase is attacked, slowed down, or has technical issues, you don’t have recourse to secure your Bitcoin.
A non-custodial exchange leaves all funds in the private wallets of its users. Users can then submit and confirm trades on their own from their personal wallets, essentially using the exchange as a matching service. An in-between solution involves users submitting funds to open source, verified smart contracts that execute when a match is made and can be canceled at any time. This has the advantage of security and automation, but there is a period of time where funds aren’t in users’ wallets. If there’s an issue with the contract, the funds could disappear.
Centralization refers to where the order matching, routing, and execution take place. In a centralized exchange, there’s a proprietary order book that reviews all incoming orders and creates matches between users. The exchange software and servers then execute the transaction.
Decentralized exchanges operate on a network of computers. Some function directly on-chain through the use of smart contracts. Others rely on second-layer networks of trusted nodes, known as relayers, to find and make order matches.
Benefits of DEXs
Trading on a DEX comes with many benefits that make it attractive to cryptocurrency users. Most importantly, DEXs disintermediate the exchange ecosystem, removing middlemen and allowing free, direct trade between parties. This fits with the decentralizing philosophy and mission of crypto generally.
But there are other benefits to DEXs that users might also find attractive:
Since DEXs in their purest form use only blockchain information, all you need to share in order to use a DEX is a public address. Most centralized exchanges require a complete signup process with name, email, and even bank account information. Even anonymous crypto-to-crypto exchanges still require location information and other personal details to comply with government regulations and restrictions.
That said, if DEXs come to greater prominence, they’ll likely meet up against regulators. Most DEX creators plan to say they’re only releasing open source software and are not liable for what the community does with that software, thus avoiding the KYC and AML issues. However, it remains to be seen if that argument holds up legally long-term, especially if damages result from a poorly written smart contract or security flaw.
- Control of Funds
DEXs are generally, but not necessarily, non-custodial. As a result, users keep control of their funds throughout the entire transfer process until the moment of exchange, when a smart contract executes the signed trade. Keeping your funds safe is your own responsibility of a DEX.
- Complicated to attack
Since a DEX exists across a network of computers, it becomes much more complicated to attack. There’s no single point of entry or failure. This makes DEXs exponentially more secure. It also makes them more difficult to design and test, which is one of the reasons why DEX development has been slow to date.
- Less chance of going down
Because there’s no single point of failure in a distributed exchange, there’s less chance of DEX going down. Rollouts of updates happen on a node-by-node basis. Even if individual nodes have to go down due to maintenance or an attack, the remaining nodes can still operate the exchange network.
Drawbacks of DEXs
DEXs are inherently more complicated than their centralized counterparts. This leads to challenges in implementation and usability that major DEXs have yet to fully address.
The first and biggest challenge is user-friendliness. Creating an account on a major centralized exchange is a fairly straightforward process, and it functions much like banking and brokerage applications that users are familiar with. On the other hand, using a DEX requires connecting to a dapp or even installing a standalone DEX client.
At its simplest, you may only need to set up a MetaMask wallet, fund that wallet, then connect with an Ethereum-based DEX dapp. At its most complicated, you might have to set up an independent node and stay online for long periods of time to sign transactions.
- Simplified Trading Tools
Centralized exchanges offer advanced tools like options and margin trading. These simply aren’t possible for today’s DEXs. Trading on a DEX typically includes buy or sell orders only.
- Low Liquidity
DEXs represent about one percent of the cryptocurrency market’s trading volume. As a result, only low volume trading of popular coins is possible. There’s not enough liquidity to allow for high-volume trading, and there are no centralized institutions providing market maker services.
When you make a trade on an exchange, you want as close to instant execution as possible. Otherwise, you could miss out on a price change. Unfortunately, DEXs so far have shown slow cancelation and slow order processing times, since all requests have to propagate across the decentralized network. As a result, price slipping–price changes between order time and execution time–is common.
Because you must broadcast your intentions to the entire network in order to execute a trade, it’s possible for bad actors on the network with fast connections to jump ahead of you in line and buy up coins at a lower price in order to sell them back to you. Known as front-running, this practice undermines the fairness of the exchange. There’s no real way to make sure miners or relayers on a decentralized exchange can’t jump in line for orders. Currently, DEX creators are working on potential solutions that involve signatures or collateral.
The Future of Decentralized Exchanges
There are still major technical hurdles facing DEXs moving forward, and complete decentralization isn’t possible. Most likely, a hybrid model will prevail where the speed and front-running protections of a centralized order book meet the security and non-custodial nature of decentralized solutions.
Atomic swaps, Lightning, and other layered solutions will make the transition and hybridization easier. It’s also still unclear the role regulation will play in all this, and perhaps exchanges will still need centralized authorities to collect KYC information and answer to government regulators.
Ultimately, the technology behind today’s DEXs will drive a wave of innovation in the ways coins get traded. We’ll see fewer security issues as exchanges diversify their network of nodes and greater coin custody for exchange users. The perfect DEX is probably imaginary, but if development continues, we’ll get a lot closer to fair, fast, cheap, and secure coin trading.