Center absence: history, current status and prospects of atomic exchange and decentralized trading platforms

On July 30th, Liquid Network officially announced that Tether (USDt) has settled on the Liquid side chain, which means that relying on Liquid USDt, the OTC platform and individual traders can complete the instantaneous Bitcoin-US dollar without any trusted third party. exchange. This may be seen as a major development in the decentralized trading platform – through the stable currency USDt, the decentralized trading platform will also be able to undertake the task of making faster transactions between the legal currency and digital assets.

Since the cross-chain transaction can be carried out in the absence of a trusted third party (such as a centralized trading platform), the decentralized trading platform has attracted a lot of attention. The cornerstone of its technology is the Atomic Swap technology developed by the Decred team. According to the official introduction of the atomic exchange program, the project now supports a cross-chain trading pair of ten blockchains including Bitcoin, Litecoin and Zcoin.

The decentralized trading platform that aims to complete secure asset transactions without trust has the vision and nature consistent with the blockchain, but its goal also means that it needs to be more innovative than its centralized competitors. Design concept and technology. From the early prototype of BitShare to the blossoming of today's major trading platforms, the decentralized trading platform has gone through an animated road, but until now, its development status still has a certain distance from the original idea.

First, the risk of centralized trading platform

Centralized trading platforms (such as currency security, fire coins, BitFinex, etc.) provide personal and institutional traders with digital assets and legal currency trading, as well as mutual exchange of digital assets. Since the advent of digital assets, the centralized trading platform has been an integral part of the entire blockchain economy, but its shortcomings are equally obvious.

When registering a centralized trading platform account, the user will get a coin address assigned by the trading platform, but the private key corresponding to the address will not be distributed along with it, but will still be controlled by the trading platform. Therefore, the transaction activity carried out by the user through this address itself constitutes a fund custody, in which the trading platform plays the role of a trusted third party. Although in general, the security mechanism of the centralized trading platform can enable traders to trust their trusted third parties with confidence, but with the gradual development of digital assets, the risk of centralized trading platforms is still emerging, and now The words are mainly reflected in the following aspects:

(1) Professional ethics risk

Commercial banks will also have a vicious incident of self-stealing due to the ethical problems of employees, and the centralized trading platform will also be difficult to avoid. In February 2014, Mt.Gox, the world’s largest centralized trading platform, was stolen by 650,000 bitcoins, although its owner Mark Karpeles was subsequently arrested for embezzling the trader’s property, but 650,000 were stolen. Bitcoin has not been returned yet.

In addition, since the account and transaction privacy of the centralized trading platform users are completely open to the trading platform, this also gives the trading platform the possibility of stealing user information for arbitrage. A typical example is the “pin” operation in the futures market: since the data of the user's pending orders in the futures market will be exposed to the trading platform, the trading platform may use the targeted reverse trading to make the user burst the position and eat Drop its initial deposit.

(2) Hacking attacks

The centralized custody of digital assets will incur a huge risk of hacking, and the technical foundation and crisis response capabilities of the trading platform are severely tested. For example, Coindesk has been robbed of a large number of NEM by hackers, and the economic loss is as high as about 530 million US dollars; and Youbit is bankrupt because of hacking.

(3) Policy risk

At present, most governments' attitudes toward digital assets are unclear, and once there is a tough policy control, the centralized trading platform will bear the brunt of the risk of being forced to close.

Second, atomic exchange and hash time lock contract (HTLC)

Currency-coin transactions between encrypted assets are one of the most fundamental requirements in digital asset trading. A third-party centralized trading platform is one of the most traditional solutions: through the specific transaction pairs provided, the trading platform can match the intended users to complete the transaction. However, under the current situation that the risk of centralized trading platforms is becoming more and more serious, is there a safer way to realize the cross-chain transfer of digital assets?

Atomic exchange is a technical answer to this question at this stage, which allows peer-to-peer digital asset transactions without the presence of a trusted third party and guarantees the security of both assets throughout the transaction. The technology was first developed by the Decred team and completed the first atomic exchange on the chain in the history of blockchain on September 19, 2017, and exchanged 2.4066 DCRs using 1.337 LTCs. Today, atomic exchange has evolved into a core technology for decentralized trading platforms that provide trading pairs for ten major digital assets, including LTC, DCR and BTC.

How does atomic exchange complete the exchange of assets on two different blockchains without the existence of a trusted third party? We can think of the trading channel between two people as a slide, and two traders, Alice and Bob, are located at both ends of the slide.

Now, the two of them decided to make a deal – exchange one of Bob's 10 ETHs with a BTC in Alice's hands. But Alice can't put her BTC in the rails, and then expects this BTC to float to Bob like a water surface, because Bob is likely to take her assets directly, but refuses to pay for her 10 ETHs; This risk is equally equal for Bob. Therefore, they need a mechanism to ensure that both parties can make the deal, or vice versa – when one repents, another can safely take back their assets.

So Alice thought of solving the problem with a locked box – she found a locked iron box and had a lock on both the front and the back. The end facing Bob is locked with a combination lock, and unless Bob knows the password, he can't open the box; and on her side, she adds a time lock if Bob doesn't open her box. Then, after a while, the lock will automatically unlock and let her get back her BTC.

This is a simple analogy of the Hashed-Timelock Contract. The contract consists of two locks, a password lock (hash lock) that requires a password to be unlocked, and a timed lock that is timed on. The former guarantees the security of the transaction; the latter guarantees that the transaction fails or In the case of being revoked, your digital assets will not be lost.

The atom exchange process is illustrated by https://github.com/decred/atomicswap

A complete atomic exchange process consists of two hash time lock contracts. In the previous situation, Alice will first create a transaction on the BTC public chain. This transaction contains one of her BTCs and is locked with two locks. . Alice will generate a random number (hereinafter referred to as random number a), and sign the private key of random number a and Bob as the key of the hash lock, and hash the random number (hereinafter referred to as hash ( a)) is transmitted to Bob, and the time lock is set to automatically turn on after 48 hours.

After receiving the random number from Alice, Bob will also open a transaction on the ETH chain. Similar to the previous one, the transaction also includes a hash lock and a time lock. The hash lock key is a random created by Alice. The number a and her own private key signature, and the automatic opening time of the time lock is 24 hours later.

After Bob submits the transaction, because Alice knows the random number a herself, she can open Bob's hash lock with her own private key signature and take away 10 ETHs he placed in the box. At the same time, the transaction will be broadcast on the public chain along with the random number a, so B can know the random number a as the secret key, and when he signs it with his private key, he can take it. Take the BTC he deserves. So far the entire atom exchange process has ended, and both Alice and Bob have got what they want.

Since Bob couldn't know the value of the random number a before his ETH was taken away by Alice, he couldn't take the other's BTC as his own if he could recover his assets. Alice, who initiated the transaction first, had a longer lock time than Bob because of the time lock, which meant that she could not withdraw her BTC immediately after extracting Bob's ETH. And no matter which side wants to repent at any time during the transaction, the result is the same – the two sides get back all their original digital assets. This is also the embodiment of the "atomicity" of atomic exchange: in this set of trading orders, the trading behavior is either completed or not equivalent. In this way, a secure asset transaction is completed in the event that both parties do not trust each other and there is no trusted third party.

Third, decentralized transaction agreement and decentralized trading platform

Atomic exchange guarantees secure transactions in the absence of trusted third parties. The decentralized trading platform includes integrated business implementation including transaction funds pool and matching transaction pairs. Decentralized trading platforms have a richer ecology and more diverse trading logic due to different blockchain community foundations and decentralized trading agreements. In general, the decentralized transaction protocol is divided into three types, namely, the order book mode represented by 0x and road printing, the reserve pool mode represented by KyberNetwork, and the P2P mode represented by Swap.

(a) 0x

0x is an open source protocol that runs on the ETH chain and runs ERC20 Pass-to-Peer transactions. The biggest feature of 0x is the introduction of a repeater node (Relayer). In the 0x protocol, the layerer is a relatively broad concept. Any node that can implement the 0x protocol, including the trading platform that provides the transaction book service, DApp, etc., can play the role of Relayer.

In the 0x protocol ecosystem, the Relayer node sets its own service fee rules and provides the services of the order book. The so-called order book can be regarded as the data set for processing the processing order. When the maker needs to conduct the asset transaction, the order book can be accessed and the own pending order can be created, and the completed order will be updated and saved by the Relayer. These saved orders will be placed in the order book, and theaker can see the desired order from the order book and choose to make one-on-one transactions. In other words, 0x uses a combination of chain and chain settlement.

0x agreement order book schematic, quoted from https://www.jianshu.com/p/5aa5d2225b3e

Although Relayer's order book may integrate a large number of orders, it does not have the asset address private key of both parties, so it is safe for the user; in addition, because of the broadness of Relayer, In the ecology, more and more Relayers will run at the same time. These numerous relay nodes can fully expand the liquidity of the entire trading system, thus alleviating the problem of insufficient depth of the decentralized trading platform.

The problem with 0x is that since the shiper needs to match the order online on the Relayer, the real-time nature of the transaction is not good, and the efficiency of the match is relatively low. In addition, 0x adopts a "pre-authorization" mechanism, that is, the transaction user needs to authorize the smart contract transfer token before the transaction, but if the user transfers the digital asset from the address but does not cancel the order on the Relayer, it will bring The risk of transaction failure, which also makes it difficult for Relayer to manage and feedback the effectiveness of the order.

In addition, according to Eagle-Eye of Chengdu Chain Platform, there is a signature verification vulnerability in the 0x protocol, which causes hackers to forge signature data for malicious pending orders. Fortunately, the vulnerability has been fixed in time and has not caused actual economic losses.

Despite some weaknesses, the 0x protocol remains one of the most mature decentralized trading systems. The platform, including Rader Relay, Tokenlon, Star Bit and the world's largest decentralized wallet imToken, supports the agreement, which means that 0x has a deep community to continue to promote the continued improvement of the agreement.

(2) Road printing (Loopering)

The roadprint inherits some of the concepts and architecture of 0x. Similar to 0x, Lu Yin also has the concept of Relayers, and also adopts a similar model of chain-linking and chain trading. Compared to 0x, the biggest innovation of Lu Yin is that it gives up the traditional way of combining individual transaction pairs, but uses the new “loop loop” to match the transactions.

The loop closure cancels the buy and sell orders, but instead uses the concept of an undirected “asset trade order”. Suppose Alice wants to exchange ETH with BTC, and Bob also wants to exchange LTC with ETH. At this time, Alice and Bob will submit the order to the order form. At this time, if there is another person on the order form called Carol who is willing to exchange BTC with LTC, then the orders of these three people will form a trading loop. If the three people on this trading loop can get the expected return from the transaction, then the road printing will automatically trade the three orders.

Loopring loop diagram, referenced from https://www.jianshu.com/p/5aa5d2225b3e

Since a transaction loop can contain multiple transactions at the same time, under the road printing agreement, not only can simultaneous transactions of multiple currencies be realized, but the transaction speed and asset liquidity also increase. Currently, there are already line printing protocols on large platforms including Kriptomat, Polymath and Wanchain. As a new trading model and complementing the road printing transaction agreement, the development of the Odyax auction agreement (Oedax) has also begun. This new trading model may abandon the order, but replace it with the updated Dutch style. Auction to solve the problem of online trading.

(3) KyberNetwork

KyberNetwork (Kyber) is an attempt not to rely on the order book, which uses an independently managed repository to ensure liquidity and provide instant online links. The repository is decentralized, similar to a warehouse that stores tokens. The contributors of the warehouse can set the transaction price of the assets in the repository and keep updating as the currency moves.

Schematic of the KyberNetwork repository, taken from https://developer.kyber.network/docs/Reserves-Intro/

When a trader intends to use Kyber for trading, the agreement will automatically traverse all the stocks in the chain and automatically match the best price for trading. Therefore, there is a direct competitive relationship between the reserve and the reserve, which helps to ensure the liquidity of the assets on the entire system; in addition, because in the Kyber agreement, theaker directly deals with the reserve rather than the trader. Interaction, therefore, the use of smart contracts in the chain can complete fast settlement, which is the biggest advantage of Kyber. Currently, there are decentralized trading platforms including imToken, coinbase and wallet and represented by oasis.

Kyber's problem is that compared to the mature 0x and road printing, the agreement is relatively relatively green, and the current system can only be run on the ETH main chain for the time being. In addition, this ambitious agreement on cross-pass and cross-chain interoperability is more dependent on the success of some of the pioneering projects, such as Melonport, Polkadot and Cosmos, which is virtually invisible. Added risk to Kyber.

(4) Swap

Swap is a representative of the transaction using P2P mechanism for transaction matching. This is a closed decentralized trading platform agreement based on Ethereum, supporting ERC20 pass. Airswap is currently the representative of the agreement.

Swap's P2P coupling mechanism is illustrated by https://swap.tech/whitepaper/

Swap's P2P mechanism consists in allowing users to quickly trade privately with known objects without having to wait for the transaction order to be placed on a public order book. Swap provides two chain services to help both parties communicate: Indexer matches and matches the transaction based on the transaction intent; Oracle is responsible for providing pricing advice to both parties. When a maker successfully matches the ship and agrees on the transaction price, the order can be quickly filled in the smart contract.

The agreement in the white paper argues that the order book has some flaws that make it "difficult to compete with existing solutions," while Swap is a "method that can be decentralized without being affected by these restrictions." According to the white paper's description, Swap may think that its advantage for the order book is faster, more intimate convergence efficiency and faster transaction speed. Considering that the project is also a young competitor far more than the order book agreement, the performance in business practice may take longer to see and judge.

Fourth, the bottleneck and future of the decentralized trading platform

Although the decentralized trading platform has been one of the most concerned topics in the blockchain industry for the past two years, as of now, the completion of trading digital assets through the centralized trading platform still accounts for more than 90% of the total. In this sense, the decentralized trading platform is still in the stage of continuous exploration and evolution. It is still the prototype in the laboratory and has not yet entered the general public's choice. For the time being, there are two main problems:

1. Trading experience . The decentralized trading platform is, in the final analysis, a user-oriented product, so the user experience can be described as important. Since all transactions completed through the decentralized trading platform require a chain, they may be subject to the speed of the blockchain itself. In the field of frequent and violent price fluctuations of digital assets, the rigid requirements for transaction speed exist objectively. Although some of the head trading platforms have made a number of technical improvements to this weakness, such as WhaleEx has reportedly reached the second-level trading, but with the launch of the millisecond-level matching engine of Blockchain's trading platform PIT, in terms of transaction speed and efficiency The decentralized trading platform still has a long way to go.

Transaction depth and asset liquidity. Considering that the decentralized trading platform still has technical difficulties in dealing with high-concurrency and large-frequency real-time transactions of digital assets, its transaction depth and asset liquidity will be affected. This is also one of the core issues facing the current decentralized trading platform, but with the technical iterations, this dilemma may be eased in the near future.

2. The user uses the threshold . In addition, since the decentralized trading platform requires the customer to manage the private key of the wallet, the user entry threshold is substantially higher than the managed centralized trading platform. Moreover, if the wallet private key is lost or leaked, the user may no longer be able to recover the assets in the wallet once the chain transaction has completed irrevocable characteristics. How to reduce the difficulty of trading, smooth the learning curve, and carry out the necessary risk warnings for small white users. For the decentralized trading platform, it will be a problem that needs to be solved jointly by the technical end and the product end.

Undoubtedly, with the continuous improvement of future agreements and technologies, the decentralized trading platform will be able to break the monopoly of the current centralized trading platform in the market. But this does not mean that the decentralized trading platform can completely replace the centralized trading platform, the main reasons are:

1. User layering . In the future, digital assets should be the experimental field of cryptography geeks, facing the new financial field of the general public. Due to the centralized hosting of the centralized trading platform, the convenient and fast one-stop service is easier to deploy on the centralized trading platform. These simple and convenient services are easier to understand and get started with the public who don't know much about the blockchain.

2. The development of security technology . The centralized trading platform has always faced strong network security challenges, and this will become an opportunity for the continuous development of its network security technology. Although the nature of centralization determines that it can never eliminate the risk of hacking or self-stealing like its decentralized opponents, if technology can reduce its risk below a certain threshold, it will combine its advantages of convenience and speed. The centralized trading platform will still occupy a place in the future digital asset market.

Reference materials:

  1. Readme file of Atomic Swap, https://github.com/decred/atomicswap
  2. Lightning Network "dirty little secret": Hash time lock smart contract to ensure payment security? , http://tech.ifeng.com/c/7lWBs6TsO12
  3. 0x: Decentralized Exchange Agreement | ONETOP rating, https://www.jianshu.com/p/f0adfcebfe01
  4. Loopring Chinese White Paper
  5. KyberNetwork Document, https://developer.kyber.network/docs/Reserves-Intro/
  6. Swap: A Peer-to-Peer Protocol for Trading Ethereum Tokens, https://swap.tech/whitepaper/
  7. What are the advantages and disadvantages of centralized exchanges and decentralized exchanges? , https://www.jianshu.com/p/95b8391e15f1