Skip to content
ChainBrief

News from across Web3

How just-in-time liquidity works on Uniswap during a pending swap

How just-in-time liquidity works on Uniswap: a provider adds range liquidity before a swap, earns fees during it, then withdraws in the same block.

The ChainBrief Editors

How just-in-time liquidity works on Uniswap during a pending swap

On Uniswap v3, just-in-time (JIT) liquidity is liquidity added around a pending swap’s price, used during that swap, and withdrawn in the same block so the provider can capture its fees.

The key is transaction order: fees follow active liquidity while the swap executes, not how long a position has been open.

JIT providers add liquidity, capture swap fees, then withdraw

A liquidity provider (LP) deposits tokens into a pool so traders can swap against them. In Uniswap v3, an LP can concentrate liquidity within a selected price range; it earns fees when trades use that liquidity while the pool price is in range.

A JIT bot watches the mempool, where pending transactions may be visible before they are included in a block. It identifies a swap whose size and price path could generate enough fees to justify a targeted position, then arranges to add liquidity immediately before the swap and remove it immediately afterward.

For a swap you are making, consider private transaction submission or a wallet’s front-running protection to reduce public exposure. Flashbots supports ordered transaction bundles sent to builders, one way a searcher can arrange the liquidity addition, target swap and withdrawal in sequence.

That ordering is MEV: value gained by influencing which transactions are included and in what order. If the bundle is included as arranged, the temporary position is active for the target trade and can earn a share of its fees.

Fee allocation depends on active liquidity during execution. A JIT position may be present for only one swap yet receive a large share of that swap’s fees if it supplies much of the liquidity in the relevant price range. Longstanding LPs still earn fees, but the added position can dilute their share for that trade. The brief provider’s fee return per unit of time can therefore exceed that of an LP whose capital sits in the pool for longer.

A USDC-to-WETH trade shows what changes hands

Say a trader submits a USDC-to-WETH swap. A JIT provider estimates the trade’s price path, deposits USDC and WETH into a narrow range around it, and has the swap execute against the deeper pool. The provider then removes the position and collects its fees. The withdrawal returns the position’s changed token balances: the swap has shifted its inventory, and the fee is added to what the provider receives.

The extra depth can reduce the trader’s price impact compared with the same pool without the JIT position. At the same time, the temporary liquidity takes a portion of the trade’s fees that would otherwise be shared among existing LPs. Whether the position is profitable depends on whether those fees exceed gas costs and any payment to the builder, while accounting for hedging costs and the value of the changed token inventory.

Change the trade to WETH-to-USDC and the provider’s inventory shift reverses direction: it ends with a different balance of each token. The same-block sequence and fee logic still apply, but the provider’s exposure and hedging needs change.

Related

Is JIT liquidity a sandwich attack?

JIT liquidity supplies depth for the target swap and earns fees when that swap uses it. A conventional sandwich places trades before and after the user’s swap to benefit from the price movement it causes; it does not provide liquidity for the user’s trade in the same way.

Can beginners provide JIT liquidity?

Providing JIT liquidity in practice requires automated monitoring, capital, transaction simulation and access to builders or another reliable ordering route. Flashbots bundles are one route for submitting a chosen transaction sequence, but the economics still depend on execution costs, fees and inventory risk.