📜 ⬆️ ⬇️

2019: Year of DEX (Decentralized Exchanges)

Is it possible that the period of cryptocurrency winter has become a golden age for blockchain technology? Welcome to 2019, the year of decentralized exchanges (DEX)!
Anyone who has anything to do with cryptocurrencies or blockchain technology is going through a harsh winter, which is reflected in the icy mountains on popular and, not so, cryptocurrency price charts (the situation has changed a bit ... ). HYIP was gone, the bubble burst, and the smoke cleared. However, not everything is so bad. Technologies continue to develop and find a way out in such solutions as decentralized exchanges (DEX - D ecentralized Ex change), which are designed to radically change the ecosystem of cryptocurrencies in 2019.

What is a decentralized exchange?



You may be surprised. On centralized trading platforms, CEX (or Centralized Exchanges., Note: in the original, CEX is an abbreviation, not to be confused 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 storing and managing all the funds that are traded on the platform. CEX is usually an intuitively simple and accessible platform offering high liquidity and a variety of trading tools. The site also acts as a gateway between the fiat currency and crypto assets.

However, as crypto enthusiasts, we know what the risks of centralization exist and the credibility of intermediaries, for example, the death of the founder of the Quadriga exchange and the loss of keys to the wallet on which users' funds were kept. 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 site, bypassing the trading platform. Thus, the main task 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". No more need for an intermediary. Consequently, the users themselves are responsible for their funds, and not a centralized platform (whose director may die, the 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), no verification (KYC) is required to gain access to trading opportunities, and all trading operations are “Anonymous”, as there is no “looking” and controlling authority;
  3. and, more importantly, as a rule, in DEX you can do any type of exchange between assets (provided that the offers of the buyer and seller are the same), so you are not limited to the terms of listing instruments, as in CEX ( note : in general, this not so, here the author fantasizes a bit and describes an exclusively idealistic picture, which is now possible only in the conditions of the possibility of atomic swaps between chains )

But, as the old saying goes, " not all is gold that glitters ." Modern DEX technology has difficulties that are still to be solved. First of all, DEX is currently not very adapted for ordinary users. We, experts, can be comfortable using wallets, managing keys, sid-phrases and signing transactions, but ordinary users are afraid of such things.

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

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

So:

CEX (centralized):


DEX (decentralized):


Fortunately, all these difficulties can be corrected, as new projects are trying to do. But more about that later, for a start, consider the current situation. How are current dexs created? There are three main approaches to designing a DEX.

On-line order book and calculations


This was the architecture of the first generation DEX. In simple terms, this is an exchange, completely on top of the blockchain. All actions - every trade order, status change - everything is recorded in the blockchain as a transaction. Thus, the entire exchange is governed by a smart contract, which is responsible for placing user requests, locking funds, matching orders and executing transactions. This approach provides 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 true decentralized exchange that fully meets the spirit and essence of this approach. The drawback is that the implementations were on top of the first and imperfect blockchains. BitShares and Stellar can be taken as an example of a good solution ).

However, this architecture makes the platform:


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 no additional funds are used 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 large restrictions on tradable assets. Examples of such decentralized platforms are DEX.tor ( note : better known yet EtherDelta / ForkDelta ), or exchanges based on the EIP823 standard ( note : an attempt to standardize the format of a smart contract 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. Currently, Tokena is the first full on-dex implementation of DEX, which uses an intermediate token to minimize the fees paid by users.

Off-line order and on-line calculations


This approach is practiced by DEX, built on second-level protocols, on top of the base blockchain. For example, 0x protocol over Ethereum. Transactions are carried out on the air (or on any other network supported by relay nodes ( note : version 2.0 of the protocol is already implemented and they plan to combine liquidity on Ethereum (and its forks) and EOS ), and users can control their funds until the moment of a trade operation (there is no need to block funds until the order is completed). Orderbooks in such a scheme are supported on relay nodes (Relay), which receive a commission for this. They broadcast each new order, combining into w liquidity system and creating a more reliable trading infrastructure. After receiving the warrant market maker expects a second side of the transaction, and then the trade is executed within the smart 0x and contract record of the transaction falls in blokcheyn.

This design approach leads to lower commissions, because no new gas is charged for new orders or renewal orders, and the only two commissions that need to be paid are one for repeaters that have facilitated commerce, and the gas needed to exchange tokens between users in blockchain network In the 0x protocol, any ( note : it is assumed that the active trader ) can become a repeater node and earn additional tokens for making deals, thus covering the commissions of their transactions. In addition, the fact that trading is performed outside the network solves the problem of the performance of the blockchain and smart contracts, which we saw in Ethereum-based DEX.

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

To be able to interact with other networks, we need to solve another problem - data availability. DEX, which use off-blockchain mechanisms for storing and processing orders, delegates this task to relay nodes, which may be subject to malicious manipulation of requests or other threats, making the entire system vulnerable.

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


Smart Contracts with Reserves


This type of DEX complements the two previous types of platforms, and is intended to solve, first of all, the problem of liquidity. Using smart reserves, instead of directly looking for a buyer for an asset, the user can conduct a transaction with a reserve, depositing bitcoins (or other assets) into the reserve and receiving a counter asset in return. This is similar to a decentralized bank offering liquidity to the system. Reserves based on a smart contract in DEX are a solution to bypass 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 advanced resource management policies so that users can block some of their funds for the sake of DEX liquidity and decentralize reserve management. Bancor (decentralized liquidity network) is a vivid example of this approach ( note : and very successfully implemented. We also soon expect the launch of the Minter project, where it is implemented at the level of the underlying protocol of the network itself ).

Distinctive moments:


Dex new wave


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

Issues to be resolved in the new generation of DEX:


As we can see, scalability was one of the main limitations in the design of DEX.
For he-chain DEX, we have restrictions on contracts and the network itself, and for off-chain, additional protocols are required. The development of blockchain platforms of the new generation, 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 a local consensus, so block checking should no longer be done by each node on the network, but only by members of one shard. In parallel, independent shards interact with each other to achieve global consensus on the network. In order to make this 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 handle more than 15,000 transactions per second (which is not bad for implementing scalable embedded DEX).



Compatibility and cross-chaining protocols


So, we figured out at the expense of scalability, but what about compatibility? We can have a very scalable Ethereum platform, but we can still only trade Ethereum-based tokens. Here such projects as Cosmos and Polkadot come into play ( note : while the article was being prepared, Cosmos has already entered the stage of real work, therefore we can already evaluate its capabilities ). These projects are aimed at integrating blockchain platforms of various types, 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 for Ethereum wants to find out if a particular transaction has been executed on the Bitcoin network, then it trusts 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 allow the exchange of cryptocurrency between them.



What about the Polkadot?


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



The approach to network security in Polkadot is based on combining and then sharing between cheyins. This allows individual chains to use collective security without having to start from scratch ( note : a very difficult and incomprehensible moment with the author. In the original, “With Polkadot the network security is pooled and shared. start from scratch to gain traction and trust. ”We find it difficult to describe the algorithm of Polkadot in simple words, currently it is one of the most difficult projects and it is still in the research phase. Different materials use the term“ security ”in very different contexts that make understanding difficult. The path is a better comparison of the two systems is, for example, in this article (RU) ).

These technologies are still under development, so we will not see, at least for several months, any real projects of the exchanges built on these interaction protocols and allowing 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 exchanging assets such as Waves, Stellar or even Ripple.

These platforms allow the decentralized exchange of any two assets (of any kind) using an intermediate token. Thus, if I want to exchange Bitcoins for air, the intermediate token will be used between the two assets to complete the transaction. In fact, this DEX implementation works as a pathfinding protocol, which, using intermediate tokens, seeks to find the shortest path (at a lower cost) to exchange one asset for another. Using this approach optimizes the compliance of applications from buyers and sellers, increases liquidity and allows you to implement some complex trading tools (through the use of a separate, special blockchain, rather than a general-purpose network). For example, Binance 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 the high speed of the chain, which confirms the blocks within a second ( note : the inside uses the Tendermint network level and the pBFT consensus, which guarantees that the received block is final and cannot be overwritten This also means that soon we can expect integration with other networks through the Cosmos network ).

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

Links to related sources


Source: https://habr.com/ru/post/451944/


All Articles