JIT Liquidity

Just-in-time (JIT) liquidity has become an important topic of discussion. In this post, we discuss the mechanics and future of JIT liquidity on Solana.

Mechanics of JIT liquidity

JIT liquidity is a form of MEV utilized by sophisticated AMM LPs (let’s call them JITers) to capture a large fraction of the fees associated with individual swaps. Unlike passive LPs, JITers provide liquidity for a very short time period, lasting only long enough for a single swap.

To see how this is profitable, consider the mechanics of JIT transaction:

  1. Identify a pending swap
  2. Mint a LP position fully concentrated on the ticks covering the price range of the swap
  3. Earn the LP fees for the swap when it executes
  4. Burn the LP position, withdrawing liquidity from the pool along with any fees

JITers own ~100% of the liquidity available for the swap, so they can earn ~100% of the pro-rata share of fees.

JIT transactions are risky

Unlike many forms of MEV, providing JIT liquidity is not riskless. With each transaction, a JITer takes on inventory risk.

Consider a typical arbitrage transaction. A searcher starts with 1000 SOL, executes a series of DEX swaps, and ends with 1001 SOL. The searcher’s portfolio starts 100% SOL and ends 100% SOL.

Now, consider a hypothetical JIT transaction:

  1. Identify a pending user swap of 150 USDC for 10 SOL
  2. Mint a LP position requiring 1500 USDC and 50 SOL
  3. Swap executes against this liquidity
  4. Burn the LP position, withdrawing 1650 USDC, 40 SOL and 0.1 SOL in fees

The JITer ends up with less SOL and more USDC. If the SOL-USDC price stays constant at 15, they walk away with 0.1 SOL in profit. But if the SOL-USDC price moves to 16, they suffer a loss of 6.8 SOL.

Managing inventory risk

To manage inventory risk, JITers will usually hedge on a CEX. The JITer has to pay fees and slippage on the CEX, so fees earned on the JIT have to be large enough to justify the costs.

JITers may also decide to engage only when prices are moving in their favor. By managing inventory risk in this way, an adverse selection effect may come into play where the majority of toxic flow is offloaded on passive LPs.

Role of bundles

To guarantee sequential and atomic execution of the relevant transactions, JIT liquidity happens with bundles submitted via off-chain blockspace auctions like Flashbots or Jito. The bundle includes the LP position mint, user swap and LP position burn.

To successfully land the JIT transaction, the JITer has to outbid all other searchers who want to include the user swap in their MEV bundle. As discussed below, this competition has important implications for which types of swaps are JITed.

Capital requirements

Providing JIT liquidity is a capital-intensive business. Given the off-chain hedging costs, only large swaps can be profitably JITed. Hence a large amount of capital is needed to mint the LP position on-chain and put on off-chain CEX positions.

Note that flash loans are not viable for a JIT transaction since it requires the execution of someone else’s swap. However, instead of flash loans from lending protocols, flash loans provided directly by block builders could make JIT viable for low capital searchers.

JIT Liquidity: Good or Bad?

It is useful to consider the parties impacted by JITers: traders and passive LPs.

Traders

JIT liquidity generally benefits traders. Assuming passive LPs do not change the amount of liquidity they provide, JITed transactions should incur less price impact. Given that providing JIT liquidity is expensive, it seems as if it can only be profitable to JIT when the trader would be getting a particularly bad price on the AMM.

However, the Uniswap Research model shows there is a theoretical upper bound on the price improvement, assuming blockspace auctions are efficient. Too much price improvement implies the user swap would be more valuable when utilized in a different MEV bundle, such as a backrun or sandwich.

The long-term effects of JIT liquidity for traders are unclear. If a large fraction of swap volume is JITed, passive LPs may disappear due to diluted yields, reducing AMM liquidity. Small traders may have to turn to alternative venues to execute all together.

Passive LPs

Passive LP returns are composed of swap fees and impermanent loss.

IL results from the divergence of pool prices and an LP’s entry price. Since JIT transactions do not change the long-term price trajectory of pool prices, IL is unchanged by JITers.

On the other hand, LP returns are negatively impacted via fee dilution. JITers only filled ~0.3% of all liquidity demand on Uniswap v3, so fee dilution may not be a major concern. However, gas prices on Ethereum impose a uniquely high cost on JITers. On high performance chains like Solana, the 0.3% number could end up being significantly larger.

There is an important caveat to point out. Making the claim that JITers dilute LP yields assumes that the large traders stick around in the absence of JITers. Since JIT provides order improvement, if JITers were eliminated, large traders may move orders elsewhere. If JITers are only handling swaps that would otherwise occur on a CEX, their presence has little to no impact on passive LP yields.

Impact on AMMs

It is difficult to predict the long-term effect of JIT liquidity on AMMs. However, it seems that too much JIT activity implies the disappearance of passive LPs. Too little JIT activity implies that traders may seek alternative venues for better execution. So, dApps are being increasingly forced to develop strategies to effectively handle JITers.

Strategies for handling JITers

As of now, there have been two approaches taken by dApps in response to JITers:

One approach is to impose burn delays. In Ambient, a pool has a minimum time-to-live (TTL) parameter. Each LP position gets timestamped at mint and cannot be burned until the TTL interval has passed. The interval can last anywhere from 0 to 255 seconds. Any TTL > 0 makes atomic JIT infeasible. However, to eliminate JITers willing to hold on to risk for some time, longer TTLs may be necessary. Ambient is flexible in their approach to JIT, allowing governance to atomically and temporarily lower TTL to zero for whitelisted addresses. The thinking is that some JITers will make long-term commitments ensuring low toxicity and market quality.

A second approach is withdrawal fees. Kyberswap effectively uses a vesting schedule for LP fees, so the amount of fees an LP positions earns is proportional to how long it was active. JIT positions are minted/burned quickly, so they are entitled to only a very small fee share.

Designing DEXs around JITers

Other DEXs have deviated significantly from the traditional AMM set-up. Rather than moving fully to a CLOB, many of these designs resemble hybrids of the AMM and RFQ models.

In the Carbon Protocol, traders can post orders which trade in a single direction and are defined by a user-defined bonding curve. These orders sit on-chain and LPs can pick off the relevant orders as they move into the money. In this design, there are no passive LPs at all. To earn fees, any LP must actively pick off orders exactly like JITers.

Drift v2 implements a hybrid model for perps that attempts to get the best of both worlds, JIT liquidity and AMMs. Once a user order is received, it is put through a 5-second Dutch auction in which JITers can bid on filling the order. In case no market maker wants to fill the order, it gets executed against a constant product vAMM, which guarantees execution.

Future of JIT liquidity on Solana

JIT liquidity remains muted on Solana AMMs like Orca. The reason is a key missing piece of MEV infrastructure: bundles which potentially multiple signers. However, with the roll out of Jito bundles, JIT liquidity on Solana is an important topic to consider.

More or Less JIT Activity?

JIT transactions could make up a comparatively large fraction of AMM volume on Solana.

First, negligible transaction fees lower the fixed costs of providing JIT liquidity. Swaps that typically would be to small to profitably JIT on Ethereum could be viable targets.

Second, negligible transaction fees could expand the types of bundles submitted by JITers. We have only focused on vanilla JIT transactions, but in many cases a JIT transaction can be used in combination with a frontrun or backrun.

As @0x94305 explains here, in a world with low fees, JITers can pursue more complex bundles. Consider an AMM pool which sits at the CEX price. A large swap comes in with a zero slippage parameter, which means a sandwich is not possible. It seems as if the best strategy is a backrun. But what about a sandwich + JIT attack? Concretely:

  1. Frontrun the swap, moving the AMM price to the execution price of the swap in a world without the JITer
  2. Mint a very large LP position at that execution price
  3. Execute the large swap against the liquidity
  4. Burn the LP position
  5. Backrun the swap, moving the AMM price back to the CEX price

In this case, the searcher earns the profit from the vanilla backrun strategy, but also swap fees. The downside is that it requires three extra instructions. In a low fee world, this is not an issue. Importantly, the trader experiences no price improvement, since their execution price is the same as in a world without the JITer.

Shorter block times may have the opposite effect. As previously discussed, some JITers may only engage when AMM prices are out of line with faster moving CEXs. Solana’s 400ms block times could limit the lookback window for JITers to identify and take advantage of such price discrepancies, potentially making certain swaps less attractive from the JIT perspective.

Centralization Risks

The profitability of JIT activity imposes a centralization risk to Solana. We already know that JIT is closer to stat arb than atomic MEV and requires searchers to maintain a large capital base. Negligible fees and short block times could unfortunately make the situation worse.

If low fees make smaller swaps (due to lower fixed costs) and large swaps (due to complex “sandwich + JIT”-type bundles) viable for JITers, this could push out other searchers from including those swaps in their MEV bundles.

Short block times also exacerbate advantages to better-capitalized searchers. Faster CEX access is a crucial for JITers since they want to be able to observe CEX prices as long as possible before hedging the on-chain LP position. Similarly, searchers want low latency access to block builders, so they can submit their bundle as late as possible. So, we may be in a situation where the only searchers able to compete are those who can colocate with builders, buy specialized hardware, and have access to fast CEX data feeds.