New Feature: Introduction of Zenlink Smart Order Routing Design Solution

At present, the first batch of parachain slots auction in Kusama network is being carried out in an orderly manner. Karura and Moonriver have successively won the first two slots, followed by Shiden and so on.

This means that the original design concept of Polkadot has been implemented, and a new pattern of extensible and interoperable multi-chain network is about to be shaped. At the same time, the launch of many smart contract based parachains has also opened the prelude to the outbreak of Polkadot DeFi and applications.

As an important protocol layer project in the Polkadot DeFi stack, Zenlink will play a key role in connecting the huge liquidity of the Polkadot DeFi ecosystem, such as helping parachain projects to deploy DEX and achieve liquidity sharing with one click, linking all DEX aggregation liquidity on the Polkadot. In this article, we will focus on introducing Zenlink’s new feature, smart order routing.

Aggregate the liquidity of three versions of Zenlink DEX

Before formally introducing Zenlink smart order routing, we first need to understand the basis on which it is built.

Different from the DeFi products on Ethereum, which is mainly running backed by smart contracts, the heterogeneous and multi-chain architecture makes Polkadot DeFi ecology more flexible and diversified. Some DeFi projects plan to bid for slots to become Polkadot parachains, some do not plan to participate in slot auctions but choose to use parallel threads, some will choose to build on Polkadot’s smart contract based parachains, and some will deploy modules on multiple parachains.

First, Zenlink aims to build Zenlink DEX Protocol based on the official XCMP protocol of Polkadot. It is not only the underlying unified and universal cross-chain DEX protocol built by Zenlink, but also the core part of Zenlink ecology. Zenlink DEX Protocol will be implemented in three forms: Module, WASM and EVM. In order to help users understand better, this article will briefly introduce the differences between the three:

Zenlink DEX Module is a module that can be inserted into parachain code through Pallet. The module will be integrated into parachains, so that they can directly have the basic functions of DEX without repeated development, such as Swap, creating transaction pairs, adding/removing liquidity, etc.; at the same time, it can also share liquidity with all parachains integrated with Zenlink DEX Module.

Zenlink DEX WASM version refers to the contract version built with WASM technology. WASM, whose full name is WebAssembly, is a stack virtual machine technology, and it is also the fourth Web programming language widely used after HTML, CSS and JavaScript. Due to the excellent design and performance of WASM code that is cross-platform, portable, and can run at a speed close to hardware instructions, many well-known public chain projects tend to adopt WASM technology at the Runtime and smart contract level.

WASM is the original contract implementation way in Polkadot network, and it is also the main contract deployment mode in the future. Zenlink DEX WASM version has the ability to deploy to WASM contract parachain at the first time.

Zenlink DEX EVM version is a contractual deployment mode to achieve compatibility with the Ethereum virtual machine (EVM), and it is also a transition scheme adopted by the Polkadot network in the initial stage. The Zenlink DEX EVM version implements all the functions of the protocol layer, complements the perfect testing process, and can be deployed to the EVM contract parachain at the first time, which greatly expands the applicability of the platform.

As Zenlink will use Module, WASM and EVM to deploy in many parachains, which also means that its liquidity terminals are also scattered, so in the future, Zenlink will achieve the mutual access and interconnection of the three versions, aggregate the liquidity of the “trinity”, and then form a decentralized cross-chain DEX network with rich liquidity.

This is also the biggest difference between Zenlink’s flexible underlying DEX protocol solution and other DEX projects on Polkadot that use a single parachain to build DEX and deploy on a single smart contract parachain, and its advantages are also what they do not have.

The flexibility of Zenlink is that it can not only integrate/deploy into parachain in many ways, but also combine with other protocols more flexibly to achieve unparalleled combination. For example, Zenlink will integrate Zenlink DEX Module into the Bifrost parachain after Bifrost wins the slot, while integrating with its SALP agreement to provide the first derivative liquidity mining product for Polkadot slot auctions.

It can be predicted that with the continuous expansion of Polkadot DeFi protocols, applications and users in the future, this advantage will become more and more obvious.

Optimizes transaction path in real-time with smart order routing

From the above, we can basically understand how Zenlink is implemented at the product level. Polkadot’s multi-chain architecture gives Zenlink a lot of freedom and room to play, but it also brings some problems. Since Zenlink DEX is distributed in different parachains in different forms, it also means that the liquidity of each asset transaction on different parachains is uneven.

In order to help users find the best trading path and bring users the best trading experience, Zenlink built Smart Order Routing. With this Smart Order Routing function, Zenlink can aggregate all liquidity on parachains connected to Zenlink DEX Protocol, becoming an one-stop shop that aggregates the optimal token price across parachains “market depth”, whether mainstream trading pairs or long-tailed trading pairs.

Zenlink smart order routing adopts a new routing algorithm, which can effectively make use of many “market depths” in the same protocol and obtain the optimal transaction price by optimizing the transaction path for users in real-time. According to the current scenario design, when a user plans to make a transaction, the execution strategy is rough as follows:

Step 1: user enters the tokens and the amount of tokens they plan to buy (sell), and the DEX front end begins to simulate smart order routing transactions in the Zenlink DEX liquidity pool (Pool) of all parachains. The routing will filter out the feasible solution of the transaction through “depth” priority search in all Pool in a single chain and prioritize the transaction path to get the optimal solution.

Step 2: after the simulated routing transaction of all chains, a set of optimal solutions of each parachain will be obtained and the chains in which the first n optimal solutions are listed in order will be used as the input parameters of the Split Trade.

Step 3: after obtaining the n chains that specifically execute the split trade, the route will be split for the first time, and the first split will allocate more transaction share to the more optimal price chain in the above simulated routing transaction. After the share is allocated, the route calculation will get the solution after the first split. Compared with the simulated optimal solution obtained before the split, the better chain after price fluctuation will get more transaction share allocation in the next split.

Step 4: continue to carry out the previous step until the trading price fluctuation on each chain after allocation shows a gentle situation and is lower than a certain threshold, then the current best split result is obtained and used as the final trading path.

In short, in the preliminary design scheme of Zenlink smart order routing, when it comes to cross-chain transactions, the route will at least simulate the transaction results in different paths in more than two parachains, and finally select the Pool on n parachains with the best simulation results to split the transaction.

It is worth mentioning that the above-mentioned selection of n optimal solution chains as the input parameters of the split transaction will not be too large. The reason for this design is that such transactions involve cross-chain Transfer, in order to ensure the success rate of routing transactions and to avoid “invalid” routes caused by the time difference caused by cross-chain Transfer between too many parachains. Therefore, a more balanced value will be sought as the value of n in the final routing scheme.

For example, the user wants to make a transaction to convert X into Y. Parachains A, B, C and D all have the Pool that involves X or Y. Zenlink smart order routing will simulate the transaction results in the four chains A, B, C and D when calculating the optimal transaction path, but the final order result may not be split on the Pool of the four parallel chains A, B, C and D. Instead, the pool on the two parallel chains with the best simulated transaction results are selected for split trading, for example, 40% of the order comes from the B-chain Pool, 60% from the D-chain Pool.

This solution enables Zenlink to effectively act as a unified portal for Polkadot ecological DEX, bringing different sources of liquidity together, giving traders the ability to trade efficiently across different parachains.

Of course, this is the earliest version of Zenlink smart order routing and a small part of the Zenlink product plan. In the future, Zenlink will build aggregators for aggregating all DEX on Polkadot. Zenlink’s vision is to create an extreme, open and universal cross-chain DEX protocol that allows Polkadot developers to easily build DEX and provide users with an efficient and enjoyable trading experience.

This vision is closely related to blockchain technology and the future development of Polkadot in Zenlink’s eyes. We believe that the era of interconnection of ten thousands of chains has begun, and Polkadot will bring more breakthroughs and innovations to the blockchain industry, and with the launch of parachains on Polkadot, the ecology on the parachain will develop rapidly, which will also bring a lot of scattered liquidity.

In order to better connect the liquidity within the Polkadot network, we need not only a universal underlying cross-chain DEX protocol for all Substrate developers to use, but also an efficient, and reliable decentralized trading network for users to use, which is what Zenlink wants to do and is doing.

What is Zenlink?

Zenlink is committed to building a new generation cross-chain DEX network. By integrating the Zenlink DEX Module, Zenlink can enable parachains to access DEX capabilities and share liquidity with other parachains quickly; Zenlink DEX aggregator can link all DEX DApps on Polkadot. Users can not only complete the exchange easily and quickly but also enjoy a low slippage transaction experience. ZLK, Zenlink native token, provides a fair and transparent governance mechanism and reasonable value capture methods, which can be used to motivate ecosystem users to participate in network development for a long time.

Zenlink is an important member of the Polkadot ecosystem and is sponsored by the Web3 Foundation. For now, two grants have been delivered successfully. Furthermore, Zenlink has also completed the prototype verification of cross-chain assets trading between Polkadot parachains at 2020–12–12 04:00:00 UTC, which means that the first cross-chain dex user case on Polkadot has been verified successfully based on Zenlink DEX Module and Assets Module.

Learn more about Zenlink

📍 — Website | Twitter| Github | Telegram EN | Telegram CN | Announcements Channel

📚 — Whitepaper

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store