When the simulation runs
Composer simulates the flow against the latest state of its chain whenever the response needs a measured value: a guard to evaluate, a terminal output to report, an epilogue forward to measure, or a handle an op exposes. Measured amounts appear asoutputs[key].amount.estimate with basis: "simulated". A flow that needs none of these skips the simulation, and its estimates come from quotes (basis: "quoted").
The simulation assumes the signer holds the amounts the flow pulls and has granted its approvals. It is not byte-for-byte the transaction the user signs. To also simulate that exact transaction, set run.simulateUserProgram: true; a success is echoed as userProgramSimulation.
What a guard is
A guard’s check is part of the final calldata, so the transaction itself enforces the invariant; nothing relaxes it after the simulation. Production serves three guards:
See the Guards catalog for each guard’s config.
When guards run
The simulation reads the value of every port a guard observes. Composer then turns each guard into a check with a bound derived from that value, and compiles the checks into the calldata it returns. The checks run onchain, inside the user’s transaction. A guard can fail at three points:- At compile time,
guard_error(HTTP 422). The guard cannot be attached: it targets a port that does not exist, has the wrong kind, or cannot be guarded. - During simulation,
simulation_revert(HTTP 422). The simulated flow reverted. UndersimulationPolicy: "allow-revert"the calldata is returned as HTTP 206 with the revert diagnostics instead. - Onchain. A
slippageorbandcheck cannot fail in the simulation that set its bound. It fails if the chain state moves past the bound before the transaction lands, and the transaction then reverts.
Where guards can attach
A guard’scompatibility.selectors list says which ports it can attach to, and the compile rejects any other attachment. Two kinds of port are unguardable for every guard:
- Ports that declare
providesMinimum: true. The op already enforces its own minimum.lifi.swap’samountOutis the canonical example: itsslippageconfig setsminOut. SeeprovidesMinimumfor the other ports. - Ports with
availability: "future". A bridge, LI.FI Intents order orcontinuation.settleoutput lands after the transaction. Its simulated value is an estimate made in the initiating transaction, so a guard on it would enforce nothing.
lifi.zap’s amountOut does not provide its own minimum, which is why the Swap and deposit recipe attaches a slippage guard there. In a cross-chain flow, the minimum received comes from the settle op, not from a guard on it; to protect the destination flow itself, attach a guard to an op inside it. See Cross-chain flows.
The manifest (GET /compose/manifest) shows which output ports carry providesMinimum or future availability.
Guaranteed minimums
Aslippage guard also produces a guaranteed minimum: the worst-case value of the port given the guard’s tolerance. The response reports it as outputs[key].amount.minimum = { value, basis: "guard" } for the resource output the guard protects. Your UI can show “you will receive at least X” from that field.
Ops produce floors too (basis: "op", for example a swap’s minOut). When both exist, the larger floor wins; it is tagged guard only when the guard floor is strictly larger. With several guards on one port, the largest minimum wins. A band guard reports no minimum: it bounds the value in both directions but promises no amount.
A guard on a handle port produces no reported minimum, because outputs lists only resource outputs. To surface one, turn the handle into a resource with core.asResource and guard that resource.
Common guard failures
What guards do not do
- Guards don’t change routing. If the market moves past a guard’s bound before the transaction lands, the transaction reverts; Composer never reroutes to honour the bound. To make the aggregator honour a tolerance, configure it on the op, for example
lifi.swap’sslippage. - Guards don’t describe state before the transaction. Preconditions do: they tell the simulation what state to assume, such as a wallet balance. Guards act on values computed during the transaction.
See also
- Guards catalog: every guard registered in the manifest.
- Execution Model: the full compile sequence.

