MEV, sandwich attacks and JIT

Nov 2022

by Johnny Chuang, Anderson Chen

Table Of Contents

Overview

All transactions on Ethereum are sent to the Memory Pool (Mempool) first, so arbitrageurs have all kept their eyes on all transactions that are flowing into the Mempool. The issues of MEV have long been in discussion by the Ethereum community and developers, but there has not been much research based on these MEV problems.

In this article, we hope to shed light on two prominent MEVs: Sandwich & JIT, by analyzing on-chain data of Uniswap V3 combined with our experiences as arbitrageurs and liquidity providers.

Methodology

Overview

As of 2022/10/31, WETH-USDC 0.05% Pool accounts for 56.32% ($531.48M) of the total volume ($916.44M) traded on Uniswap V3 Ethereum. As the most iconic trading pair with more than half of the trading volume, we believe digging into the data of this pair will give us insights about the general idea of MEV in Uniswap V3. Therefore, in this research, we decided to focus on the trades & liquidity provision in WETH-USDC 0.05% Pool.

We parsed the swap, add/remove liquidity event data in the past six months from Subgraph, put them into human-readable tables, and using the Python Pandas package to analyze these data. To be more specific, for Sandwich Attacks, we used swap data only; while for JIT (Just In Time) Liquidity, we used swap data and liquidity provision data combined to see if the prevalence of such a move exists.

Data Source

We used the Subgraph created by @ianlapham, the dev from Uniswap, to get the data we need for this research. We used swap/add liquidity/remove liquidity data from 2022/05/01 to 2022/10/28 (exact 180 days) to get all the results displayed in this article.

Sandwich Attacks

The key to understanding Sandwich attacks is to understand their profitability. We simplified any arbitrary Sandwich attacker’s profitability can de defined as Revenue - Cost, where:

Sandwich Profit = Sandwich Revenue - Sandwich Cost

In this simplified model, a Sandwich attack will be profitable if revenue is greater than cost. It is worth noting that we did not consider the cost to bribe miners, so the actual situation might be slightly different.