Skip to main content

JIT routing reference

Reference for JITSettler on Ethereum mainnet. For how to use it, see Integrate JIT routing.

Contracts​

ContractRoleAddress
JITSettlerThe only contract you call and approve.0x96A875242618E50450F470646FFF8980fC2d406B
SandboxCalls the route's executor for the settler. Never approve it.SANDBOX() on the settler
BuilderNet posterThe address that BuilderNet posts routes from. Your contract checks it before it runs a route.0x4a1f5Ac5652F8046dC1088095d34a21c526cE548

The settler has no owner and cannot be upgraded. Its source is in flashbots/JITSettler.

Interface​

// The contract source calls the poster `setter`. Parameter names do not change the ABI.
interface IJITSettler {
struct Request {
address tokenIn;
address tokenOut;
uint256 amountIn;
uint256 amountOutMin;
address recipient;
}

function peek(Request calldata req) external view returns (address poster);
function swap(Request calldata req, bool callback) external returns (uint256 amountOut);
function reportDefault(Request calldata req, uint256 amountOut) external;

function setRoute(address executor, bytes calldata data) external;
function currentRoute() external view returns (address poster, address caller);
function SANDBOX() external view returns (address);

event JITRoutedV1(
address indexed caller,
address indexed poster,
address indexed executor,
address tokenIn,
address tokenOut,
address recipient,
uint256 amountIn,
uint256 amountOutMin,
uint256 amountOut
);

event JITDefaultV1(
address indexed reporter,
address indexed tokenIn,
address indexed tokenOut,
address recipient,
uint256 amountIn,
uint256 amountOutMin,
uint256 amountOut
);

error NoRoute();
error RouteDeclined();
error TransferFailed();
error InsufficientOutput(uint256 amountOut, uint256 amountOutMin);
}

// Implement this if you call swap with `callback` set.
interface ISettlerCaller {
function routeAvailable(address poster) external returns (uint256 amountOutMin);
}

Request​

FieldMeaning
tokenInERC-20 token that the settler transfers from your contract.
tokenOutERC-20 token paid to recipient.
amountInExact amount of tokenIn transferred.
amountOutMinLeast tokenOut that recipient can receive.
recipientReceives tokenOut.

Functions​

FunctionBehaviour
peek(req)Returns the poster of the route that is live in this block, or 0 if there is none. The settler does not read req. The builder reads it when it simulates your transaction.
swap(req, callback)Fills req through the live route. Returns amountOut, the increase in recipient's tokenOut balance. Reverts on any failure. With callback set, it first calls routeAvailable(poster) on msg.sender.
reportDefault(req, amountOut)Emits JITDefaultV1. Changes no state. See Report your route.
setRoute(executor, data)Posts the route for this block. The poster is msg.sender. A later post replaces an earlier one.
currentRoute()While a route runs, returns its poster and the caller of the swap. At any other time, both are 0.

The settler holds one route at a time. A route is live at the block.timestamp it was posted at, and one successful swap uses it up. A swap that reverts leaves it live.

A route is not tied to a request. It runs for the next caller that swaps while it is live. The builder therefore clears a live route before a swap that it did not route: it posts a route with executor 0, which makes that swap revert, and your route runs. peek still returns the builder's poster in that case.

The floor of a fill is req.amountOutMin, or the value that routeAvailable returned if that is larger. The settler measures a fill as the change in recipient's tokenOut balance. Anything else that raises that balance during the swap counts as output too, such as a rebase or a transfer from a token hook.

Errors​

ErrorWhen
NoRoute()No route is live in this block.
RouteDeclined()With callback set, your contract declined: routeAvailable reverted, is not implemented, returned less than 32 bytes, or posted a route itself.
TransferFailed()The transfer of tokenIn from your contract failed.
InsufficientOutput(amountOut, amountOutMin)recipient received less than the floor.

swap can also revert with data from the route's executor, or with empty data. Handle every revert the same way.

Events​

EventEmitted byMeaning
JITRoutedV1swap, once for each fillcaller is your contract. amountOutMin is the floor that applied. amountOut is what recipient received, after the posting charge and the fee.
JITDefaultV1reportDefaultreporter is the contract that called it. amountOut is what the reporter says its own route paid.

Read both events from the settler's address only.

Supported tokens​

The supported tokens are published with their addresses at https://jit-router-universe.buildernet.org/v1/latest.json. Both tokens of a swap must be in that list. A swap with any other token gets no route. The list also names native ETH, which some venues trade directly.

The settler does not accept native ETH, so wrap it first.

Supported venues​

The venues that the JIT router uses are published in the same file. The list changes as the JIT router adds and removes venues. v1/index.json at the same host lists every published version, and a published version never changes. When other routers can supply routes, the venues a swap can fill on will depend on the routers that take part.

The settler does not enforce the token and venue lists. They describe what the JIT router searches.

Fees​

The builder takes two amounts from a route's output, in tokenOut, before the route pays recipient:

  • The posting charge. The builder pays the gas for the transaction that posts your route, and recovers that cost.
  • A fee of 10% of the improvement that remains over your route's output. The fee applies from 10 December 2026. Before that date, the builder takes only the posting charge.

The settler has no fee logic. The route pays both amounts itself, and the floor applies to what recipient receives.

Gas​

Measured on a mainnet fork for a swap of 1 WETH to USDC through one Uniswap V3 pool. Figures are the gas of the calls, without the transaction's base cost.

CaseGas
No route posted: peek returns 0about 6k
reportDefault, after your route ranabout 3.5k
Fill: swapabout 177k
Fill: peek, then swapabout 200k

A fill replaces your route, so the net cost of a fill is its gas less the gas of your route. Run the sample tests to measure your own integration.