The vast range of DeFi platforms that have emerged over the last few years has made this market suffer from the problems inherent to their centralized alternatives, i.e. fragmentation and inefficient price formation. At the same time, all these discrepancies serve as fertile ground to traders as they provide numerous opportunities for arbitrage trading.
In this article, we are going to explore the basic principles of cryptocurrency arbitrage on DeFi, how one can make money with its help and what associated risks there exist.
Cryptocurrency arbitrage explained
Before exploring how arbitrage works in DeFi, it’s important to understand this phenomenon from a general perspective.
Crypto arbitrage is a trading strategy based on differences in asset prices across different platforms. Simply put, if you see that Bitcoin price varies by $100 on two different exchanges, you can buy it on one of them for a lower price and sell it on the other platform. This is what they call an arbitrage opportunity.
The reasons why these opportunities arise are aplenty. Here are some of the most popular ones:
- Variations in liquidity for the same asset across different platforms
- Differences in the time needed to deposit or withdraw assets from exchanges
- Supply and demand are not consistent
- Crypto-fiat exchange rates may differ, too
Regardless of the reason, these opportunities are usually very short-living. Therefore, to spot one, you must be either very lucky or rely on automated algorithms that would do that for you.
Cryptocurrency arbitrage in DeFi
In the case of DeFi, the situation is pretty much the same. To make profits, traders look through liquidity pools to spot assets that differ in price from the market average. They buy these assets at lower prices, drive the demand upward and thus bring them in line with the market.
While DeFi platforms come with their own perks and features, the main approach is the same. Some of the most popular DeFi platforms providing opportunities for arbitrage trading include Balancer, Uniswap, Yearn.Finance, and Compound.
How can one spot an arbitrage opportunity on DeFi? The most obvious way to do this is to thoroughly monitor the asset prices and compare them to the market. The best time for such opportunities to arise is a ‘pump and dump’ as different markets cannot stay consistent during big price movements that occur in a blink of an eye.
However, aside from the obvious, you will not easily find working techniques on the web. Cunning traders rely on their own experience when building their strategies and creating automated bots, and be sure that they will keep them secret. Don’t be down on them, as they follow a well-known rule of a trader: the more people use the same strategy, the less effective it becomes. There’s no need to despair, though, as we can give some hints on where you can start.
» We are 10Clouds: Introducing the DeFi Developer Roadmap
Arbitrage trading methods in DeFi markets
Crypto arbitrage on DeFi can be accomplished in a number of different ways. Opportunities may arise within a single pool as well as across multiple platforms, including centralized ones. In our explanation below, we split arbitrage methods into Yield Arbitrage and Cross-platform trading.
1. Trading two assets on a single platform
One of the simplest methods of arbitrage is on a single platform, when you take advantage of the short-lived differences in rates during swaps in liquidity pools. If a trader notices that the borrowing APR of a given asset is below the supply APR of another asset, they can borrow the former against the latter, and in doing so make a profit.
Let’s illustrate this with an example from Balancer:
In Balancer V2 an arbitrage can be achieved when there is a price discrepancy between liquidity pools holding the same assets.
Balancer rewards users who can identify the imbalance between pools with the profit
Let's say we have 3 liquidity pools:
a) ETH-USDC
b) USDC-USDT
c) USDT-ETH
In pool a 1 ETH costs 3000 USDC, in pool b 1 USDC costs 1 USDT, in pool c 1ETH costs 2000 USDT.
We can notice a price discrepancy between pools a and c.
By swapping 1ETH in pool a we get 3000 USDC, we then swap our USDC for USDT in pool b (1:1 ratio), and finally swap our 3000 USDT in pool c for 1.5 ETH - netting 0.5 ETH in the process.
A similar transaction on Balancer V2 is described here. The user netted over 1,3ETH after performing 3 swaps.
The key risks of this strategy include the episodic nature of such opportunities. Also, the rates may change for the worse before you finalize your order, which may result in losses. Gas costs are also an important factor that may negatively affect your trade, especially with the Ethereum network.
2. Cross-platform trading
It’s important to note that cross-platform trading can happen on one blockchain (as in the examples above) or on different blockchains. They can even happen off-chain, in the case of CEXes. There are some nuances, though.
First, you may come across some difficulties if you trade across platforms based on different blockchains such as Polygon and Binance Smart Chain, for example. To resolve this problem, there are a number of services aimed at bridging different blockchains between each other and facilitating the swaps.
Second, there is the same problem with swapping assets between centralized and decentralized exchanges. For that purpose, bridges also exist, though it may be a challenging task to find a solution for a specific set of platforms. The general market fragmentation is here to blame. When using bridges, you sometimes have to wait a long time for the transfer to complete and in doing so, miss your arbitrage opportunity.
Finally, another issue is that of high gas fees for transitions between platforms, which in and of themselves lower potential for profit. This is where yield farming comes into play.
MEV Exploits
Miner Extractable Value (MEV) is another important aspect related to arbitrage. It is ‘a measure of a profit miners can make through their ability to arbitrarily include, exclude, or re-order transactions within the blocks they produce.’ MEV is an increasingly large market on Ethereum, with an estimated $1–4MM in value per day. It has a significant impact on both the usability and security of blockchains. Some of the forms of MEV include front-running and sandwich attacks.
Sandwich attacks occur when a user exchanges a significant sum of crypto (e.g. ETH to DAI). A bot notes the transaction and front-runs the user by purchasing the second asset before the user’s trade goes through. This pushes the price of the 2nd asset upward and increases the expected price fluctuation (slippage). Thus, the victim has to buy the second asset at a higher rate while the attacker sells it at higher rates, too, and gets profits.
Front-running is a situation when a potentially profitable transaction is spotted, replicated with higher gas price, and executed before the original transaction (due to the higher gas price).
Both of those attacks can cause a potential arbitrageur to lose their profits.
Summing up
While new technologies open up new opportunities of making money, they bear a plethora of risks that traders must be aware of. If you want to test your luck in crypto arbitrage in DeFi you must also be ready to stand against all the associated dangers.
The good news is there are already solutions available to help users protect themselves from MEV attacks.
1. Using Flashbots Protect RPC to ensure transactions won’t be seen by MEV bots in the public mempool.
2. Using Defi products that offer protection against it internally:
- 1inch - uses Flashbots internally to protect Users from MEV exploits
- CowSwap - leverages batch auctions with uniform clearing prices for all trades in the same batch. Because of the uniform clearing price, there is no need for ordering the transactions within a single batch. Because everyone receives the same price across assets it’s not possible for any value to be extracted by placing transactions in a certain order. This prevents the primary strategy used in MEV.
- mistX - The unique technology underlying the mistX platform utilises Flashbots and as such transactions processed via mistX do not publish user transaction information to a public mempool, but instead bundle transactions together. This effectively hides the information from front-runners and thus prevents your transactions from being manipulated, front-run, or sandwiched.