Skip to main content

When to Use This Pattern

Use this pattern when ERC4626 deposit or withdraw calls must not dilute existing or remaining shares. It applies to yield aggregators, lending protocols with ERC4626 interest-bearing tokens, liquidity pools using ERC4626 shares, and staking protocols with ERC4626 receipt tokens. This pattern checks share-price monotonicity around matched deposit and withdraw calls. It does not cover mint/redeem entry points or batch-wide preview-function validation.

What This Pattern Checks

Checks ERC4626 share-price safety around deposit and withdraw calls:
  • registerAssertionSpec(AssertionSpec.Reshiram): Registers the assertion as a Reshiram assertion.
  • registerFnCallTrigger(): Runs the assertion around deposit and withdraw calls.
  • ph.context(): Reads the current call frame.
  • PhEvm.ForkId({forkType: 2, callIndex: ctx.callStart}) / PhEvm.ForkId({forkType: 3, callIndex: ctx.callEnd}): Reads pre-call and post-call snapshots.
  • ph.loadStateAt(): Loads total assets and total supply at each snapshot.

Assertion Pattern

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