2019: Year of DEX (Decentralized Exchanges)

Is it possible that the period of the cryptocurrency winter has become a 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 experiencing a harsh winter, which is reflected in icy mountains on the price charts of popular and, not so, cryptocurrencies (approx.: Pthe eye was translated, the situation has already changed a little ...). The hype has passed, the bubble has burst, and the smoke has dissipated. However, not everything is so bad. Technologies continue to evolve and find a way out in solutions such as decentralized exchanges (DEX - Dcentralize Exchange), which are designed to radically change the cryptocurrency ecosystem in 2019.

What is a Decentralized Exchange?


You may be surprised. On centralized trading platforms, CEXs (or Centralized Exchanges., note: in the original, CEX is an abbreviation, do not confuse it with the name of the popular exchange CEX.io), the owner of the platform is only an intermediary, a kind of crypto-banker. It is responsible for storing and managing all funds that are traded on the platform. CEX is usually an intuitive and accessible platform that offers high liquidity and a variety of trading tools. The platform also acts as a gateway between fiat currency and crypto assets.

However, as crypto enthusiasts, we are aware of the risks of centralization and trust in intermediaries, such as the death of the founder of the Quadriga exchange and the loss of keys to the wallet that stored user funds. In the case of a centralized site, it becomes a single point of failure or censorship.

The goal of DEX is to eliminate middlemen and single point of failure, by conducting transactions directly between users, on the blockchain itself, which underlies the site, bypassing the trading platform. So the main purpose of a DEX is simply to provide buyers of an asset with the infrastructure to find sellers and vice versa.

The main advantage of DEX over CEX is obvious:

  1. "reliability". No more need for an intermediary. Therefore, 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 possibility of censorship (deposits cannot be frozen and users are blocked), verification (KYC) is not required to access trading opportunities, and all trading operations are β€œanonymous”, since there is no β€œwatching” and controlling body;
  3. and more importantly, generally in DEX you can make any type of exchange between assets (as long as the buyer and seller offers are the same), so you are not limited by the listing conditions of the instruments, as in the CEX (approx.: in the general case, this is not the case, here the author fantasizes a little 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 proverb says,not all that glitters is gold". Current DEX technologies have complexities that still need to be addressed. First of all, DEX is currently not too adapted for ordinary users. We professionals may find it convenient to use wallets, manage keys, seed phrases and sign transactions, but ordinary users are afraid of this kind of thing.

What's more, because trades are peer-to-peer, some exchanges require users to be online to complete their order (that sounds crazy, right?). UX is the main reason why crypto newbies prefer CEX over DEX to trade crypto assets. And as a result of the terrible UI/UX, the DEX has low liquidity in almost all tradable assets.

Again, in case you forgot that minor detail, the trades in the DEX are peer-to-peer, so if you want to exchange BTC for LTC, you definitely need to find a client willing to exchange litecoins for your proposed amount 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 so, all this, together with the limited performance of most DEXs (blockchains at their core), puts an insurmountable barrier on the way to mass market adoption.

And so:
CEX (centralized):

  • Easy to use
  • Advanced trading options
  • High liquidity
  • Opportunities to work with fiat currencies (trade, deposit/withdrawal)

DEX (decentralized):

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

Fortunately, all these complexities can be fixed, which is what new projects are trying to do. But more on that later, first let's look at the current situation. How are current DEXs created? There are three main approaches to designing a DEX.

On-chain order book and settlements

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, status change - 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, locking funds, matching orders, and executing a trade. This approach provides decentralization, trust and security by transferring the core principles of the blockchain to all DEX functionality on top of it. (approx.: in principle, this is a real decentralized exchange that fully meets 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, you can cite BitShares and Stellar).

However, this architecture makes the platform:

  • low liquidity β€” there is not enough volume for instruments in the system;
  • slow β€” the bottleneck in the execution of orders in the DEX is the smart contract and network bandwidth. Imagine the operation of a decentralized stock exchange on this principle;
  • expensive - each operation that changes the state means the launch of a smart contract and the payment of the cost of gas;
  • "by-design" the inability to interact with other platforms, and this is a huge limitation.

What do I mean by not being able 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 additional means for cross-network connection are not used. Thus, if we use Ethereum for DEX, then through this platform we will only be able to 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 the assets traded. Examples of such decentralized platforms are DEX.tor (approx.: more famous yet EtherDelta/ForkDelta), or exchanges based on the EIP823 standard (approx.: an attempt to standardize the smart contract format for trading ERC-20 tokens).

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

Off-chain orderbook and on-chain settlements

This approach is professed by DEXs built on second-level protocols on top of the underlying blockchain. For example, 0x protocol over Ethereum. Transactions are executed on the air (or on any other network supported by relay nodes (approx.: version 2.0 of the protocol has already been implemented and plans to merge liquidity on Ethereum (and its forks) and EOS), and users get the opportunity to control their funds, until the moment a trade is made (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 each new order, pooling all the liquidity of the system and creating a more reliable trading infrastructure. After receiving the order, the market maker waits for the second side of the transaction, and after that the trade is executed inside the 0x smart contract and the record of the transaction enters the blockchain.

This design approach results in lower fees as no gas needs to be paid for new orders or order updates, and the only two fees that need to be paid are one for the relays that facilitated the trade, and the gas required to complete the exchange of tokens between users in blockchain networks. In the 0x protocol, any (approx.: it is assumed that an active trader) can become a relay node and earn additional tokens for making transactions, thus covering the commission of their transactions. In addition, the fact that trading takes place offline solves the performance problem of the blockchain and smart contracts that we saw in the 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 a DEX based on the 0x protocol, we can only trade tokens that live on the Ethereum network. Moreover, according to the specific implementation of the DEX, there may be additional restrictions in the specific standards of the tokens that we are allowed to trade (basically all involve trading tokens under the ERC-20 or ERC-721 standard). An ideal example of a 0x-based DEX is the Radar Relay project.

To be able to interact with other chains, we must solve another problem - the availability of data. DEXs, which use off-chain mechanisms to store and process orders, delegate this task to relay nodes, which may be susceptible to malicious order manipulation or other threats, leaving the entire system vulnerable.

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

  • Working with only a limited list of tool standards
  • Smaller commissions
  • Best Performance
  • More liquidity
  • No blocking of traders' funds

Smart contracts with reserves

This type of DEX complements the two previous types of platforms, and is designed to solve, first of all, the problem of liquidity. Using smart reserves, instead of directly looking for a buyer for an asset, a user can trade with a reserve by depositing bitcoins (or other assets) into the reserve and receiving a counter asset in return. This is analogous to a decentralized bank offering liquidity to the system. Reserves based on a smart contract in the DEX are a solution to get around the problem of β€œcoincidence of desires” and open up illiquid tokens for trading. Flaws?

This requires a third party to act as a bank and secure these funds or implement advanced resource management policies so that users can lock up some of their funds for DEX liquidity and to decentralize reserve management. Bancor (decentralized liquidity network) is a prime example of this approach (approx.: and very successfully implemented. We also expect the launch of the Minter project soon, where this is implemented at the level of the basic protocol of the network itself).

Distinguishing points:

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

new wave DEX

You now know the different approaches to DEX architecture and how to implement them. However, why such a low popularity of such solutions, with strong advantages? The main concerns of current projects are mainly scalability, liquidity, interoperability and UX. Let's take a look at the promising developments that are at the forefront of DEX and blockchain development.

Issues to be addressed in the next generation DEX:

  • Scalability
  • Liquidity
  • Compatibility
  • UX

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

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

Ethereum is expected to be able to process over 15 transactions per second (not bad for implementing a scalable embedded DEX).

2019: Year of DEX (Decentralized Exchanges)

Compatibility and cross-chain protocols

So we've got scalability out of the way, but what about compatibility? We can have a very scalable Ethereum platform, but we can still only trade Ethereum-based tokens. This is where projects like Cosmos and Polkadot come into play (approx.: while the article was being prepared, Cosmos has already entered the stage of real work, so we can already evaluate its capabilities). These projects aim to bring together 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. Individual networks will communicate with each other via 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 verify events on other blockchains. Imagine that an Ethereum smart contract wants to find out if a particular transaction has been completed on the Bitcoin network, then it trusts this check to another Relay Chain node that is connected to the desired network and can check if this transaction has already been completed and 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 specific smart contract on each of the connected chains to enable the exchange of cryptocurrency between them.

2019: Year of DEX (Decentralized Exchanges)

What about 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 to communicate between blockchains. The biggest difference is how they plan to connect different networks and still be secure.

2019: Year of DEX (Decentralized Exchanges)

The approach to network security in Polkadot is based on aggregation and then sharing between chains. This allows individual chains to use collective security, without having to start from scratch (approx.: a very difficult and incomprehensible moment from the author. Originally β€œ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 in simple words the algorithm of Polkadot's work, 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. A slightly 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 a few months, any real projects of exchanges built on these interaction protocols and allowing the exchange of assets between different networks. However, the advantages of such technologies are very interesting for the implementation of the next generation DEX.

Liquidity through reservations

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

These platforms allow any two assets (of any kind) to be exchanged decentralized using an intermediate token. Thus, if I want to exchange bitcoins for ethers, the intermediate token will be used between the two assets to complete the transaction. In fact, this DEX implementation works as a pathfinding protocol that, using intermediate tokens, seeks to find the shortest path (with lower cost) to exchange one asset for another. Using this approach optimizes the matching of buyers and sellers, increases liquidity and allows the implementation of some complex trading instruments (due to the use of a separate, special blockchain, rather than a general purpose network). For example, Binance (approx.: one of the world's largest centralized crypto exchanges) did just that, using a separate blockchain for its new Binance DEX project (approx.: launched just a week ago). The leading exchange is trying to solve all the problems of modern DEXs with a great user interface and a fast chain that confirms blocks within a second (approx.: internally, the Tendermint network layer and pBFT consensus are used, which ensures that the accepted block is immediately final and cannot be overwritten. It also means that integration with other networks via the Cosmos network can be expected soon.).

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

Links to related sources

Source: habr.com

Add a comment