Skip to main content
The slippage guard protects users from adverse execution by asserting at simulation time that an op’s output port produces at least (1 - bps/10000) of the expected amount. Attach it to any op whose output is not already minimum-guaranteed by the aggregator — typically lifi.zap, core.call, and custom contract interactions. You do not usually need a slippage guard on lifi.swap: LI.FI’s aggregator already provides a minimum-out value (providesMinimum: true), and passing slippage: 0.03 in the op config bakes a 3% floor into the quote itself.

Example

Attach a 100 bps (1%) slippage guard to a zap’s amountOut port:
builder.lifi.zap('zap', {
  bind: { amountIn: builder.inputs.amountIn },
  config: {
    resourceOut: resources.erc20(A_ETH_USDC, 1),
  },
  guards: [guards.slippage({ port: 'amountOut', bps: 100 })],
});
See Build a Flow for attaching guards, interpreting failures, and choosing tolerances.