How Decentralized Exchanges Enable Trustless Trade on Blockchain Networks
For the longest time, people used to trade tokens and cryptocurrencies in centralized exchanges.
It was convenient: the exchanges matched and executed orders automatically and provided a processing speed which most blockchains could never pull of – not with their complex block validation.
But, at the same time, they were vulnerable as, in fact, all centralized databases are.
ShapeShift, Cryptsy, Colbitex, Coinflip… it’s hard to even to count all the traditional exchanges that either fell victim to hacking or were shut down by regulators over the last few years. And this caused utter panic; people lost millions of dollars worth of crypto assets.
Now, the conventional trading procedure, which cryptocurrency enthusiast are so familiar with, is about to be redefined. There are hundreds of new tokens on blockchains, spawned predominantly by the ICO craze, and soon we may be trading them, securely and hassle-free, using decentralized exchanges (DEXs).
Decentralized Exchanges on Ethereum
On the Ethereum network, where most of the new tokens are traded, there now exist a few types of decentralized exchanges. They all share one trait – using smart contracts to execute settlement – but differ in how they approach maintaining orders.
- A person submits a (buy/sell) request to a relayer which hosts an order book (which can be administered in a centralized or decentralized fashion)
- An interested party on the other end digitally signs it and creates a counterorder
- Both orders are then sent to a smart contract on Ethereum, which executes the transaction and transfers crypto assets between users’ wallets.
[Tweet “Unlike centralized exchanges, DEXs let users have control over their crypto assets at all times”]
Unlike centralized exchanges, DEXs let users have control over their crypto assets at all times: they give out personal keys and allow a buyer (or a seller) to retract their funds from a smart contract should they change their mind and decide not to proceed with a transaction.
They resolve risks of hacking and scrutiny from regulators, which centralized exchanges are so prone to, by having smart contracts take care of order clearing. They also enable global trade, as anyone in any country could post to their order books, and reduce the friction of the procedure by eliminating registrations and signups.
As of now, decentralized exchanges are typically designed as frontend apps (see EtherDelta). However, in the not-too-distant future, experts say, they might only have programmatic interfaces and become mere nodes in p2p networks that match orders with other orders.
Unlike EtherDelta that just has one relayer service and an order book that it fully controls, decentralized exchange protocols, like 0x, allow anyone to become a relayer and set up their own exchanges.
These relayers can then collect fees for matching orders – the process similar to mining, but designed to facilitate the trade of different tokens.
Besides, there are exchanges on Ethereum that avoid the order book functionality altogether. KyberNetwork, for example, has introduced a solution that allows people to send a token in and get another one out without a relayer, anonymously.
The company will maintain reserves of various tokens and cryptocurrency, to which anyone will be able to contribute, and thus ensure tokens’ liquidity. It plans to be the sole manager of these reserves initially, regulating the exchange rates and listing or delisting tokens, but claims to give administrative rights to others too as their reserves grow bigger.
To become a reserve manager though, one will have to go through a KYC process with KyberNetwork, which to some might seem a bit off-putting.
What are the Drawbacks of Using Decentralized Exchanges?
It is still early days, and though the concept indeed seems promising, the adoption of decentralized exchanges has not been large-scale yet. There are quite a few risks associated with the technology, which its developers should think through carefully, and, mostly, the hidden dangers are related to potential arbitrage and frontrunning.
Since automated matching on the majority of decentralized exchanges is sacrificed for the sake of security, things might occasionally get out of sync. For instance, an order might appear valid in an off-chain orderbook, when, in fact, it’s already been fulfilled on the blockchain. This might result in your paying a gas fee for submitting an order to the network and losing funds for nothing when it fails.
Arbitrage, as we’ve mentioned, is one of the primary concerns too. In the light of constant fluctuations on the crypto market, and the fact that users are unable to cancel transactions instantly, there is a temptation for bad actors to fill and manipulate stale orders to their advantage. When you attempt to call off a signed order, you must submit a cancellation transaction to the blockchain, which means paying a gas fee to miners for the execution. But an arbitrageur can beat you to it; they can offer more gas to validators and thus get ahead of you in the transaction race.
Miners, too, can act maliciously. Since all of your canceled orders are visible before the transaction takes place, validators can execute them with themselves as a counterparty. So, a token you wanted to buy yesterday, but that has become worthless today, might still be sold to you by a dishonest miner, even though you canceled the deal. And you’ll still have to pay a gas price for the failed cancellation.
With new tokens being poured into the blockchain ecosystem at a frenetic pace; with centralized exchanges’ being unsafe and refusing to list them, it’s obvious that there is now a market fit for DEXs. We should, therefore, expect to hear new loud names entering the exchange game presently, and, since the competition is firing up, the new cool tech that’ll have all the systemic issues fixed will certainly be developed soon too.
Thinking to launch your company’s own decentralized exchange? Reach out to us for a free consultation; we can help you bring your idea to life.