Skip to main content
JIT Routing (Just-in-Time Routing) is DFlow’s onchain routing mechanism that updates trade routes at execution time to find the best possible prices. Traditional Solana aggregators compute routes offchain and embed a fixed path into the transaction. Once signed, that route cannot change. If prices move before execution, the transaction either executes or fails due to slippage limits. JIT Routing moves part of the routing decision onchain. The swap transaction contains conditional logic that allows the router to select between liquidity sources during execution, based on current onchain prices.

When JIT Routing Is Used

JIT routing engages automatically when the router determines it is optimal.

Execution Flow

  1. Quote time (offchain)
    • DFlow computes an optimal route using current market data.
    • The route may include prop AMMs and fallback venues.
  2. Transaction construction
    • The transaction embeds conditional instructions.
    • These instructions allow branching between liquidity sources.
  3. Execution time (onchain)
    • Before executing, the program checks the current onchain price.
    • If the price is within acceptable bounds, the original leg is executed.
    • If the price has moved beyond a threshold, the router switches to an alternative venue.
    • All decisions occur within the same transaction.
The route is finalized at execution, not at quote time.

Key Properties

  • Onchain decision making Routing decisions are made by the program during execution, not by offchain infrastructure.
  • Single transaction Rerouting does not require resubmission or multiple transactions.
  • Deterministic constraints All possible branches are known and encoded at transaction construction time.
  • No user interaction changes Users still request a quote and sign a transaction as usual.

Benefits for Builders

  • Lower realized slippage Execution reflects current prices instead of stale quotes.
  • Higher success rates Fewer transactions fail due to price movement exceeding slippage tolerance.
  • Reduced need for wide slippage limits Less exposure to adverse execution caused by conservative slippage settings.

Comparison to Static Routing

AspectStatic RoutingJIT Routing
Route selectionOffchain, fixedOnchain, conditional
Reaction to price changesNoneImmediate
Failure risk in fast marketsHighLower

Availability

JIT Routing is enabled automatically for eligible routes when using the DFlow Trading API. No additional parameters are required from builders.