DEX is very hot, and DEX has loopholes, saying that "preemptive trading" is a disease.

The security breach of the central exchange, such as the currency security, ignited confidence in the decentralized exchange (DEX). But be careful, humans are not the opponents of robots on decentralized exchanges. "Preemptive trading" has become the biggest evil in decentralized exchanges.

The stolen stolen 7000 bitcoins allowed the risk of the centralized exchange to be exposed again, and everyone turned their attention to the Decentralized Exchange (DEX). It is theoretically safer for decentralized exchanges to keep assets and private keys for users. However, it does not mean that there is no problem.

Philip Daian , a well-known smart contract developer and a Ph.D. student at Cornell University in the United States, recently published a paper pointing out that arbitrage robots on decentralized exchanges can be used to raise transactions as high-frequency traders in traditional trading markets. The gas fee method gives priority to the location of the block and the priority execution of the order, and obtains arbitrage gains through operations similar to the " preemptive trading " in the traditional trading market. As human beings, they will be at a disadvantage when dealing with these arbitrage robots.

The results of this study have attracted the attention and reports of mainstream commercial media such as Bloomberg, and have also raised concerns about decentralized exchanges.

What is the preemptive transaction

The so-called "preemptive transaction" refers to the important information that will change the transaction price in advance, and profit from trading before the market.

In the simplest case, if a trader gets a message before the open market: an institution will buy a large amount of BTC in the next second, then within this second, the trader can buy the BTC first, and wait until the institution orders a large amount. At the time of purchase, the BTC on the market may rise because of the large number of purchase orders, and the trader can sell the BTC to the institution at a higher price at this time.

A successful preemptive transaction can have a very large return and a low risk, because before the trade, the trader has been able to determine that there will be a counterparty at a point in time in the future, and a certain profit can be obtained from the trade.

This kind of operation may be legal or illegal depending on the situation. The difference is whether the information is public. If the information is made public, the trader can legally rush to trade in front of it faster, that is, legal arbitrage. Conversely, if the information is not public, the trader gets the information through the job, so it is illegal at the moment of the transaction.

A simple analogy is used to further explain that each transaction is a runway, each trader is an athlete prepared at the starting point, the market information is the referee, and the first athlete who rushes to the finish line will make a profit. Then the legal preemptive transaction is that the referee shoots. All the athletes hear the gunshots at the same time and start running together. The fastest athletes are the first to rush because of their own strength. The illegal preemptive transaction was that the referee secretly made a gesture to the No. 3 athlete. The gesture was planned in advance. At this time, the No. 3 athlete started running because the other athletes did not know the secret number, so they rushed after the No. 3 athlete.

Preemptive transactions in exchanges in traditional financial markets

One of the biggest reasons for the preemptive trading being pushed into the public eye is the book by financial writer Michael Lewis called " Flash Boys: A Wall Street Revolt" . In this book, Lewis describes in detail the preemptive trading strategies used in high-frequency trading.

It is worth mentioning that the high-frequency preemptive transactions described in the book are not illegal. The reason is that high-frequency traders use their own software and hardware equipment to obtain public information at a faster speed, make faster judgments, place orders faster, and make transactions in front of other "athletes". Lee.

Although this practice is legal, it does not conform to "morality." The reason is also very simple. In the absence of supervision at all, high-frequency traders can buy servers closer to the exchange through their own financial strength, can lay faster cables, and hire more advanced programmers to write. Faster software, some of which are designed to grab public information before trading with ordinary traders. Throughout the process, high-frequency traders did not conduct economic analysis through market information. They simply engineered the transaction process efficiently and took the upper hand in this zero-sum game. This approach is the ultimate in shearing, without any benefit to the entire market, and the result is that the cost of ordinary traders is rising.

Preemptive transactions in centralized cryptocurrency exchanges

The preemptive transactions in centralized cryptocurrency exchanges are more like traditional financial markets. We are not specifically discussing here. Because most centralized exchanges lack supervision, preemptive transactions can be seen as insider trading, and players who get insider information ahead of time for various reasons become the biggest profiteering party.

If you look at it from another angle, you can even think of the exchange as a preemptive transaction, because this is a typical operation team to get information before the user to make judgments, and to cash out.

Preemptive transactions in decentralized cryptocurrency exchanges

The pre-emptive transactions of decentralized exchanges are more complicated and there has been discussion in the market.

It is precisely because the information of the centralized exchange is opaque that we are slowly exploring the path of decentralized exchanges. The simplest idea is that decentralized exchanges can put transaction information on the chain, visible to everyone, and break the opacity of information. At the same time, users master their own wallet private keys and truly control their own funds. The transaction combination between the seller and the seller can be automatically carried out through the smart contract, the middleman is removed, and the handling fee is saved.

All of this looks good, but due to the technical nature of trading on the smart contract chain, preemptive trading has been rampant in decentralized exchanges.

The logic of decentralized preemptive trading is simple and rude. Because the order of execution of contracts is not completely in chronological order, the higher the transaction fee and the higher the priority, so athletes can accelerate themselves by paying higher fees. Fly shoes, let yourself reach the end point first, and complete the transaction of the higher handling fee ahead of the block process to complete the arbitrage.

Researchers at Nelson Daian, Steven Goldfeder, and Tyler Kell at Cornell University recently published a paper that found that arbitrage robots on decentralized exchanges can use decentralized centers like high-frequency traders in traditional trading markets. Part of the weakness of the exchange, gaining arbitrage gains. The paper points out that these arbitrage robots give priority to the location of the block and the priority execution of the order by raising the price of the transaction gas. By preemptive trading, the ordinary trader is at a disadvantage when dealing with the robot.

Flashboys 2 research decentralized exchange arbitrage details

The research paper by Philip Daian et al. is titled " Flash Boys 2.0 ", which is clearly a tribute to Michael Lewis's classic book, "Flash Boys."

Philip Daian is currently a Ph.D. student in the computer science department at Cornell University, but has emerged in the field of distributed systems and cryptography. In 2017, under the direction of Elaine Shi, he published a paper entitled " Snow white: Provably secure proofs of stake" and made great achievements in smart contract security.

The Cornell University research team spent 18 months tracking six unnamed de-centered exchanges and found the “preemptive transactions” of these de-centered exchanges.

To make it easier to understand the findings of the Philip Daian team, let's first list the features of the decentralized exchange :

  1. The transaction process is a discrete process of exporting, and the capacity of each block is limited;
  2. Multiple exchanges are chained in parallel, and price differences have occurred during the block process;
  3. Multiple transactions can be placed in the same atomic exchange contract, which can be considered to be executed instantaneously, across exchanges;
  4. Depending on the complexity of the transaction, the more complex the transaction (the more operations within a smart contract), the higher the fee charged, so the transaction complexity needs to be optimized;
  5. The transaction is spread out to the entire network through the protocol, but because each participant has a different location in the network, the time of receiving the information is divided into several;
  6. The order of transactions is particularly important, and the order of transactions is determined by the fee, the fee is determined by the auction, and the miner prioritizes the handling of higher commission transactions, which is the core rule for pre-emptive transactions in decentralized exchanges;
  7. Future transactions can be simulated to some extent, and players can predict based on simulation results;
  8. Some transactions may not be executed because they did not win the fee auction, but the trader still needs to pay a certain percentage of the handling fee, which is the cost of trying to execute the contract, and the miner charges;
  9. Whether the transaction needs to wait for a block confirmation is not an instant confirmation.

Based on these characteristics, smart players can find a process of moving bricks to cover the spread :

  1. Since (1) and (2), after the player finds the price difference between the exchanges, he can trade through the same (3) one atom exchange contract, and smooth the spread for arbitrage. This is a method similar to the arbitrage of moving bricks. Unlike the traditional arbitrage of trans-centralized exchanges, atomic exchange can confirm the simultaneous execution of buy and sell transactions, without considering that one of the exchange transactions failed to execute. risks of. In the execution of the transaction, it is necessary to consider (4) optimize the transaction logic to reduce the handling fee;
  2. However, if other players also find the spread, then (5), different players get different information speeds, assuming that several players in the head get the information and launch the transaction. Because (6) players want to be able to pass their own trades as quickly as possible, if they can quickly pass their own trades, the player will have the right to preemptive trading, and the winning players can predict (7) the future trading network form, prepare Participate in future transactions;
  3. Unexecuted transactions, because (8) will also bring a certain amount of trading losses;
  4. Finally, due to (9), in the process of the block and synchronization of the entire network, there will be a price difference, and the cycle will return to (A), and the arbitrage space will be re-occurred.

Based on observations, Philip Daian and the research team concluded the following conclusions :

  • By observing the atomic trading contract, it is estimated that such arbitrage has a profit of 6 million US dollars so far;
  • The arbitrage market is strong, and the strongest arbitrage robots have long-term access to most of the profits in the market;
  • The authors issued their own pass, called GasToken, which can be used to arbitrage the cost of the Gas through this new pass. Players can use this pass to reduce the price of the fee during the auction.
  • There is a certain degree of arbitrage space in the input error of the human transaction process. Some robots obtain unethical excess profits exclusively by robbing people of wrong orders. Since the decentralized exchanges are not regulated, these transactions cannot be rolled back;
  • The design of the entire decentralized trading system, due to the fee auction, made the miners the biggest beneficiaries. At present, many new DEX are trying new designs to solve the problems caused by the fee auction.

At the end of the article, through the simulation, the paper also analyzed two important blockchain protocol layer security vulnerability risks. However, since this article only discusses arbitrage logic, it will not be elaborated here.

How to solve the problem of preemptive trading?

In fact, it’s not just arbitrage robots that cause bidding. This vicious bidding can even happen between a few normal users. Due to the limited flow of blockchain, when many people try to trade, they will naturally raise the fee slowly. Just like the traffic increases every time the bull market rises, the transaction fee on the chain will skyrocket.

This seems to be an inevitable shortcoming of the current decentralized chain trading.

It can be seen that the core mechanism of a arbitrage of the decentralized exchange is the bidding process of the transaction order, and some teams have begun to solve the problems caused by this bidding mechanism. Their approach is to put the transaction matching process under the chain, so that the order of transactions is determined by time, which can effectively solve the (6) bidding problem. At the same time, since the transaction is coordinated online, the transaction can be carried out continuously, so that (9)(1)(2) can be solved, the spread can be minimized, and the arbitrage opportunity of inequality can be reduced.

This approach is more like a compromise between a fully centralized exchange and a fully decentralized exchange, giving users more choices.

Regarding how some decentralized exchanges solve the problem of preemptive transactions, the decentralized exchange agreement Hydro community recently wrote an article and made a good summary. You can refer to this article: "Bloomberg is also wrong, "The arbitrage" on the exchange is such a thing."

In the traditional trading market, the problem of preemptive transactions is also being explored. Brad Katsuyama, a character in the book "The Flash vs. A Wall Street Uprising", has established a new stock exchange called Investors Exhange in recent years. The core design of the exchange is guaranteed by new rules. Information can reach the user in the same period of time, thus preventing large customers from preemptive trading through engineering speed.

It is worth mentioning that Chanan seems to want to use the same system design to counter the unfair preemptive transactions against retail investors (details in the official document https://docs.binance.org/anti-frontrun.html) .

Just as the community explores decentralized governance, we seem to realize that simply translating information transparency and fair distribution of rights does not solve all problems. It is very likely that we still need a decentralized regulatory mechanism to allow users to protect their own interests through management mechanisms. Of course, how this is combined with the concept of "decentralized" encryption world is still a long road of exploration.

Written by: Jiang Mingrui, working for password currency hedge fund BitCapital

Source: Chain smell