DEX: A Novel Approach to Traditional Financial Markets
This article is authorized for translation work by Mr. Yao Qian, the former director of the Institute of Digital Money at the People’s Central Bank of China.
Close followers of CoinMarketCap.com might have noticed already that in May 2018 the number of mainstream cryptos (coins with a market capitalization of 15 million USD) has exceeded 400. Earlier in November 2017, Coinbase, a Bitcoin exchange, reported that it had 11.7 million users in October, which was 1.1 million higher than the US-based brokerage Charles Schwab. According to its homepage, Coinbase now has more than 20 million active users.
Clearly, the emergence of crypto assets and the surge of user base are creating a big gap in market services. On one hand, we see crypto market generating unmet trading demands, and on the other hand, traditional financial institutions are not responding well to this emerging market. This results in a large amount of capital flowing in to meet this unfulfilled need. As of August 2018, there were over 60 cryptocurrency exchanges reporting daily trading volume over 15 million USD.
The emerging cryptocurrency exchanges are considered “super institutions” that cover custodian, clearing, order-matching, broking and market-making in one roof, and are further expanding to primary market services like private equity and investment banking. They act as the nucleus of the market with unbounded capacity and authority. However, cryptocurrency exchanges involve lots of risks due to the concentration of power and lack of regulations, including but not limited to front-running, wash trading, price manipulation and changing trading rules at their will.
Albeit sharing many similarities such as standardized order-matching and therefore bearing minimal counterparty risks theoretically, cryptocurrency exchanges in practice frequently become the root cause of defaults on lack of regulations. Some even lose out to over-the-counter (OTC) transactions on security concerns. Centralized exchanges do not fall exactly in line with the decentralized ethos of cryptocurrencies and distributed ledger system. As a result, decentralized exchanges (DEXes) emerged to take lead in crypto asset trading.
From a technical perspective, DEX needs to address five fundamental issues:
· Establish decentralized know-your-customer (KYC) and anti-money laundering (AML) rules and practices;
· Realize decentralized order books, order-matching, and automated market making;
· Implement liquidation and settlement procedures, especially delivery versus payment (DvP), in a decentralized setting;
· Construct a market status release mechanism;
· Enforce regulatory compliance in a decentralized atmosphere.
In this article, we want to discuss the characteristics of decentralized asset trading, the potential risks facing DEXes and some technical aspects including multi-asset order matching, global identity verification, cross-ledger protocols and more. Through a side-by-side analysis of DEXes and traditional centralized exchanges, we aim to produce a practical guide for the audience to enhance the overall market and improve trade security.
Decentralized KYC / AML Rules and Practices
Due to its decentralized nature, cryptocurrency does not innately require a centralized marketplace for procedures such as liquidation. On top of that, the lack of regulation and ease of cross-border payments make trading OTC inevitable, even if following regulatory authorities’ diktats. Thus, simply mimicking features of traditional stock exchanges is not applicable to cryptocurrencies. Given various levels of governmental recognition over cryptocurrencies, it is not realistic to expect any effective international regulation to come out in the short run.
An ideal way to facilitate inter-agency and cross-border KYC/AML is to create a decentralized KYC/AML rules and practices scheme following the logic behind blockchain technology. And the first step is to create a decentralized identification platform.
Current online identification system is far from perfect. User data is stored separately in different service providers, with no integrated management. As a result, users often register identities repeatedly to access different web contents. For example, using the same password for several accounts and sites puts users at elevated security risks. Nowadays, data breaches happen so often that we become almost desensitized to these hacks, which does show that the centralized identification system is not ideal.
Blockchain itself can be a decentralized public key infrastructure (PKI), making PKI more robust and secure. A decentralized certificate authority can be run on a blockchain by mapping identity maintenance to a public key. Moreover, smart contracts can implement more sophisticated logic, allowing revocation and recovery. Latest blockchain technology makes it possible to run PKI on a group of computers in a peer-to-peer manner. These self-sovereign identities constitute to distributed data and calculation among individuals so that breaching seems to be economically inefficient for hackers in this way.
Self-sovereign identity system does not conflict with national sovereignty or financial interest, and thus, it can be a viable path to implement cross-border KYC / AML. Institutions can adopt laws and regulations of different countries, thereby creating a proper KYC / AML scheme for the cryptocurrency market.
Decentralized market making, order book and order matching
Numerous solutions for decentralized trading services can already be found in the market. These solutions are categorized into three types of models based on their trade and settlement methods.
Central Reserve Model
Two of the most representative projects under the Central Reserve Model are Bancor and Kyber. There is a classical problem in asset trading, which is a double coincidence of wants. To solve this problem, Bancor protocol utilizes a technology solution through smart contracts and reserved tokens. Under such protocol, anyone can issue a Smart Token. Such token has one or multiple other collateral tokens as a reserve with a predefined ratio. Those collateral tokens can be fiat, digital asset or other cryptos. The newly issued smart token gets its value through those collaterals without to consider trading volume. In the meantime, the trading rate between an issued smart token and reserved tokens will be determined by demand and supply.
Those tradable smart tokens’ trading price against other tokens can be calculated by using a mathematical equation. A constant called CRR (Constant Reserve Ratio) needs to be set. CRR represents a portion of the tokens to be used as reserves. This is a new price discovery mechanism, which is independent from the third parties’ trading behaviors. Bancor uses a mathematical equation to define the price adjusted by supply and demand. Liquidity is provided without consideration of trading volume. Bancor’s original pricing equation is relatively simple.
Kyber uses a token reserve to provide liquidity and trading price. Kyber network consists of reserve contributor, reserve manager, and numerous other key roles. Reserve contributor can be Kyber or other organizations. Different reserves are managed by different reserve managers. Digital assets are stored in reserves and the trading price against other assets are provided by reserve manager. When an order comes, the smart contract finds the best price from multiple reserves and completes the trade. The existence of multiple reserves helps to maintain a reasonable price for each pair.
Both Bancor and Kyber use central reserves to provide liquidity. Compared with a traditional trading model, a central reserve party is a smart contract other than a trusted organization. Therefore, it is more secure, trustless, and needs no regulation. The difference is that Bancor price discovery is based on an equation adjusted by demand and supply, while Kyber trading price is maintained by reserve managers.
Order Matching Model
On-chain order book
Ripple, Stellar, EtherDelta, OasisDex, BitShares order books are on-chain. All unfilled orders are stored on blockchain. Whether the order in the order book is filled or not depends on the buyer’s bids and the trading strategy set at the time of transaction. When the order is matched for assets, the cross-asset transaction can be completed automatically. On Ripple/Stellar, if no direct matching is found, the network will find indirect path for order matching through intermediary asset.
On EtherDelta, operations such as deposit, withdrawal, making order, and trade settlement are all completed by smart contract. Maker uses a private key to sign an order and submits it to blockchain. Maker can specify expiration time by setting block numbers. Taker can select from the order book and complete the order. Smart contract will verify signatures and check whether the order has expired. There is no order matching mechanism on EtherDelta. Every transaction needs to be confirmed on chain. The trading efficiency is affected by the Ethereum network. The transaction can even be reverted due to confirmation problem on blockchain.
Some disadvantages of on-chain order book include high trading gas cost, expensive order modification, low transactions per second, and poor order book depth.
Off-chain order book
0x protocol is a decentralized exchange protocol based on Ethereum. In order to improve trade efficiency, there is no deposit and withdrawal of asset. 0x proxy contracts are approved by users to spend their assets. The order book is maintained off chain by relayers while order settlement is done on chain. In such a way, trading efficiency is improved, and trading fee is lowered. However, every order still needs to be confirmed on chain, trading efficiency is affected by the blockchain network.
Under 0x protocol, the order book is maintained by relayers. Relayers will charge ZRX tokens as fees. Orders are submitted to relayes. Then relayers verify whether the order is validated. If it is validated, relayers send order to order book pool. A taker can select an order from the pool and complete token swaps on smart contract.
For the sake of liquidity sharing, the 0x and AirSwap protocols hope to open up the liquidity barriers of different decentralized exchanges and realize the free flow of orders between different exchanges and relayers. The relayer in the 0x protocol is similar to the broker in the traditional over-the-counter market, providing order forwarding and matching services. The transaction is initiated by the taker and is settled on the blockchain without the need of relayer.
The 0x and AirSwap protocols currently only serve direct transactions for ERC-20 tokens, and their solutions have some limitations for low liquidity assets.
Multi Assets Loop Matching Model
The traditional matching system is to complete the order matching between two assets. However, the loop matching protocol expands the matching to multiple digital assets and complete the transaction between multiple digital assets through a matching loop. The loop matching helps to increase market liquidity, increase transaction confirmation speed, and reduce transaction costs. A representative of such model is Loopring.
The Loopring protocol is an open transaction protocol that supports the standard ERC-20 operations. In a sense, it is an extension of the 0x protocol. The protocol also introduced the concept of a relayer. It also draws on the idea of lightning network, and puts order generation, broadcasting, and matching of orders off chain to avoid transaction congestion on chain.
To users, Loopring simplifies the process of asset deposit and withdrawal, which reduces the possibility of losing assets. When the order is made, the funds do not have to be locked. After the order is placed, the funds involved in the order can be transferred partially or completely, that is, partially or completely order cancelling. Loopring provides Oracle services that allow traders to access market information. Loopring’s trading model also supports splitting large orders into small orders and optimizing the trading process.
Decentralized clearing service
Peer-to-peer clearing and central counterparty clearing are two common forms of the clearing. Because there is a counterparty default risk, it is necessary to technically guarantee the atomic swap of asset settlement.
Delivery versus Payment
In clearing and settlement, delivery of asset and payment need to be completed at the same time. The principle 12 of the Principles for Financial Market Infrastructures states that “If a FMI settles transactions that involve the settlement of two linked obligations (for example, securities or foreign exchange transactions), it should eliminate principal risk by conditioning the final settlement of one obligation upon the final settlement of the other”. Final settlement means that assets or financial instruments should not be revoked or transferred. According to this requirement, delivery versus payment needs to ensure asset settlement and payment atomicity. Either the assets are exchanged successfully, or there is no asset transfer. It should be ensured that one asset is transferred while the other asset is transferred at the same time
Decentralized exchange cross chain asset settlement
On a single chain, an atomic swap of two assets can be guaranteed easily. However, swapping over different chains require specific technology to ensure exchange atomicity. The earliest research starts from bitcoin atomic swap. Currently, there exist three cross-chain technologies: Notary schemes, sidechain/relays, and hash-locking.
In Notary schemes, a group of credible nodes act as notaries to verify whether a specific event has happened on Blockchain Y and prove it to the nodes of Blockchain X, without caring about specific structure and consensus on each chain. Interledger proposed by Ripple Lab is a representative of Notary scheme.
If Blockchain X enables to verify the data coming from Blockchain Y, Blockchain X is called a sidechain. Sidechains are usually based on tokens anchored on the main blockchain. Side chain is not a fork of main chain. Relay chain technology temporarily locks a number of tokens of an original Blockchain by transferring them to a multi-signature address of the original Blockchain, and these signers vote to determine whether the transactions happen on the relay chain are valid or not. Both sidechains and relays function as a listener and get data from the main chain. Side chain and main chain cannot validate the other chain’s state, avoiding form a loop. It is possible to contain the other chain’s light client. Validation logic is based on chain protocol or smart contracts. In general, the main chain does not know the existence of side chain, but side chain has to know about main chain. BTC relay, RootStock and Polkadot are the flagship projects in this area.
Hash-locking is a mechanism that carries out payment by locking some time to guess the plaintext of a hash value. Only this plaintext owner can claim the asset. In the meantime, two redemption contracts are created. Assets will be released after both parties have signed. A key point is that the person requesting for redemption will get his/her asset back later than the other person. It is designed to protect the other person. One example solution is Bitcoin lightning network.
Upon the above three solutions. Solution 1 and 3 do not require building a new blockchain. The original blockchain can be extended to implement cross chain asset swap. Solution 2 requires asset transfer cross chains, such that assets are kept in one balance sheet. Example project of side chain solution is Cosmos.
Cosmos is dedicated to forming a blockchain network in order to solve the problem of scalability and variety. There are two types of blockchains in Cosmos, called Hub and Zone. Their consensus mechanism is Tendermint, a pBFT based consensus algorithm. The first Hub in Cosmos network is Cosmos Hub. It interacts with other Zones through Inter Blockchain Communication (IBC) protocol. If regarding one Zone as a DEX, it can leverage the liquidity provided by Cosmos Hub and create a crypto to crypto trading platform. DEX transactions throughput is improved by Tendermint POS consensus algorithm. Double-spending is avoided and cross chain asset swap is settled safely.
Market Price Dissemination Mechanism of Decentralized Cryptocurrency Trading
Under the decentralized trading system, a given type of digital asset can be traded through a variety of decentralized transactions. Its advantage lies in the ability to enhance market price transparency and efficiency, due to the openness of the decentralized trading system where the price information comes from multiple sources and information monopoly is absent.
However, it is not risk-free. There might be malicious traders who post false order information, fabricate transaction volume, influence and manipulate the market. In addition, malicious users may target the weaknesses of various trading agreements and attack them, influencing the partial market to affect the entire market. Thus, it is necessary to establish a reasonable information dissemination mechanism in the decentralized trading system, in which the transparency of price information is achieved, and the authenticity of price signals is ensured.
Regulatory Compliance of Decentralized Exchange
In traditional centralized trading, central agencies are the regulatory inspectors who are responsible for investor education, risk warning, project review, customer identification, qualification, funds custodian, anti-money laundering etc. In decentralized trading, it also requires efficient regulatory compliance. Therefore, it is necessary to introduce regulatory technology concepts through technological innovation, to set up an access point for active supervision of decentralized asset trading, and provide professional services such as KYC, AML, project due diligence, risk rating, information disclosure, and risk monitoring. The specific implementation can be determined according to different technical solutions, some may require large-scale reconstruction, while others may only need to have minor corrections and adjustments. For example, the distributed monitoring platform can use blockchain technology to implement risk rating and due diligence analysis for decentralized exchange projects. Additionally, the specific monitoring of the decentralized asset trading that is based on notary schemes, can be implemented through the Internet gateway.
Comparative Analysis of Decentralized Cryptocurrency Trading and Centralized Trading
As the blockchain-based technical solutions of decentralized asset trading have the potential to enhance system flexibility and reliability, it can better deal with verification problems of node failure and data format error. When a node failure occurs, the availability of a system is not affected if the nodes required for consensus plugin are operational. The verification node can recover regardless of the length of system downtime. However, it should be noted that in the notary mode, if the notary node fails, the advantages of distributed verification may disappear. Apart from that, a distributed ledger system can detect data format errors without affecting the overall performance of the network.
Therefore, judging from the perspective of system robustness, decentralized asset trading may possess more technical advantages as compared to the centralized asset trading, which carries the risk of single point failure.
In terms of the security risk of fund custodian, the loss is immense in the event of a hacker attack and there is a risk that the custodian and the exchange may embezzle the funds (or assets) placed under their care, since all assets and funds are stored centrally in a single point in traditional centralized trading. Decentralized asset trading, on the other hand, does not require a centralized custody of assets, as the overall loss of assets is less likely to take place. Certainly, the decentralized asset trading is not invincible. A flaw in the technical design (e.g. the smart contract bug) may lead to hacking attacks. It is also worth noting that in decentralized asset trading, not all participating nodes have high security, thus the weakest link may occur. The potential loss of a single-node security flaw is determined by the design and implementation of the specific decentralized protocol.
Blockchain structure allows decentralized transactions to take place among parties without requiring any central administrators. This eliminates the risk of centralized control. Inevitably, blockchain also bears limitations, which include a number of nodes, transaction packing, block generating, cross-ledger interactions and more.
Research shows that blockchain transaction speed is largely dependent upon the time it takes to communicate and validate transactions between parties. More nodes often mean longer response time, in which executing smart contract accounts for the most of total response time. Cross-ledger DvP takes longer than single-ledger DvP. For example, cross-ledger DvP with “Hashed Timelock Contracts” (HTLC) takes up to 3 times longer than the one with a single-ledger setup. In both single-ledger and cross-ledger DvP with HTLC, most of the latency (up to around 97% in some cases) stems from the time it takes to verify transactions and commit on the ledger.
Currently, there are blockchains that have achieved a 2-second average block rate with 100,000 transactions per second (tps). Though some high-performance cryptocurrency exchanges can settle trades quasi-real-time, it is still relatively weak when compared to traditional stock exchanges which can sustain orders at microsecond-level latency.
Traditional centralized trading can employ the asset-limited delivery to solve the problem of settlement risk, while the settlement risk of decentralized asset trading is determined by the specific technical design. For single-chain DvP, even if the procedures in the process are not completed, the counterparty will not face the main risk because the asset transfer order and the cash transfer order are simultaneously executed as a single transaction in the final procedure. When it comes to cross-chain DvP, however, if there are design flaws in the timing of related process, certain incomplete procedures may cause some participants to face settlement risk.
Centralized exchanges require users to go through an identity verification process. This leaves a record at the central administrator and poses the threat of information breaching. On the contrary, DEXes better protect users’ identity and transaction data by trading peer-to-peer. For single-ledger DvP, both parties need to verify and sign a single transaction. Regardless of the underlying DLT platform, communication between parties is not committed on the ledger. Therefore, visibility is not required at verification and signing stages. Under cross-ledger DvP, information could be disseminated across the network. Nevertheless, it is possible to protect the privacy of transaction through a number of ways. This includes but is not limited to using efficient cryptographic schemes (e.g. zero knowledge protocol), ring and group signatures, homomorphic encryption, secure multi-party computation, and mixed coin methods to increase privacy for all users.
Decentralized Asset Exchanges and Traditional Centralized Exchanges Are Not Mutually Exclusive
Decentralized asset trading is advantageous in terms of cost, timeliness, and system stability. However, it requires further research and exploration in terms of performance, security, privacy, access monitoring and trading scenario expansion. Particularly, how to provide the “point of entry” for monitoring access should be an “indispensable” element of every technological solution of decentralized asset trading.
Therefore, it should be evident that decentralized exchanges and traditional centralized exchanges do not conflict against each other as neither can fully replace the other. Traditional exchanges could employ decentralized asset trading and unleash the full potential of blockchain technology. This could further enhance the price discovery function and the capital allocation efficiency of the financial market and better serve the ‘real economy’ development.