Skip to main content

When to Use This Pattern

Monitors and limits cumulative token outflows to prevent catastrophic asset loss during exploits, creating a response window for protocol operators. Use it for lending reserves, vault custody, bridge escrows, treasuries, liquidity pools, and other contracts where rapid ERC20 withdrawals are a critical risk. This is a V2 Reshiram circuit-breaker pattern. The rolling-window accounting is handled by the trigger/precompile machinery, not by assertion-authored storage.

What This Pattern Checks

Registers a percentage-based cumulative outflow limit:
  • registerAssertionSpec(AssertionSpec.Reshiram): Registers the assertion as a Reshiram assertion.
  • watchCumulativeOutflow(token, thresholdBps, windowDuration, assertFn): Watches ERC20 outflow over a rolling window.
  • ph.outflowContext(): Reads the token context inside the triggered assertion.
  • Reverts when cumulative outflow breaches the configured threshold.
The assertion does not manually store balances or rolling counters. The Reshiram circuit-breaker trigger is responsible for tracking the window and invoking the assertion when the limit is exceeded.
As of May 6, 2026, the v2 Reshiram spec is not live on Linea mainnet. Treat this pattern as a local, development, or forward-looking example until Linea mainnet supports the spec.
For more information about cheatcodes, see the Cheatcodes Documentation.

Assertion Pattern

Full examples and mock protocol code are available in credible-std.