Beneath the Surface of Uniswap Pools: Just-in-Time Liquidity

Riyad Carey
Kaiko
Published in
9 min readFeb 2, 2023

--

Sign up for Kaiko’s research newsletters here.

This piece was originally going to compare the average and median size of liquidity events — meaning any mint (deposit) or burn (withdrawal) to/from a DEX liquidity pool — on the most popular Ethereum DEXs: Uniswap V3, V2, and Curve. There have been some excellent Twitter threads comparing DEXs and considering whether providing liquidity on Uniswap V3 can be profitable.

But after taking a look at the Uniswap V3 liquidity event data, it became clear that I had to write about an under-explored and rapidly developing topic: just-in-time (JIT) liquidity.

Uniswap V2 to V3: Evolution or Metamorphosis?

Uniswap V2 (and Sushiswap, which forked Uniswap’s code) was the highway that made early DeFi work. It was easy for new projects to create liquidity pools and easy for users to provide liquidity. Known as LPs (liquidity providers), users could deposit equal USD amounts of a token — for example, 1 ETH + 1600 USDC in today’s prices — and receive LP tokens representing their share of the pool. Many protocols incentivized LPing by providing their token as a reward; those of us active in DeFi in mid 2020 may remember staking YAM-ETH LP tokens on the YAM Finance site to receive YAM rewards.

This system had some drawbacks, namely capital inefficiency (the V3 whitepaper notes that, because liquidity is spread across the entire price range, most of it is “never touched”) and impermanent loss.

This all changed with the release of Uniswap V3, which brought with it concentrated liquidity. This allows LPs to choose a price range in which to provide their liquidity. When price is within the range they select, they will earn fees, and when it moves higher or lower, their liquidity is not used and thus will not earn fees.

After launch, Uniswap V3 quickly captured most of SushiSwap and V2’s market share and today it is the largest DEX on Ethereum by volume.

Despite their similar interfaces and shared name, Uniswap V2 and V3 function quite differently. Nowhere is this more apparent than when looking at liquidity events.

V2 vs. V3: Liquidity Analysis

Predictably, with the release of Uniswap V3, liquidity quickly began flowing out from V2 pools. Below we can see that on the week V3 was released there were $272mn in burns and $154mn in mints in the WETH-USDC V2 pool (one of the largest V2 pools). Throughout the early 2021 bull market there were usually between $50mn and $200mn worth of mints and burns each week. These days, it’s rare for mints or burns to exceed $1mn in a week.

Shown a different way, we can see the net flows into and from this pool.

This chart is fairly predictable, with large outflows during the dramatic collapses of the past year and a net burn of $446mn since the release of Uniswap V3.

So what does LP activity on Uniswap V3 look like? Let’s look at the largest WETH-USDC pool on V3, which carries a 0.05% swap fee. (V3 also introduced different fee tiers, so pools either have a 0.01%, 0.05%, or 0.3% fee; there are separate WETH-USDC pools at each fee tier.)

Okay, that looks pretty similar, with some more active weeks, except… wait, is that $20bn on the y axis? These sums are astonishingly large; on January 12, 2023 the sum of all liquidity events (mints plus burns) in this pool was $12.7 billion. The week of January 8 this figure was $56 billion, almost 300 times more than the TVL of the pool. The largest events week for our V2 pool above was just $426 million!

My first two thoughts upon seeing this were: 1) there is some sort of data error; or 2) just-in-time (JIT) liquidity is much (much) more prevalent than I thought.

Just-in-Time Liquidity

As described by Uniswap, JIT liquidity involves an LP spotting a pending swap, adding concentrated liquidity to the pool the swap will go through in a tight range around the price, letting the swap execute, and removing the liquidity and fees. This is all done in a single block.

Here’s a very simplified version of what a JIT liquidity event looks like:

Imagine there is $1,000 of liquidity concentrated in a $0.01 price range. As an LP, I see that someone has submitted a swap of $100 worth of a token, which will incur a fee of $1. Within the same block, I add $9,000 of liquidity in that small range, which now represents 90% of liquidity in the range. This means I will receive 90% of the $1 fee, leaving the static LPs with just 10 cents compared to my 90 cents (minus gas fees and MEV cost). There is a small fee earned in this example, but as we will see, JIT liquidity events are in the tens of millions of dollars.

There are some important points to note here:

  • JIT events are much larger — usually over $10mn — so they can capture enough of the fees to offset fixed costs like gas.
  • Because of this, events volume is usually larger than actual trade volume.
  • Not all JIT events are successful. Because they are such complicated transactions, there are a few things that can go wrong (adding at the wrong price range, adding for a non-swap transaction, etc.). Below we will examine all JIT attempts, which are not necessarily successful.
  • The trader actually gets better price execution; they are essentially receiving on-demand liquidity for a large swap.

Additionally, JIT is feasible only on Uniswap V3 because of its concentrated liquidity. In the example above, if it were a Uniswap V2 pool, my JIT liquidity would be a fraction of all of the liquidity in the pool, rather than a huge proportion of the liquidity in that small range, thus netting me a much smaller share of the swap fee. Additionally, I would have less ability to mitigate impermanent loss.

JIT liquidity is thus a way for lightning quick LPs to extract value within a block without the risk of impermanent loss that comes with latent liquidity. So how can we tell a JIT event from a regular event? While it is hard to come up with definitive numbers, we can make assumptions on each transaction with a fairly high confidence level.

The two sides of a JIT transaction will occur in the same block and thus have the same timestamp and are reciprocal: a mint will have a corresponding burn. The wallet addresses conducting a JIT transaction will also be the same.

When charting each transaction, another trend jumps out: JIT transactions are large. There is an obvious gap between the smaller, organic transactions (the tiny circles at the bottom of each chart) and large JIT transactions, with few events in the $1mn to $10mn range.

If you look closely, you can see that large mints are matched almost perfectly with burns. (Mints and burns had to be charted separately, otherwise they would overlap.) These are JIT transactions. Let’s zoom in on the smaller events.

Here there are clusters of activity, but mints are not matched perfectly with burns. This tracks with what we would expect to see for organic liquidity events.

Using our assumptions that JIT liquidity is added and removed in the same block, with the same upper and lower tick (i.e., price range), and nearly the same number of tokens in each event, we have estimated that 50% of liquidity events on January 12 were JIT, representing 99% of liquidity event volume.

Because JIT transactions are so large, the addresses that engage in this activity dominate liquidity event volume. The top 20 addresses have accounted for 93% ($434bn of the $467bn) of the total liquidity event volume in this pool since November 2022. The largest address has contributed 25% of all liquidity event volume in this time frame.

This strategy is incredibly capital intensive. The largest address did $118bn in total event volume in just 5,150 transactions for an average of nearly $23mn per transaction. The high technical and capital barriers to entry likely played a role in JIT’s relative rarity (as described in Uniswap’s piece) earlier in V3’s history, though it seems the floodgates are open now.

A Fuller Picture

The Uniswap V3 WETH-USDC 0.05% has the highest proportion of JIT events out of all V3 pools. The reason for this is explained in the Uniswap piece linked above; essentially it is because larger trades are more likely to go through the largest pools and the tokens in the largest pools are more liquid on CEXs, making JIT easier to hedge. For comparison’s sake, here is a sample of the last 2 days from the APE-WETH 0.3% pool.

The crosshair shape shows an overlapping mint and burn, which has a good chance of being a JIT event. This pool has a TVL of just under $8mn but there were seven (likely) JIT events of over $10mn in this time frame. This pool’s highest total liquidity event day was also January 12, 2023, though it topped out at just over $800mn, compared to $12.7bn in the previously examined pool. So, while JIT liquidity on this pool pales in comparison to the previous pool, it is certainly present.

Add swaps on top and zoom in on a couple hours and we get a good idea of what this all looks like in practice:

There’s a trade that likely uses JIT liquidity early on, but the two largest swaps have no corresponding JIT events. Additionally, the two largest JIT attempts had no large (over 10k APE, about $60k USD) swaps in the same block. The vast majority of swaps are not impacted by JIT liquidity. JIT liquidity is still a messy and imperfect science.

Conclusion

Some others, including Uniswap, have attempted to quantify trade volumes that have been affected by JIT liquidity. Their estimates put it at under 0.5% of volume through most of 2022, while a more recent estimate from a researcher showed it increasing to 3.5% in December 2022. We have not attempted to quantify the trading volume that is being affected by JIT liquidity, but this is an interesting area of future research. Here are some takeaways from my research on the topic:

  • Like lots of things in crypto, the terminology around this can be confusing. In many articles I’ve seen JIT liquidity events referred to as “MEV attacks”. The word “attack” here carries negative connotations that I don’t think are justified, in part because of the next point.
  • JIT liquidity is usually beneficial for traders. It essentially serves as on-demand liquidity for large trades, reducing their price impact and giving better execution.
  • JIT liquidity is probably not great for passive LPs. We haven’t quantified how much in fees JIT LPs take, but any sum greater than $0 is money that isn’t going to passive LPs. As mentioned above, the profitability of less sophisticated LPs on V3 has been a controversial topic that I won’t wade into here but suffice to say that V3’s LP environment is miles more cutthroat than V2’s ever was.
  • JIT liquidity is growing. The Uniswap article on the phenomenon written in September 2022 stated that these transactions were “very rare” between May 2021 and June 2022. We can safely say that they are not rare today.
  • The Uniswap team and UNI token holders will have to decide whether they want to attempt to get rid of JIT liquidity. There are murmurings that Uniswap V4 will be released this year, and if it is it will be interesting to see whether the team attempts to mitigate JIT liquidity.
  • TVL is not a complete measure of liquidity on Uniswap V3. V3 now has a lot in common with a centralized order book, with liquidity constantly being added and pulled. Any institution trading on the DEX without snapshots and events has an incomplete picture of any pool’s liquidity.

--

--