What's JIT Routing?
Overview
JIT (Just-In-Time) Routing changes how an onchain swap picks its path. The route is no longer fixed when you get the quote. When the transaction executes onchain, the swap looks at the market again and switches to whichever path gives more tokens, all in one transaction.
You still sign once. The contract handles the rest.
Why does this matter?
Standard DEX aggregators decide the best route before you sign, based on the prices they see at that moment. Blockchains don't execute your transaction instantly. By the time it lands onchain, the picture can change:
Someone else trades through the same pool first.
A market maker pulls back and widens its spread.
LPs that looked deep at quote time withdraw their liquidity.
An MEV bot front-runs or sandwiches your transaction.
The token is volatile and the price just moves.
When that happens, the price you actually receive drifts from the quote. Set slippage too tight and the swap reverts. Set it too loose and you eat poor fills or get sandwiched.
JIT Routing was built to close that gap.
How does JIT Routing work?
The router still produces a quote off-chain. The difference is that it prepares more than one candidate path, and the transaction itself carries conditional logic. When it executes onchain:
The smart contract checks each candidate pool's current state.
It picks the one with the highest output.
Everything settles in a single atomic transaction.
If the originally selected pool is still the best, the trade goes through it. If another candidate looks better by the time the block lands, the trade reroutes automatically. The user does nothing different. The logic sits inside the transaction itself.
OKX JIT routing with three-step quote and re-quote flow at execution
Key benefits
More tokens received
Comparing pools at execution time means the trade can grab the better path even when conditions move after the quote. On average users get more output, and the bigger the trade the more it matters.
Lower realized slippage
Routing decisions happen close to when the trade actually settles, so the gap between quoted price and executed price shrinks. Users can keep slippage tolerance tighter without losing fill rate.
Higher swap success rate
Most failed swaps come from prices moving past the slippage limit. Reacting to the latest pool state makes that less likely. Fewer reverts, less wasted gas.
Protection against PropAMM spoofing
Proprietary market makers (PropAMMs) sometimes show tight quotes to attract order flow and then widen their spread before the trade settles. JIT Routing compares actual onchain output at settlement, so if the quoted venue worsened the trade switches.
Better resilience to liquidity removal
Some liquidity looks deep at quote time and disappears before trade lands. The onchain re-check spots this and skips the pool.
How can I enable JIT Routing function?
You don't need to. It's on by default and finds the best price for you on every swap. When it's active for your trade, look for the "JIT Routing" tag in the top-right corner of the provider card.
OKX DEX Swap page with JIT Routing tag on provider card
FAQ
Is JIT Routing safe?
Yes. The logic runs inside audited smart contracts. The trade only settles if it satisfies the user's minimum-received condition. If no candidate path meets it, the transaction reverts and funds stay in the wallet.
Do I need to do anything differently as a user?
No. You see one quote and sign one transaction. No extra steps, no extra signatures, no extra protocol fee. Slippage settings still apply. JIT Routing sits on top of them, it doesn't replace them.
Will it make my swap slower?
Not really. The candidate paths are prepared off-chain ahead of time. The onchain comparison happens inside the same transaction, so settlement takes about as long as any regular swap on that chain.
Does JIT Routing always give me a better price?
Not always. Sometimes the originally selected pool is still the best and the trade goes through it unchanged. What matters is that when conditions change the trade isn't stuck with a stale path. Over many trades the average outcome improves.
Does it cost extra gas?
Yes, a bit. The contract does extra pool comparisons onchain, which costs a little more gas. Usually the extra tokens you get back outweigh that. On chains with cheap gas (Solana, BSC), the overhead is small enough to ignore.
Does it replace slippage protection?
No. Slippage tolerance still defines the worst price you're willing to accept. JIT Routing makes that worst case hit less often, but you should still set slippage based on how volatile the pair is.
Does it work for all tokens and chains?
It helps most for volatile pairs, large swap sizes, and swaps that touch PropAMM or PMM liquidity. Right now it's live on Ethereum, BSC, and Solana. More EVM chains are coming.