Skip to content

Certora: verify ERC4626 round-trip properties - #465

Merged
MathisGD merged 10 commits into
mainfrom
claude/certora-erc4626-roundtrip
Aug 27, 2026
Merged

Certora: verify ERC4626 round-trip properties#465
MathisGD merged 10 commits into
mainfrom
claude/certora-erc4626-roundtrip

Conversation

@claude

@claude claude Bot commented Jul 24, 2026

Copy link
Copy Markdown

Requested by Mathis GD · Slack thread

Adds a Certora spec covering the last unchecked item in the formal verification wish list: the ERC4626 round-trip properties (the a16z erc4626-tests ERC4626.prop.sol L244-318) hold — no deposit→redeem, mint→withdraw, or reverse round trip lets a user extract more than they put in.

certora/specs/ERC4626.spec proves the eight a16z round-trip inequalities (each rule named for its counterpart) plus two conversion lemmas. It proves them at fixed vault totals via the preview/convert path: the Morpho-Blue-dependent totalAssets fee accrual is summarized to arbitrary-but-fixed totals (a sound over-approximation) so the proof isolates exactly the rounding-direction correctness these properties test, without the supply-accounting cost that timed out #419. Math.mulDiv is summarized to exact mathint floor/ceil semantics for SMT tractability. A matching certora/confs/ERC4626.conf and the CI matrix entry are included.


Generated by Claude Code

Comment thread certora/specs/ERC4626.spec
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfzVWCYX7Nrnu4P6h4EuP9
Comment thread certora/specs/ERC4626.spec Outdated
Comment thread certora/specs/ERC4626.spec Outdated
@MathisGD
MathisGD marked this pull request as ready for review July 24, 2026 17:59
@MathisGD
MathisGD requested a review from QGarchery July 24, 2026 17:59
Comment thread certora/specs/ERC4626.spec
Comment thread certora/specs/ERC4626.spec
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfzVWCYX7Nrnu4P6h4EuP9
Comment thread certora/specs/ERC4626.spec Outdated
Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
Comment thread certora/specs/ERC4626.spec
claude added 3 commits July 31, 2026 17:31
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfzVWCYX7Nrnu4P6h4EuP9
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfzVWCYX7Nrnu4P6h4EuP9
The intermediate lemma proving OZ's real Math.mulDiv matches the basic
floor/ceil cvlMulDiv summary does not discharge. The prover returns fast
counterexamples (not timeouts) for every rounding mode, in both an exact
mathint-division form and a tight two-sided multiplicative-bounds form.

Witness (floor, assert (res+1)*d > x*y): x=0xb6db..6dc (~8.27e76), y=7, d=6,
returned res=0 on a non-reverting path -- true floor is ~9.65e76.
Witness (ceil, assert res*d >= x*y): x=2^255+2, y=4, d=3, returned res=1 --
true ceil is ~7.7e76. The returned values are unrelated to floor/ceil(x*y/d):
the prover over-approximates Math.mulDiv's 512-bit mulmod + Newton-Raphson
modular-inverse bytecode and admits arbitrary small results. With mulDiv
un-summarized there is no ghost to constrain, so no lemma fixes this.

Reverting to keep PR green; the Math.mulDiv => cvlMulDiv summary in
ERC4626.spec remains an assumption.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CfzVWCYX7Nrnu4P6h4EuP9
Comment thread certora/specs/ERC4626.spec
Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
@MathisGD
MathisGD requested a review from bhargavbh August 18, 2026 16:57

@jhoenicke jhoenicke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

The mulDiv summary is ignoring reverts and uses require_uint256. This is only sound because we don't check for reverts in the rules.

@QGarchery QGarchery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #470

@MathisGD
MathisGD merged commit 3d21e66 into main Aug 27, 2026
20 checks passed
@MathisGD
MathisGD deleted the claude/certora-erc4626-roundtrip branch August 27, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants