2019: Year of DEX (Decentralized Exchanges)

Original author: Contractland
  • Transfer
Is it possible that the cryptocurrency winter season has become the golden age for blockchain technology? Welcome to 2019, the year of decentralized exchanges (DEX)!
Everyone who has anything to do with cryptocurrencies or blockchain technology is going through a harsh winter, which is reflected in the icy mountains on the price charts of popular and, not so, cryptocurrencies ( note : in the past they translated, the situation has changed a bit ... ). Hype passed, the bubble burst, and the smoke cleared. However, not everything is so bad. Technology continues to evolve and find a way to solutions such as decentralized exchange (the DEX - D ecentralized Ex change), which are designed to drastically change the ecosystem cryptocurrency in 2019.

What is a decentralized exchange?

You may be surprised. On centralized trading platforms, CEX (or Centralized Exchanges., Note: in the original CEX this is an abbreviation, do not mix with the name of the popular exchange CEX.io ), the owner of the platform is only an intermediary, a kind of crypto-banker. He is responsible for the storage and management of all funds that are traded on the platform. CEX is usually an intuitively simple and affordable platform offering high liquidity and a variety of trading instruments. The platform also acts as a gateway between fiat currency and crypto assets.

However, as crypto enthusiasts, we know what risks of centralization and trust in intermediaries exist, for example, the death of the founder of the Quadriga exchange and the loss of the keys to the wallet on which user funds were stored. In the case of a centralized site, it becomes a single point of failure or censorship.

The goal of DEX is to eliminate intermediaries and a single point of failure , by conducting transactions directly between users, on the blockchain itself, which lies at the heart of the platform, bypassing the trading platform. Thus, the main objective of DEX is simply to provide the buyers of the asset with the infrastructure to search for sellers and vice versa.

The main advantage of DEX over CEX is obvious:

  1. "reliability". There is no longer a need for an intermediary. Consequently, users themselves are responsible for their funds, not a centralized platform (whose director may die, keys may be stolen or hacked);
  2. since users are responsible for their funds and there is no intermediary in the form of a platform, there is no likelihood of censorship (deposits cannot be frozen and users are blocked), verification (KYC) is not required to gain access to trading opportunities, and all trading operations are “Anonymous”, since there is no “looking” and controlling body;
  3. and, more importantly, as a rule, in DEX you can make any type of exchange between assets (provided that the offers of the buyer and seller are the same), so you are not limited by the terms of the listing of instruments, as in CEX ( note : in the general case, this not so, here the author fantasizes a little and describes an exclusively idealistic picture, which is now possible only in conditions of the possibility of atomic swaps between chains );

But, as the old saying goes, " not all that glitters is gold ." Modern DEX technologies have challenges that still need to be addressed. First of all, DEX is currently not too adapted for ordinary users. It may be convenient for us specialists to use wallets, manage keys, seed phrases and sign transactions, but ordinary users are afraid of these kinds of things.

Moreover, since transactions are peer-to-peer, some exchanges require users to be online to fulfill their order (this sounds crazy, right?). UX is the main reason newcomers to cryptocurrency prefer to trade crypto assets with CEX rather than DEX. And as a result of the terrible UI / UX, DEX has low liquidity on almost all traded assets.

Again, in case you forgot this insignificant detail, transactions in DEX are peer-to-peer, so if you want to exchange BTC for LTC, you definitely need to find a client ready to exchange lightcoins for your proposed number of bitcoins. This can be a daunting task (to put it mildly) for certain currencies or if the number of DEX users is small. And now, all this, together with the limited performance of most DEXs (blockchains based on them), puts an insurmountable barrier to mass adoption by the market.

And so:

CEX (centralized):

  • Easy to use
  • Advanced Trading Opportunities
  • High liquidity
  • Opportunities for working with fiat currencies (trade, input / output)

DEX (decentralized):

  • Difficult to understand and use.
  • Only basic trading opportunities
  • Low liquidity
  • No ability to work with regular currencies

Fortunately, all these difficulties can be fixed, which is what new projects are trying to do. But more on that later, to begin with, consider the current situation. How are current DEXs created? There are three main approaches to designing DEX.

On-chain book of applications and calculations

This was the architecture of the first generation DEX. In simple words, this is an exchange, completely on top of the blockchain. All actions - every trade order, change of status - everything is recorded in the blockchain as transactions. Thus, the entire exchange is controlled by a smart contract, which is responsible for placing user orders, blocking funds, matching orders and executing a transaction. This approach ensures decentralization, trust and security, transferring the basic principles of the blockchain to all DEX functionality on top of it. ( note : in principle, this is a real decentralized exchange that fully complies with the spirit and essence of this approach. The disadvantage is that the implementations were on top of the first and imperfect blockchains. As an example of a good solution, we can cite BitShares and Stellar ).

However, such an architecture makes the platform:

  • low liquid - the system does not have enough volume for the instruments;
  • slow - the bottleneck in the execution of applications in DEX is a smart contract and network bandwidth. Imagine the work of a decentralized stock exchange on this principle;
  • expensive - each operation that changes state means the launch of a smart contract and payment of the cost of gas;
  • “By-design” is the inability to interact with other platforms, and this is a huge limitation.

What do I mean by the inability to interact? And the fact that in this type of DEX you can only exchange assets that are native to the blockchain and smart contracts of the DEX platform, if you do not use additional tools for cross-network connection. Thus, if we use Ethereum for DEX, then through this platform we can only exchange tokens based on the Ethereum blockchain.

Moreover, embedded DEXs are usually used to exchange a limited number of standard tokens (for example, only ERC20 and ERC721), which imposes great restrictions on traded assets. Examples of such decentralized platforms are DEX.tor ( note : better known all the same EtherDelta / ForkDelta ), or exchanges based on the EIP823 standard ( note :attempt to standardize the smart contract format for trading ERC-20 tokens ).

Since not everything should be based on Ethereum, let me share with you an example of DEX implemented using this approach on another popular blockchain - EOS. Tokena is currently the first full-on-chain DEX implementation that uses an intermediate token to minimize user fees.

Off chain order book and on chain calculations

This approach is followed by DEX, built on second-level protocols, on top of the underlying blockchain. For example, 0x protocol on top of Ethereum. Transactions are performed on the air (or on any other network supported by relay nodes ( note : version 2.0 of the protocol is already implemented and plan to combine liquidity on Ethereum (and its forks) and EOS), and users get the opportunity to control their funds until the time of the transaction (there is no need to block funds until the order is completed). Orderbooks in this scheme are supported on relay nodes (Relay), which receive a commission for this. They broadcast every new order, combining all the liquidity of the system and creating a more reliable trading infrastructure. After receiving the order, the market maker expects the second side of the transaction, and after that the trade is executed inside the 0x smart contract and the record of the transaction falls into the blockchain.

Such an approach to design leads to a reduction in commissions, since there is no need to pay gas for new applications or order updates, and the only two commissions that need to be paid are one for repeaters that facilitated trade, and gas necessary for exchanging tokens between users in blockchain network. In the 0x protocol, anyone ( note : it is understood that the active trader ) can become a relay node and earn additional tokens for transactions, thus covering the commission of their transactions. In addition, the fact that trading operations are performed outside the network solves the performance problem of blockchain and smart contracts, which we saw in Ethereum-based DEX.

Once again, one of the main disadvantages of this type of DEX is the lack of interaction with other platforms. In the case of DEX based on 0x protocol, we can only trade tokens that live on the Ethereum network. Moreover, in accordance with a specific implementation of DEX, there may be additional restrictions on the specific token standards that we are allowed to trade (basically everyone assumes trading tokens in accordance with the ERC-20 or ERC-721 standard). A perfect example of a 0x-based DEX is the Radar Relay project.

To be able to interact with other chains, we must solve another problem - data availability. DEX, which use mechanisms outside the blockchain to store and process orders, delegate this task to relay nodes, which may be susceptible to malicious manipulation of orders or other threats, making the whole system vulnerable.

And so, the main points of this type of DEX:

  • Work with a limited list of tool standards only
  • Smaller commissions
  • Best performance
  • More liquidity
  • Lack of blocking funds of traders

Smart contracts with reserves

This type of DEX complements the two previous types of platforms, and is designed to solve, first of all, the liquidity problem. Using smart reserves, instead of directly looking for a buyer for an asset, a user can conduct a transaction with a reserve by depositing bitcoins (or other assets) into the reserve and receiving a counter asset in exchange. This is similar to a decentralized bank offering liquidity to the system. Reserves based on a smart contract in DEX are a solution to circumvent the “coincidence of desires” problem and open illiquid tokens for trading. Disadvantages?

This requires a third party to act as a bank and provide these funds or implement an advanced resource management policy so that users can block part of their funds for DEX liquidity and for decentralized reserve management. Bancor (decentralized liquidity network) is a vivid example of such an approach ( note : it has been very successfully implemented. We are also looking forward to launching the Minter project, where it is implemented at the basic protocol level of the network itself ).

Distinctive points:

  • Increases liquidity
  • Supports many different tokens at once
  • Some degree of centralization

Dex new wave

Now you know the various approaches to the DEX architecture and their implementation. However, why such low popularity of such solutions, in the presence of strong advantages? The main problems of current projects are mainly scalability, liquidity, interoperability and UX. Let's look at promising developments that are at the forefront of the development of DEX and blockchains.

Issues to be addressed in the new generation DEX:

  • Scalability
  • Liquidity
  • Compatibility
  • Ux

As we can see, scalability was one of the main limitations in the design of DEX.
For DEX on-chain, we have limitations on contracts and the network itself, and off-chain require additional protocols. The development of next-generation blockchain platforms, such as NEO, NEM or Ethereum 2.0, will allow the development of more scalable DEX.

Let's focus a bit on Ethereum 2.0. The most promising improvement is sharding. Sharding divides the Ethereum network into subnets (shards) with local consensus, so block checking should no longer be performed by each node in the network, but only by participants in one shard. In parallel, independent shards interact with each other to achieve global consensus on the network. For this to be possible, Ethereum will have to move from the Proof-of-Work consensus to the Proof-of-Stake consensus (which we hope to see in the next few months).

Ethereum is expected to be able to process more than 15,000 transactions per second (which is not bad for implementing scalable embedded DEX).

Compatibility and cross chain protocols

So, we found out about scalability, but what about compatibility? We may have a very scalable Ethereum platform, but we can still only trade Ethereum-based tokens. Projects such as Cosmos and Polkadot come into play here ( note : while the article was being prepared, Cosmos has already entered the stage of real work, so we can already evaluate its capabilities ). These projects are aimed at combining various types of blockchain platforms, such as Ethereum and Bitcoin, or NEM and ZCash.

Cosmos has implemented the Inter Blockchain Communication (IBC) protocol, which allows one blockchain to interact with other networks. Separate networks will communicate with each other through IBC and some intermediate node, Cosmos Hub (implementing an architecture similar to 0x).

Chain Relays is a technical module in IBC that allows blockchains to read and check events in other blockchains. Imagine that a smart contract on Ethereum wants to find out if a particular transaction in the Bitcoin network was completed, then it entrusts this check to another Relay Chain node that is connected to the desired network and can check whether this transaction has already been completed and is included in the blockchain bitcoin.

Finally, Peg Zones are nodes that act as gateways between different blockchains and allow the Cosmos network to connect to other blockchains. Peg Zones requires a certain smart contract in each of the connected chains to ensure the possibility of exchanging cryptocurrency between them.

What about Polkadot?

Polkadot and Cosmos use similar approaches. They build intermediate blockchains that work on top of other networks and consensus protocols. In the case of Polkadot, the binding zones are called Bridges, and they also use relay nodes to communicate between blockchains. The biggest difference is how they plan to connect different networks, while ensuring security.

The approach to network security in Polkadot is based on combining and then sharing between chains. This allows individual chains to use collective security without having to start from scratch ( note :very difficult and incomprehensible moment for the author. Original “With Polkadot the network security is pooled and shared. This means that individual chains can leverage collective security without having to start from scratch to gain traction and trust. ”. We find it difficult to describe Polkadot's algorithm of work in simple words, at the moment it is one of the most complex projects and it is still in the research phase. Different materials use the term “security” in very different contexts, which makes it difficult to understand. There is a slightly better comparison of the two systems, for example, in this article (RU) ).

These technologies are still under development, so we will not see, at least for several months, any real exchange projects built on these interaction protocols and allowing for the exchange of assets between different networks. Nevertheless, the advantages of such technologies are very interesting for the implementation of the next-generation DEX.

Liquidity through Reservation

Similar to smart contracts with redundancy, we have an additional type of DEX, which use independent blockchains as the main infrastructure for the exchange of assets, such as Waves, Stellar or even Ripple.

These platforms allow decentralized exchange of any two assets (of any kind) using an intermediate token. Thus, if I want to exchange bitcoins for ethers, an intermediate token will be used between the two assets to complete the transaction. In fact, this DEX implementation acts as a path-finding protocol that, using intermediate tokens, seeks to find the shortest path (with a lower cost) for exchanging one asset for another. Using this approach optimizes the correspondence of requests from buyers and sellers, increases liquidity and allows you to implement some complex trading tools (thanks to the use of a separate, special blockchain, rather than a general-purpose network). For example, Binance ( note :one of the world's largest centralized cryptocurrency exchanges) did just that, using a separate blockchain for its new project Binance DEX ( note : it was launched just a week ago ). The leading exchange is trying to solve all the problems of modern DEX thanks to the excellent user interface and high chain speed, which confirms the blocks within a second ( note : inside uses the Tendermint network level and pBFT consensus, which ensures that the received block is immediately final and cannot be overwritten This also means that integration with other networks through the Cosmos network will soon be expected ).

Note :The original article goes on to talk about the product of the company where the author works, and this part seemed to us not so interesting as the first part, which perfectly reveals the approaches to the architecture of decentralized exchanges.

Related links to sources

Also popular now: