- Also known as a DEX
- For a history on crypto currency exchanged up until 25-8-2020, check out this post by Coin Metrics.
- Opposite of a CEX
- From DeFi Rate:
"Decentralized exchanges allow users to swap their digital assets without having to transfer custody of the underlying collateral. DeFi DEXs aim to provide trustless, interoperable trading across a wide range of digital asset markets. Depending on the specific DEX in question, users may benefit from anonymous transactions, automatic order matching and/or profit sharing."
- Decentralized exchanges have the potential to offer advantages over centralized systems such as real-time settlement, reduced counterparty risk, censorship-resistant transactions, and transparent technology.
- From this blog post by Komodo (29-10-2019):
"With a decentralized exchange (DEX), your funds are always in your custody, thus eliminating the security issues that plague centralized exchanges. This means your funds are in your control and remain much more secure. Real decentralized exchanges must also be permissionless because, if a DEX requires users to receive permission, then there must some centralized entity controlling it.
Users never need to deposit or withdraw funds to trade on a true DEX. On top of that, DEXs provide better privacy, transparency, and censorship-resistance, and allow unlimited trading pairs using technologies like atomic swaps. With atomic swap technology, traders can make cross-chain exchanges between any two listed assets."
Requirements of a 'true' DEX
- Komodo wrote a blog about what a Decentralized Exchange needed to be 'truly decentralized'. And of course it put itself as the only true one at the end. However, it still gave some good points:
"There are at least 4 core requirements that an exchange must meet before we should consider it “decentralized.” This is not an exhaustive list and these core requirements will surely evolve over time as blockchain technology continues to evolve, too. But it’s still useful to have criteria in place to help us evaluate the degree of decentralization of DEX projects.
The 4 core requirements of a DEX are that it must be:
1. A DEX must be non-custodial.
Traditional crypto exchanges are custodial, meaning that they take custody of users’ funds before those users can make trades. On one level, this makes sense, as it ensures that users are not making trades with assets they don’t actually have.
In many other ways, this system makes very little sense. It completely undermines the ethos of decentralization on which the blockchain industry was founded. Centralized digital asset exchanges are replacing big banks and becoming the powerful middlemen of the blockchain industry.
The centralization of digital asset trading has also introduced major security vulnerabilities, which hackers have gladly taken advantage of. In 2018, hackers stole an incredible amount of wealth: estimates range from $877 Million to $950 Million all the way up to a cool $1 Billion. To date, the trend has held strong in 2019. Malicious hackers continue to rob both exchanges and everyday holders of digital assets blind. An estimated $227 Million has been stolen from centralized exchanges thus far in 2019. In other words, centralized exchanges are the perfect target for malicious hackers and they are consistently hacked for tens of millions of dollars. This is a global, industry-wide problem that demands our immediate attention.
These huge heists have a number of negative consequences. They lead to losses for ordinary holders. They also generate a great deal of negative coverage in the mainstream media, damaging the reputation of the industry as a whole. Lastly, they inhibit the adoption of blockchain technology more generally, as many people are reluctant to get involved in an industry that seems extraordinarily risky and insecure.
Decentralization is the solution. If every trader holds their own assets in their own wallet, there are never any massively lucrative wallets to target in the first place. Hackers can target individual users if they want, but that is true in all circumstances. In fact, it has been true since the advent of the Internet.
The blockchain industry must shift towards decentralized trading for its own survival. And for an exchange to be a true DEX, it must never take control of users’ funds. Each trader must retain control of his/her private keys throughout the entire trading process.
2. A DEX must be both a cross-chain and on-chain protocol.
An cross-chain swap is one that is made between two different blockchains. For example, if Alice trades 1 BTC to Bob in exchange for 150 LTC, this would be a cross-chain swap. The swap is occurring across two different blockchains.
Many DEX projects fail to meet this condition because they are designed exclusively for the Ethereum ecosystem. Users may be able to make swaps between tokens built on the Ethereum blockchain, but they cannot make swaps across different blockchains. For these token DEXs, there is no way to swap ETH or an ERC token for BTC or an asset of another protocol like, say, XMR or EOS.
As the name suggests, an on-chain swap is one that occurs on the blockchain’s ledger. This means that the transactions are submitted to and verified by each blockchain’s decentralized network, from each trader’s personal wallet.
This stands in contrast to a number of so-called decentralized exchanges, which actually settle trades through centralized order-matching nodes or smart contract accounts before submitting the transaction to any blockchains. In both cases, the swaps are not made on-chain. Rather, there is someone or something in the middle helping to facilitate the trade.
This structure reduces the decentralization of the exchange itself, since two individual traders are not transacting directly with one another. It also inevitably leads to additional security vulnerabilities and an increase in fees.
For instance, whenever swapping an ERC token, you must pay gas fees in ETH. This is true even if you're swapping an ERC token for a BTC protocol coin. Gas fee payments aren’t a flaw with any particular DEX protocol as much as they are one of the limitations of smart contract platforms in general, but this fact still makes smart contract DEXs inconvenient and costly from a user’s perspective.
Exchanges that allow on-chain trades are more decentralized, secure, and cost effective. They are also much harder to develop. That’s one of the primary reasons that many DEXs use off-chain order matching before settling the swap on-chain. But to be considered a true DEX, transactions must take place on-chain, even for assets from different platforms and protocols.
3. A DEX must be permissionless.
For a DEX to be truly decentralized, it must be permissionless. In other words, you shouldn’t need to be granted permission by a central authority to make trades on a true DEX.
There are two different dimensions to this idea of permissionless use.
First, a DEX must be accessible to everyone, regardless of their nationality or geographic location. If a DEX is actually decentralized, it is both theoretically and practically impossible to block anyone from using it. Some people refer to this property as “censorship resistance.”
Location-based censorship is already becoming a reality. For example, in July 2019, GitHub began locking the accounts of developers in Iran, Syria, North Korea, Cuba, and Crimea. In a statement to ZDNet, a GitHub spokesperson said that "GitHub is subject to US trade control laws, and is committed to full compliance with applicable law.”
Censorship of this nature would not even be possible on a truly decentralized exchange. And this would not create regulatory compliance problems because a true DEX is not subject to trade control laws. A true DEX is open source software that anyone can download and use.
The second dimension of permissionless software is the absence of registration processes. Users should never need to enter personal data or submit “know your customer” (KYC) documents, such as government identification, proof of employment, or bank records.
If an exchange is truly decentralized, then there is no central authority to decide who may or may not use the DEX. There is no central authority to collect user data and KYC documents to begin with. Any exchange that requires KYC is permissioned and therefore not decentralized.
A truly decentralized exchange is not a business, legal entity, or even an organization. A real DEX is simply a digital marketplace that connects individuals and allows them to transact with one another in a secure, fully peer-to-peer manner.
4. A DEX must be asset agnostic.
A truly decentralized exchange must allow direct trading trading between any two listed assets.
Most exchanges only offer a two or three trading pairs for each asset and those trading partners will inevitably be BTC, ETH, and perhaps a stablecoin. While Bitcoin and Ether have hundreds of trading pairs, most other assets have just two or three pairs.
There are several reasons why an exchange would want to limit the number of trading pairs each listed asset has. First, it quickly becomes much more difficult to manage all order books and trade settlements if every listed asset can be traded with any other.
With 6 listed assets, there would be a total of 15 trading pairs. With 15 listed assets, there would be 105 trading pairs. With 105 listed assets, there would be a 5,565 trading pairs. With 150 listed assets, it would be a whopping 11,325 trading pairs. This quickly gets out of hand.
There are now more than 2,000 different digital assets listed on CoinMarketCap so listing a few hundred of them on a single exchange is not unreasonable. In fact, many exchanges already support more than 100 assets. But it would be impossible for a centralized exchange to maintain active markets if there were tens of thousands of possible trading pairs.
Another reason that exchanges restrict trading pairs is to ensure ample activity and liquidity for all pairs offered. It would be extremely difficult to guarantee liquidity for thousands or tens of thousands of markets. Instead of taking on this enormous task, centralized exchanges simply corral traders into a limited number of trading pairs so that liquidity remains reasonably high.
However, for an exchange to be truly decentralized, it should not even have the ability to decide which trading pairs are accessible and which are not. A DEX must act as a free and open marketplace, allowing users to trade between any two listed assets. There may not be a willing counterparty to every trade offer but, at the very least, users have the freedom to post their desired offer in the first place."
- The founder of IDEX also made his own list of what a "Fully-Decentralized" would need (11-2019):
- "Orderbooks would be entirely on-chain; placing and canceling orders would be slow and cost gas
- There would be no website to visit; users would be required to download (from a P2P system like BitTorrent) and compile a front-end interface locally
- There would be no customer support; users would be on their own to troubleshoot issues
- There would be no fees (a temporary benefit to the user but one that prohibits further development)
These changes would certainly kill both the product and the business. Most everyone acknowledges that “DEXs” with on-chain orderbooks are currently impractical, while the other changes would make the UX too complex for anyone but advanced users."
A couple well known DEX's
- The top 3 AMMs account for nearly 90% of trade volume among DEXs (6-10-2020).
- "There are approximately one hundred decentralized exchange protocols in development (10-2019) or available for live trading. However, there are many projects calling themselves a decentralized exchange are not actually decentralized."
- The most used 'DEX' on Ethereum as of 8-2019 was IDEX, with 51%. However, their own founder said back in 11-2018: "IDEX is not a “DEX” in its current state. At this point the best way to describe IDEX is as a “non-custodial” or “hybrid-decentralized” exchange. But this semantics issue is by no means unique to IDEX. We believe that no DEX is decentralized. As long as a project has a website, off-chain orderbook, or known team, they are not “fully decentralized.”"
- Komodo wrote a blog (29-10-2019) about its own (AtomicDEX) and 7 other (0x, IDEX, Waves, Loopring, Kyber Network, Decred and Nash Exchange) DEX's.
From the Token Economy newsletter (7-2019):
- Uniswap uses pooled liquidity reserves and a constant product market-making formula. In less abstract terms that means that liquidity providers can add tokens to pools and others can then trade directly against those pools with the smart contract as their counterparty. Liquidity providers earn fees from trades done against the liquidity pool they supplied to. The benefit of this model is that it’s very easy to use as neither liquidity providers nor traders need to find a counterparty to use the system. The downside is that traders sometimes experience significant slippage and that being a liquidity provider is not always as profitable as one might hope.
- On the surface, Kyber Network appears similar to Uniswap as both allow users to easily swap tokens. There are, however, some important differences. Kyber offers users liquidity through various reserve pools that are managed by both Kyber and other parties. The user gets the price from whatever pool that offers the best rate. There are requirements for starting a pool and they can be managed in different ways. While on Uniswap anyone and everyone can supply to the same pool and prices are set by a formula. Furthermore, Kyber is making it very easy for other dApps and apps to integrate Kyber into their products.
- 0x is a protocol for trading with smart contracts. While they offer various products on top of their core protocol they are most known for having a range of relayers that keep order books off-chain and then the actual trades are settled on-chain. This is the model that looks most similar to traditional exchanges. Challenges with this model have been unclear regulatory environment and a lack of liquidity.
- The DutchX uses the dutch auction principle for trading tokens. Even though this model is less well known than the others the mechanism is actually not that complicated: the seller begins the auction with a high asking price for a set quantity of a token and then the price goes down over time. At each point in time bidders can buy a desired amount of tokens at the current price. When bidders have bought the full amount of tokens for sale in the auction every buyer pays the lowest (/last) price. The DutchX mechanism removes some challenges like no front-running and slippage due to low liquidity. The main issue with this model is that it is slow: each auction takes about 6 hours to clear.
- Balancer, SushiSwap and Curve are in the top (for liquidity) together with Uniswap (10-2020).
Automated best prices across DEX's
From the Token Economy newsletter:
- Totle Swap; Instant token swap at the best price across all DEXs.
As anticipated back in May, the Totle team have released a dead simple interface for exchanging ERC-20 tokens that automatically goes off and fetches the best price available from decentralized exchanges they integrate with, hiding all those complexities in the background. The very cool thing here is that the user submits one single transaction and the Totle smart contract executes multiple buys and sells over multiple DEXs.
Ethereum token swap aggregator with best possible price achieved by splitting volume among DEXes inside single transaction. This is a project born over a weekend at the latest ETHNewYork hackathon and, along the same lines as Totle Swap, it automatically splits up a token swap transaction across multiple orders over several integrated DEXes (eg UniswapExchange, KyberNetwork, Bancor and RadarRelay) in order to minimize price slippage. By using the Gas Token they are also able to bring down tx costs.
High Gas Prices
"One of the primary motivations for paying high gas prices for orders is to realize an arbitrage opportunity. One of the aspects of DEXs on Ethereum that makes them different from centralized exchanges is the ability of DEXs to support atomic arbitrage. This means that multiple DEX trades can be combined into 1 transaction, so when a trader sees mispricing between two DEX protocols, they can fill all the relevant orders at once. For centralized exchange arbitrage, the trader would have to communicate with each relevant exchange and fill orders separately.
This sounds great for the arbitrageur until you factor in competition. Other bots see the same trade and will race to fill the orders. What results are gas price battles to incentivize miners to include your transaction over those of other traders. Given competition, we would expect most of the arbitrage opportunity in the trade to accrue to miners in the form of gas fees.
Arbitrage trades are often not beneficial to market makers. Market makers seek to profit from a spread above the market price. The fact that an arbitrageur is taking your order often indicates that it has become mispriced. One feature of protocol fees in [0x Protocol] v3 is they result in sharing some of this arbitrage opportunity with the market makers. This, in turn, should make market makers more comfortable offering tighter spreads, since they accrue some of the arbitrage gains if their orders become mispriced.
Indeed, we [0x Protocol] see that the highest protocol fees paid thus far have been paid by contracts that we have labeled as arbitrage bots."