The unfair advantage

Bots can't plan for a price that doesn't exist yet.

A sandwich attack needs to know almost exactly where your trade will land, so it can front-run and back-run it for profit. Protected-lane swaps break that assumption: the settlement boundary is chosen by Chainlink VRF after the swap is committed, not before.

  • No off-chain keeper, no oracle to trust
  • Real VRF, not a same-block pseudo-random trick
  • LPs get paid extra, not the hook
HazeHook · Sepolia
beforeSwap → impact > 0.5%?
  └─ yes → revert, must commitSwap()

commitSwap → requestRandomness()
  └─ VRF fulfills off-chain

settleSwap → candidate = VRF % 5
  └─ swap bounded by candidate price
  └─ 0.1% premium donated to LPs

Good questions.

Why do small swaps skip all of this?+

Sandwich attacks only make sense when there's enough price movement to profit from. A hook that protects every trade equally would just slow everyone down for no reason — so only swaps that cross the risk threshold get routed through commit/settle.

Is this actually random, or just obfuscated?+

It's real Chainlink VRF v2.5 — a verifiable randomness oracle, not a pseudo-random on-chain trick like block.prevrandao. The value doesn't exist anywhere until after your swap is already committed.

Does this mean my swap always executes at a worse price?+

No — the randomness picks a boundary, not a price. Your swap still executes against the real pool; the boundary just moves within a tight ±0.20% band so an attacker can't calculate the exact setup in advance.

Who pays for this protection?+

A small premium (0.10% of the settled amount) is added on protected-lane swaps and routed directly to liquidity providers — not the protocol.