Skip to content

Uniswap V3 MEV activity

@alexth@alexth51 charts

2. Gas Fees Analysis

Here, we compare the gas fees paid by arbitrage bots, sandwich bots, and organic users.

Results

  • The results appear to be in line with expectations. MEV bots are paying significantly higher gas fees on average, especially sandwich bots

1.2 Time series visualisations

  • We can see a decrease in the proportion of MEV bot volume over time, and a corresponding increase in the proportion of organic activity
  • Similarly, we see the proportion of MEV bot transactions decreasing over time, and a corresponding increase in the proportion of organic transactions
  • The proportion of sandwich transactions is steadily decreasing over time
  • The proportion of unique arbitrage bots interacting with Uniswap V3 is steadily increasing over time

Arbitrage

An arbitrage transaction is defined as follows: a series of 2 or more trades, occurring in the same transaction where the very first token bought (token in) is the same as the very last token sold (token out). This means that the entire arbitrage transaction can be found under a single transaction hash on Etherscan.

i.e. token_in = token_out in a single transaction

A profitable arbitrage is one where the tokens_out > tokens_in

3. Trading Pair Analysis

  • In this, we breakdown the MEV bot and organic activity for individual trading pairs on Uniswap V3.
  • The table below shows stats for every single individual liquidity trading pair over the its entire history, ranked by organic volume in descending order
  • The pie charts summarise the distribution for the top 20 pools for percentage of arbitrage bot, percentage of sandwich bot, and percentage of organic activity respectively

Results

  • Interestingly, we can see some of the high liquidity pools with a vast majority of their transactions comprised by MEV bots. Such pools are usdt-usdc (70% MEV bot) and link-weth (80% MEV bot)

Sandwich attack

A sandwich attack typically involves both front-running and back-running a large dex swap, where the attacker buys and sells the same asset as the victim. Typically, it starts with the attacker buying before the victim transaction and selling after.

Unlike arbitrage, a complete sandwich attack cannot occur in a single transaction, but using Flashbots or some other relay service, the attack is tightly bundled such that the two attacking transactions are only separated by the victim transaction.

A much rarer form of sandwich involves a sell first and buy last by the attacker. This is much rarer because it involves holding the possibly volatile asset in order to sell it first.

The logic to identify a sandwich attacker is as follows:

  1. Two separate trades, t1 and t2 in no particular order, in the same block initiated by the same address
  2. Both trades inititated on the same project
  3. Token bought in t1 = token sold in t2
  4. Token sold in t1 = token bought in t2
  5. Amount bought in t1 = Amount sold in t2
  6. Amount sold in t1 < amount bought in t2 (excluded) (index of t1 >= index of t2 + 2) or (index of t2 >= index of t1 + 2)
  7. exclude uniswap v2 and v3 router address since this gets included as a false positive for some reason
  • This logic should work to include both buy-first and less common sell-first sandwiches
  • By excluding point 6, we also include sandwich attacks that made a loss
  • By using '>=' instead of just '=' in point 7, we can also include sandwich attackers that are perhaps not using flashbots and not tightly bundling their transactions

Uniswap V3 MEV activity

  • In this dashboard, we analyse the MEV bot activity of Uniswap V3 and compare that to its organic trading activity.
  • We classify an MEV bot as any smart contract that engages in arbitrage, sandwich attack, or just-in-time (JIT) liquidity transaction
  • A running commentary on the results is provided
  • Note: The stats quoted on the text widgets are subject to change over time and may not be equal to the query results forever. The query results should be seen as the true values

Contents

  1. Volume, transactions, users + time series visualisations
  2. Gas Fees
  3. Trading Pairs
  4. Just-in-time (JIT)
  5. Future research

Just-in-Time liquidity attack

  • JIT liquidity is a special form of liquidity provision where an LP mints and burns a concentrated position immediately before and after a swap
  • JIT attacks are similar to sandwich attacks in that they both involve a both a front-run and a back-run of the victim transaction, but in the case of JIT the attacker adds and removes liquidity instead of buying and selling

1.1. Volume, transactions, and users

  • The summary stats below represent the daily average over the past 6 months.
  • JIT attacks are not included here and have their own section since the attacks are liquidity transactions and don't contribute to swap volume
  • Note: For sandwich and arbitrage bots, the activity identified encapsulates all trading activity by these bots. Not all of this activity will fall under the definition of MEV. This is because these bots will likely have fund management functions that will sell their MEV profits into stablecoins or other tokens of choice
  • The reason for this analysis method is that during the course of building this dashboard, we have developed and saved two separate MEV tables to the Dune Analytics Spellbook, one for arbitrage bots and another for sandwich bots. Directly using these tables of MEV bots is much faster than dealing with MEV transactions. It also gives a more complete overview of overall activity by these MEV bots.
  • However, a transaction focused research can easily be accomplished in the future, at the expense of longer queries, by analysing MEV transactions directly.

Results

  • Almost half of all the trading activity on Uniswap V2 comes from MEV bots
  • The vast majority of MEV bot activity, around 75%, comes from arbitrage bots
  • Sandwich bots have an average transaction size of around $50k, which is slightly higher than than arbitrage bots
  • Organic traders have a much lower average transaction size than the MEV bots, around $25k
  • Compared to arbitrage bots, there are very few unique sandwich bots per day - around 20 for sandwich vs 325 for arbitrage vs almost 7000 unique organic users per day

4. Just-in-time (JIT) liquidity attacks

  • Revenue = fees earned
  • Profit = fees earned - gas(add liqudity) - gas(remove liquidity) - miner share

Note: profit figures, which are not calculated here, may be much lower than revenue figures

Results

  • JIT appears to be a much rarer form of MEV than arbitrage or sandwich, with only around 18,335 on Uniswap V3 at time of writing (November 2022)
  • Only about 15 addresses have ever attempted a JIT attack, as seen in the 'All JIT attackers' table
  • Only about 6 addresses have earned significant revenue from JIT attacks, as seen in the 'JIT attackers with stats' table. The distribution of fees earned by these addresses in shown in the pie chart
  • JIT requires a very large amount of capital to be profitable over other forms of MEV and cannot be executed with flash loans since it occurs over multiple transactions
  • JIT attackers use approximately the same amount of gas as normal sandwich attackers. This makes sense because JIT also involves a sandwich but with liquidity instead of swaps
  • On the revenue chart, we can see a day that towards the end of August 2021 that was extremely unprofitable for JIT attackers. Note that this single day may be significantly lowering the average revenue figure
  • The amount of JIT liquidity being supplied over time is increasing over time, with a sharp increase appearing in recent times. However, this needs to be compared to the total volume to see whether this increase is due an overall increase in volume or some or reasons (noted for future research)
  • There is just one address driving the vast majority of JIT activity on Uniswap V3, with around a 90% share of the all revenue earned by JIT
  • The success of JIT attacks seems to be improving with less attacks resulting in a loss for attackers over time
  • It is interesting to note that the top JIT attacker is a generalized front-runner as well, meaning that it can front-run other MEV attempts
  • Note that, due to gas fees, actual profit figures may be vastly different from the revenue figures displayed below

Future Research

This dashboard is by no means complete or totally accurate. Fortunately, we are aware of some ways in which can be improved:

  1. For sandwich and arbitrage analysis, use transactions instead of wallet addresses for a more accurate analysis of actual MEV. This applies to the individual trading pair analysis as well
  2. Include profit statistics for all sections, this involves subtracting gas fees from the total revenue. For sandwich and JIT attacks, this involves calculating gas paid for both front-runs and backruns
  3. Analyse summary stats and charts of the victims of MEV for sandwich and arbitrage. This has already been provided for JIT 4. Add functionality for any uniswap user to check their individual MEV victim statstics i.e if they have been sandwich or JIT attacked, back run by arbitrage (although this arbitrage is benign to the user), and how much gas fees they have paid. We would then be able to report to the user in detail how much MEV has been extracted from them
  4. Analyse gas fees paid from both successful and failed MEV transactions
  5. Investigate the day where the attackers lost a lot of money through JIT attacks. Also remove it from the standard analysis to show revenue figures more accurately
  6. Investigate JIT in relation to volume on Uniswap V3.
  7. Fee tier research