Skip to main content
A deposit mints too many shares, diluting existing holders. This template rejects a lower asset-per-share ratio after a deposit or withdrawal.

Behavior

ERC4626DepositWithdrawAssertion registers standard deposit(uint256,address) and withdraw(uint256,address,address) selectors. With assets in slot 0 and supply in slot 1, it requires postAssets × preSupply >= preAssets × postSupply. It skips the comparison when either share supply is zero.

Configuration

Replace the toy slots with the vault’s actual accounting. For real vaults, prefer the reusable ERC-4626 policy, which reads the interface at explicit snapshots, includes mint and redeem, and supports a tolerance.

Scenarios

Coverage limits

The example has no rounding tolerance, omits mint and redeem, and uses potentially overflowing products. It permits share-price increases and does not prove that tokens reached the vault. Legitimate fees or loss recognition can lower the ratio; test those paths before applying a no-decrease policy.

Source

The reviewed source is a teaching template. The example setup guide provides the pinned checkout and test procedure.