Original title: "A deep dive into arbitrage on decentralized exchanges"
Original source: Nansen
Original compilation: 0x26
Arbitrageurs profit from price differences between different markets. In addition to earning these profits, arbitrageurs also serve the broader market ecosystem by aligning prices across different markets. In the world of decentralized exchanges (DEXs), arbitrage also exists. However, the nature of DEXs creates a more level playing field for traders large and small. This article aims to clarify the three mechanisms used in DEX arbitrage smart contracts, as well as Nansen's data analysis of specific DEX arbitrage addresses.
Let's start with the definition. A trading platform is an organized market where any trader can participate and buy or sell assets according to rules established by the market operator. In a centralized exchange (CEX), the trading market is hosted on the operator's private device and only authorized traders can use it. Orders placed by traders on CEX are sent to operators via a direct connection and processed behind the scenes. Traditional institutions like NYSE or Nasdaq, and crypto institutions like Coinbase or Binance are all forms of centralized exchanges.
In contrast, a decentralized trading platform, or DEX, is a Marketplaces on the Internet (such as the public Ethereum chain) can be accessed by anyone as long as they have access to the right tools. Unlike CEXs, orders submitted on DEXs are submitted to their respective blockchains, and transactions are executed using logic built into smart contracts deployed on that network. Uniswap and 0x Protocol are the two most used DEXs at the time of writing.
Finally, arbitrage is the process of simultaneously buying and selling assets, usually in different markets, to profit from price differences.
Say, you walk into a flea market and see a rare comic book for well below the market Priced to sell. You know your local comics dealer will be dying to have it in their display case. You call them and agree to sell to the dealership for a certain price while buying it from a garage sale for less so you can make a small profit. This is essentially how arbitrage works - you buy and sell assets in different markets and take advantage of the difference in price.
In the world of exchanges, arbitrage works very similarly, except that each market has multiple buyers and multiple sellers, and transactions on each market can also exert upward or downward pressure on prices. In fact, it is the pressure from arbitrageurs that has caused the market to tend towards law of one price.
Image source:Nymag
To illustrate the law of one price, suppose you have two vertical columns of water, A and B, each representing a market for the same asset, and the height of the water represents the price of that asset in the market. Now imagine that you attach a small tube with a valve to the bottom of these cylinders so that water can flow back and forth when the valve is open. This pipeline represents an arbitrageur between A and B.
Suppose the water in A is a little higher than the water in B, And the valve on the pipe between the two is closed. What happens to the height of the water in A and B when you open the valve?
When the valve is open, gravity will force water from A to flow into B, lowering the height of A and raising the height of B, until both are equal. This is exactly how the carry trade works — when the price is higher than normal, push it lower until it is in line with each other.
Now that we have a good understanding of what arbitrage is, let's talk about the main risk arbitrageurs face when trading on a trading platform in this way - execution risk.
When a trader submits an order to the trading platform, it may take a while to confirm or "settle" the order. During this time, the price of the asset may change in an unfavorable way for the trader. This is what we call execution risk, and it exists in all kinds of trading markets today. In the comic book example above, when you're buying a comic book at the flea market, you're faced with the very real possibility that the dealer doesn't think the comic book is worth the price you negotiated, and when you walk into their store, they will give you a lower price. This is similar to execution risk. Furthermore, this situation should illustrate why going to the comic book store as soon as possible after buying a comic book is an optimal option.
To offset execution risk, traditional financial firms invest quickly and in huge amounts. In Michael Lewis's book "Flash Boys a>” detailed such an investment: a $300 million fiber optic cable from Chicago to New Jersey, just to save a few milliseconds of time in data transmission.
Image source:: Bloomberg
p>
For them, speed is everything and the biggest budget helps create the fastest trading system. Therefore, it is almost impossible to profit from arbitrage unless one has the most resources.
While small institutions or individual traders can make money through arbitrage, as the market becomes more and more crowded, large Players are getting bigger and their lives are getting harder. To put it bluntly, the companies with the deepest pockets are already finding ways to tip the scale in their favor. For example, sophisticated decentralized exchange (CEX) platform arbitrageurs are likely to run their bots on the same cloud provider as the trading platform they interact with.
In a decentralized trading environment, the ground rules are different and even small traders can make money. In contrast to CEXs, DEX arbitrageurs can operate without execution risk (although not all do, as explained below).
A particularly well-designed arbitrage contract can execute multiple trades in different markets, requiring only one trade. These on-chain contracts guarantee that all transactions will go through, or none of them will go through. This limits the downside for traders that they only pay gas fees for one failed transaction.
Again, in DEX transaction speed is no longer a major advantage. On Ethereum, the block time is about 15 seconds. Regardless of volume, traders must wait for the next trade to confirm their order. Therefore, reducing transaction processing time by a few milliseconds has almost no impact on your profitability. This provides a more level playing field for traders of all sizes compared to traditional CEX markets.
Miners play an important role in the DEX trading environment. The more gas you pay, the more likely miners will confirm your transaction first. Index traders are also vulnerable to frontrunning by miners or other third parties. When traders submit transactions to the blockchain network, other traders or miners can use the information they gain from these upcoming transactions to first submit their own transactions for processing.
Deal sequencing and front-running can be influenced by personal relationships or outside business transactions. For example, mining pools are likely to offer frontrunning service.
However, even with these risks, there is still a vibrant trading ecosystem on DEX. With the rapid pace of innovation and asset introduction, and the overall competitiveness of these markets, there are still many opportunities for players large and small to get a piece of the action, including arbitrageurs.
So we have an idea of the pros and cons of DEX arbitrage, let's look at some real world examples of traders arbitrage on DEXes.
We analyzed data from Uniswap and identified 3 DEX arbitrage smart contracts exhibiting different mechanisms and levels of complexity :
First category: The most complex arbitrage of the three. They leverage Gas tokens, flash loans, mempools, and transaction batching (wrapping multiple transactions across one or more DEXes into a single transaction)
The second category: Only use transaction batch processing to package multiple transactions between one or more decentralized trading systems into one transaction, without using other complicated methods.
The third category: arbitrage contracts will not be traded in batches. Instead, the operator performs two-point arbitrage using separate transactions. Nonetheless, some of these contracts may use other technologies such as Gas tokens.
Trade batching ensures Either all transactions pass, or none pass. In the comic book example, you can imagine a scenario where the comic book dealer comes to the garage sale, and you are simultaneously buying and selling comic books quickly in one place. On the other hand, you won't buy comic books from the flea market if the comic dealers don't show up.
Flash loans are another sophisticated technology that is closely related to transaction batching. They allow anyone to borrow the funds needed to complete a transaction and then pay them back in the same transaction. Let's continue the same plot where the deal batch at the comics dealer meets you at the garage sale. You might consider using a flash loan, which is like having a cash-carrying friend at the same garage sale who will lend you the money you need to buy your comic book, and paying them back the loan as soon as you sell the comic book to the dealer. Using this mechanism, arbitrageurs don’t need a lot of capital to make money — they simply borrow and return funds through flash loans without risking any collateral.
Gas tokens allow arbitrageurs to reduce smart contract transaction fees. Normally, when the Ethereum network is less busy and gas prices are lower, these arbitrageurs will arbitrage coinage at low prices. If they arbitrage when gas prices are higher, they burn those tokens instead of paying the current price. In the comic book example, you could think of gas tokens, like filling up the gas tank of a car when gas prices are low, and then driving the car a week later to complete the transaction, regardless of the current gas price.
Mempool (memory pool) replacement is a complex front-end technology. If an arbitrageur sees that their upcoming transaction may be frontrunned, and they don't want to fight back (they can outrun the frontrunner), they may create simple transactions with a higher gas price, canceling their initial transaction. This reduces potential losses for arbitrageurs. (Note that not all arbitrageurs are frontrunners, and not all frontrunners use this technique).
Going back to the comic example, let’s assume that a comic book store has a public auction on their web page This comic book. You bid top dollar for the comic, and thinking you've won, you drive to the store to close the deal. On your way there, you see someone outbid you (they replaced your deal). While you could raise your bid again (and replace their deal), you decide it's no longer worth your time and money and turn around and go home. This cuts your losses and saves you the time and gas you spend on trips to the store. This is more or less how Mempool replacement works.
Finally, two-point arbitrage using steps is the simplest mechanism. Such arbitrageurs buy and sell an asset back-to-back in two trades, hoping to turn a profit. More often than not, they don't because the more sophisticated arbitrageurs take the opportunity first, causing them to lose money overall.
Using Nanse, showing users an advanced on-chain arbitrageur's The data of 0x0000000000007f150bd6f54c40a34d7c3d5e9f56.
Data show that this contract was very active as it completed thousands of trades in about two months. Additionally, it appears to be active at all times, suggesting it may be a bot.
This screenshot only shows one page among many projects, but we can already see that this contract address is related to the externally owned Accounts (EOAs) that also took out flash loans and also had many transactions with various DEXes such as Uniswap and Sushiswap.
We can see that this contract address is running on Uniswap, Kyber, 0x, Bancor, Balancer and Sushiswap. Most interestingly, the data also shows a high number of self-destructing transactions, suggesting that it is also using gas tokens to reduce on-chain transaction costs.
Hope to pass This article helps users better understand what arbitrage is and how arbitrageurs trade between different decentralized exchanges (DEX).
Original link
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia