SLIPPAGE WHEN WET: An Intro into the world of MEV
Slippage is an important factor to consider in DeFi trading, as it can impact the overall cost and outcome of trades. MEV is “…ETHEREUM’S INVISIBLE TAX” that already cost traders over USD 1.5bn
This article draws on insights from an article and lecture by Magnus Woodgate, Principal Researcher at Romulus Technologies. His open lecture was hosted by the University of Zurich Blockchain Center in collaboration with DeFi AM.
Slippage is an important factor to consider in DeFi trading, as it can impact the overall cost and outcome of trades. By understanding the causes of slippage and employing strategies to manage it, traders can better navigate the DeFi landscape and optimize their trading performance. Always remember to assess the market conditions and liquidity before executing large trades to minimize the risk of unfavorable price movements.
TO GO BACK TO WHERE IT ALL BEGINS; WHAT IS SLIPPAGE?
Slippage occurs when there is a disparity between the intended execution price of a trade and the price at which the trade is actually executed. This can happen for several reasons, including:
Market Volatility: High volatility can cause prices to move rapidly, leading to a difference between the expected price and the actual execution price.
Low Liquidity: In markets with low liquidity, there may not be enough buyers or sellers at the desired price, causing the trade to be executed at a less favorable price.
Order Size: Large orders can significantly impact the market price, especially in low-liquidity environments, leading to slippage.
The invariant curves here demonstrate different type of pricing a swapper will receive when they come to the pool, i.e. the larger the swap size, the more slippage, but not all invariant curves are the same.
Slippage is particularly important, because is often spoken about in combination with MEV as some forms of negative MEV can impact a user’s slippage (e.g. trade execution) giving the user a worse resulting price.
SO WHAT IS MEV?
MEV literally is “Maximal Extractable Value”. It’s influencing the ordering of transactions (TXs) in the blockchain.
Transaction ordering is the sequence in which transactions are arranged within a block. Since the order can affect the outcome of transactions, miners and validators have the power to optimize the order to their advantage or the advantage of those willing to pay for preferential treatment.
Let’s go over the most well known types of MEV transaction ordering:
Front-running: This occurs when a miner sees a profitable transaction pending in the mempool (the pool of unconfirmed transactions) and inserts their transaction just before it. For example, if a transaction is about to purchase a significant amount of a token, the miner can buy the token first, causing the price to rise, and then sell it at the higher price after the original transaction is executed.
Back-running: In this strategy, the miner inserts their transaction immediately after a known profitable transaction. For example, if a large buy order is expected to drive up the price of a token, the miner could place a buy order just after this to benefit from the price increase.
Sandwich Attacks: This is a combination of front-running and back-running. A miner places a transaction before and after a target transaction. For instance, the miner can first buy a token before a large buy order to drive the price up and then sell the token right after the large buy order is executed, profiting from the price difference.
And everything else… anything from one off token unlocks to DAO voting systems and all new kinds of token formats that aren’t even developed yet!
WHAT’S A MEMPOOL?
Another key concept to be understood when it comes to MEV and a lot of the systems surrounding modern MEV design is the mempool i.e. the memory pool of transactions.
A common feature of many chains, although not all blockchains support the ability to monitor the mempool like Ethereum does.
This in part is due to the activities of MEV and some blockchain’s intentional design decisions to reduce some of the more negative MEV, however most chains still have an internal mempool that is visible whoever is in control of the RPC endpoint.
Let’s take a look at what is happening with the mempool on Ethereum:
So as you can see users submit their transaction (TX) to the mempool, where searchers monitor and then submit directly to “builders” who are able to combine multiple TXs from a wide arrange of searchers into a full block.
FLASHBOTS.
So what is Flashbots? An iconic name (to those who know Flashboys), inspired the brilliant piece of research published in Flash Boys 2.0, outlining the issues with public PGAs (priority gas auctions) and how MEV searchers were driving up gas prices, and sending a lot of unnecessary TXs to the blockchains they were taking place on.
The result: a Geth extension, enabling direct MEV Auctions for Ethereum, while generating additional yield for those who run it.
As you can see, even as of 2021 there was a particularly wide adoption of the MEV-geth patch ontop of the original go-ethereum client.
If you’re interested in learning more about flashbots, checkout their docs.
SO WHY SHOULD I CARE?
According to Coin Telegraph, MEV can also be called:
“…ETHEREUM’S INVISIBLE TAX”
And furthermore, CowSwap also states:
“…MEV HAS COST TRADERS OVER $1.5 BILLION IN LOSSES.”
And these activities don’t just apply to Ethereum but a large majority of today’s blockchain systems.
IT IMPACTS USER’S PERFORMANCE.
Users / traders can receive worse execution if not taking MEV into account (very similar to the original days of HFT in TradFi with rapidly changing order book liquidity).
Users / traders are missing out on generating additional revenue from their order flow.
MEV systems are constantly evolving and remaining unaware may only negatively impact your on-chain experience in new and unforeseen ways.
BUT IT IS NOT ALL BAD!
Arbitrage (and back running MEV) keeps the DeFi markets efficient, so you don’t have to worry about negative price discrepencies between pools / other on-chain venues.
Some systems want MEV searchers, they actually need them to function! E.g. liquidation systems such as Aave to keep the protocol safe for depositors.
The existence of MEV has created brilliant concepts like the monetization of order flow, bringing extra rewards to the users of DeFi.
In any case, let’s dig into some examples and shine some light on this dark forest.
3.2 MILLION USD PROFIT IN A SINGLE TX.
This specific case is an arbitrage TX between two WBTC / WETH Uniswap pools.
The searcher made a profit of $3.2 million out of this singular arbitrage TX.
The searcher paid 1.2582 ETH to the miner as a “bribe” (to ensure their TX was prioritized before any competition).
This swap borrowed about 297 WBTC directly from Uniswap, using the flash swap mechanism possible with atomic TXs and modern AMM.
SYNTHETIX PROTOCOL CONTRACT DEPRECATION
NOTE: This section I felt the need to add due to the great article by Robert Miller, check out their original blog post here.
In May of 2021, an “alpha leaker” KALEB posted the following message in the the Flashbots public searchers discord:
This opportunity highlighted a one off opportunity to liquidate millions of dollars in outstanding loans, but there would be no opportunity for months.
As you can see, there is not shortage of effort that goes into singular TXs in terms of identifying opportunties and ensuring you will be able to actual act on them are two completely different games.
In the end the plan was for the searcher (Robert Miller) to submit the bundle via Flashbots, but there happened to be a string of non-Flashbots blocks, meaning the TX did not go through in time!
The winner ended up submitting a TX through the public mempool (with all of its risks) and won.
JIT LIQUIDITY PROVISIONING
JIT (Just in Time) LPing is the process of sandwiching a TX, where the frontrun TX adds liquidity, and then the backrun TX removes the liquidity.
This concept applies specifically to concentrated liquidity protocols (such as Uniswap V3).
This was a real example, shown with a real TX on Ethereum. In this case these TXs were bundled together and sent through Flashbots (according to Uniswap).
This would allow a searcher to potentially take 100% of the fees the pool would have given to other liquidity providers within the tick range.
I.E. AS AN LP YOU MISS OUT ON YIELD.
This problem seemed to generate enough attention that the Uniswap foundation researched into their on-chain swap data to analyze how often this happens.
The summary of this data analysis was:As a percentage of total USD trading volume on Uniswap, JIT has not been significant or growing, either. Over the past 6 months, Uniswap supported an average of $50bn of trading volume per month on Ethereum mainnet. With the exception of July and September 2021, the amount of trading volume executed against JIT liquidity has never risen above 0.5% on a monthly basis.
IN SUMMARY
It’s a dark forest out there.
Not all MEV is bad.
MEV is helping to grow the DeFi ecosystem.
Don’t get MEVd.
Link to the original article [link].