Skip to main content
The band guard keeps an op’s output within a two-sided range around its simulated value. It adds two on-chain checks:
  • output ≥ simulated × (10000 − bps) / 10000, rounded down
  • output ≤ simulated × (10000 + bps) / 10000, rounded up
If the output at execution falls outside that range, the transaction reverts. The compile result reports no minimum for the guarded port.

When to use it

Use band where a move in either direction is a problem, above all the pool price a liquidity deposit sees. A deposit that executes after the price moved, for example after a sandwich trade, adds liquidity at a worse ratio, and a floor alone can’t catch that. The Uniswap deposit ops expose the price they read just before the deposit for this guard: These ops have no other price protection. Pair the band guard with a slippage guard on liquidity, which floors the LP amount the deposit mints.

Config

Example

Add 1,000 USDC and 0.25 WETH to the Uniswap V2 USDC/WETH pair on Ethereum. The transaction reverts if the pool price moved more than 0.5% either way, or if the deposit mints less than 99.5% of the simulated LP amount:
The unused side of the deposit comes back as a residual and is swept to the sender with the LP tokens. For a full Uniswap walkthrough, including V3 positions, see Add liquidity on Uniswap.