Quantifyng ‘Just-in-Time’ liquidity in Uniswap v3
PART 1. Analyzing what is and how JIT liquidity affects regular LP’s returns
The utilization of JIT liquidity strategies by some flashbots searchers is something that could become a concern for Uniswap v3’s users as it can have the short term effect of decreasing LPs returns, and in the long term potentially cast some doubts about the long-term stability of the Uniswap v3 protocol if regular liquidity providers can become disincentivized to provide liquidity. In this article I will try to quantify the impact of this strategy and shed some light into this still somewhat obscure topic.
What is ‘Just-in-Time’ liquidity?
Firstly, in order to give a clear explanation of how this strategy works, I will quote a great thread from the revert.finance twitter:
The main implications of this strategy for Uniswap v3 actors could be summarized as:
- Traders get a reduction on expected price impact as a consequence of the spike in liquidity, but in the extreme case where all liquidity is JIT, price discovery would be extremely difficult.
- Liquidity Providers not using this strategy get a reduction on expected returns as fees accrued decrease, but impermanent loss does not.
Identification of ‘Just-in-Time’ liquidity operations
Providers of JIT liquidity require the use of private relays, such as flashbots, in order to organize the transactions that will formthe “sandwhich” (add liquidity at the beggining of the block and remove liquidity after the swap). JIT liquidity happens in a specific block and requires of big capital concentrated in the narrowest range available, in order to dilute the active liquidity provided by the rest of LPs.
An example of this kind of operation could be this flashbots bundle #2 in block 12931127:
1- JIT LP add 8,951,953.29 USDC 8,519.64 Ether for a total USD value of approx 29.824.445 $ according to Uniswap TheGraph data.
Usually liquidity in active tick for this pool range between 3 M$ and 4 M$, so this addition accounts for something between 80% and 90% of liquidity available on the block.
2- JIT LP include meaningful swaps in his bundle for a total of 58.61 ETH swapped, although theoretically any number of swaps is feasible, the majority of JIT liquidity sandwiches included one huge swap only:
3- JIT LP remove 8,826,855.94 USDC and 8,570.708 ETH of liquidity and collect 0,1536 ETH of fees (calculated subtracting remove amounts from collect amounts):
The difference in token amounts are close to 50 ETH, so JIT LP takes aprox 80% of the swap, diluting the fees accrued to pool LPs from 0,17853 ETH (0,3% fee) to 0,02223 ETH.
4- JIT LP pay a bribe/fee of 0,070856 ETH to the miner in order to get his bundle mined.
Not all of this JIT operation seems to has a positive EV at least taking in consideration on-chain data, nevertheless the stratetgy decreases regular LP returns by diluting fees accrued for a block, no matter if the JIT liquidity is profitable or not.
In a next chapter of this series i will try to analyze total returns of this MEV strategy considering searcher side.
Data model to identify JIT liquidity operations
With the objective of calculating the fees that are diluted by these operations I will use data from the Uniswap v3 graph as described in the following steps:
1 Query all ‘mints’, ‘burns’ (decrease liquidity event of uniswap v3 pool contracts) and ‘collects’ (decreased liquidity plus fees accrued) since 1th of June for a specific pool looking for the following parameters:
- Block number, transaction Id, Origin EOA and gas price paid
- Amount of tokens minted, burned and collecteded (Including a total amount converted to USD value)
- Range of prices selected by the LP, expressed as (tickLower, tickUpper)
2 Select mints, burns and collects with a gas price of 0 gwei (this indicates that flashbots relay has been used) and the narrowest ranges of prices available on the specific pool. This approach will not work for JIT liquidity operations happeningafter EIP-1559.
3 Group mints, burns and collects that happen in the same block and have been originated by the same EOA.
4 Calculate fees accrued by every JIT liquidity operation as total tokens collected minus total tokens burned.
5 Query poolDaydata of the uniswap v3 graph in order to estimate the total fees generated by the pool and compare it to the fees extracted by JIT operations.
A python script with the code used to run this analysis is available in my Github
Results for ETH/stables pools
The workflow described above has been applied to 9 pools (ETH/USDC, ETH/DAI and ETH/USDT *3 fee tiers for every pool) but only in 6 of them JIT liquidity operations were observed. Overall results are provided in the next table:
Taking in consideration the total fees accrued by the different pools seems that JIT liquidity is not taking too much of the cake yet.
Looking to timeseries of the data generated there is no clear pattern of JIT liquidity growth:
Conclusions:
- JIT liquidity is not a generalized MEV or LP strategy as it targets less than 1% of the blocks and seems to be run by just one actor.
- No conclusion about wether there is space for more operations in this pools or additional searchers should compete for the same opportunities.
- JIT liquidity has not decreased substantially regular LP returns.
- JIT liquidity is not a risk-less MEV strategy as can result in losses if it analyzed in a isolated way.
- Apparently these operations are being runned by a single operator that use 0xa57bd0013… as a proxy contract, raising the question of wether this strategy is not EV positive for other MEV searchers or market maker actors or we just have to wait to see it explode.
Reach me at twitter or join LP cafe discord to continue the discussion
A repo with all the code used is available on my github
Join Coinmonks Telegram Channel and learn about crypto trading and investing
Also, Read
- YouHodler vs CoinLoan vs Hodlnaut | Cryptohopper vs HaasBot
- Binance vs Kraken | Dollar-Cost Averaging Trading Bot
- How to buy Bitcoin in India? | WazirX Review | BitMEX Review
- Bitcoin Taproot | Bitso Review | Top 6 Bitcoin Credit Card
- How to buy Ripple (XRP) | Best Crypto Exchanges in Africa
- Best Crypto Exchanges in Africa | Hoo Exchange Review
- eToro vs Robinhood | MoonXBT vs Bybit vs Bityard
- Stormgain Review | Bexplus Review | Binance vs Bittrex