a16z / erc4626-tests
git clone https://github.com/a16z/erc4626-tests.git
🔥 on GitHub Trending today
ERC4626 Property Tests
+0
stars, 24h · #15,315
+0
stars, 7 days · #15,869
+0
stars, 30 days · #22,310
223
★ total
44
forks · 3 open issues
Star history (as recorded here)
LanguageSolidity
LicenseAGPL-3.0
Created2022-10-21 (4y ago)
Last push1y ago
Watchers5
OwnerOrganization
Seen on GitHub Trending
- 2026-10-23 — #3 daily in solidity
- 2026-10-23 — #2 monthly in solidity
- 2026-10-23 — #3 weekly in solidity
- 2026-10-22 — #3 daily in solidity
- 2026-10-22 — #2 monthly in solidity
- 2026-10-22 — #3 weekly in solidity
- 2026-10-21 — #4 daily in solidity
- 2026-10-21 — #2 monthly in solidity
- 2026-10-21 — #3 weekly in solidity
- 2026-10-20 — #4 daily in solidity
- 2026-10-20 — #2 monthly in solidity
- 2026-10-20 — #3 weekly in solidity
Links
README excerpt
# ERC4626 Property Tests
Foundry (dapptools-style) property-based tests for [ERC4626] standard conformance.
[ERC4626]:
You can read our post on "_[Generalized property tests for ERC4626 vaults][post]_."
[post]:
## Overview
#### What is it?
- Test suites for checking if the given ERC4626 implementation satisfies the **standard requirements**.
- Dapptools-style **property-based tests** for fuzzing or symbolic execution testing.
- Tests that are **independent** from implementation details, thus applicable for any ERC4626 vaults.
#### What isn’t it?
- It does NOT test implementation-specific details, e.g., how to generate and distribute yields, how to compute the share price, etc.
#### Testing properties:
- **Round-trip properties**: no one can make a free profit by depositing and immediately withdrawing back and forth.
- **Functional correctness**: the `deposit()`, `mint()`, `withdraw()`, and `redeem()` functions update the balance and allowance properly.
- The `preview{Deposit,Redeem}()` functions **MUST NOT over-estimate** the exact amount.[^1]
[^1]: That is, the `deposit()` and `redeem()` functions “MUST return the same or more amounts as their preview function if called in the same transaction.”
- The `preview{Mint,Withdraw}()` functions **MUST NOT under-estimate** the exact amount.[^2]
[^2]: That is, the `mint()` and `withdraw()` functions “MUST return the same or fewer amounts as their preview function if called in the same transaction.”
- The `convertTo{Shares,Assets}` functions “**MUST NOT show any variations** depending on the caller.”
- The `asset()`, `totalAssets()`, and `max{Deposit,Mint,Withdraw,Redeem}()` functions “**MUST NOT revert**.”
## Usage
**Step 0**: Install [foundry] and add [forge-std] in your vault repo:
[code]
[foundry]:
[forge-std]:
**Step 1**: Add this [erc4626-tests] as a dependency to your vault:
[code]
[erc4626-tests]:
**Step 2**: Extend the abstract test contract `ERC4626Test` with your own custom vault setup method, for example:
[code]
$ forge test
```
## Examples
Here are some examples of these property tests in use:
- OpenZeppelin ERC4626 Test
- MetaMorpho Vault Test
- Snekmate ERC4626 Test
- Yearn Tokenized Strategy Test
- Aave Umbrella StakeToken Test
More examples can be found in other projects.
## Disclaimer
_These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions or loss of transmitted information. THE SMART CONTRACTS CONTAINED HEREIN ARE FURNISHED AS IS, WHERE IS, WITH ALL FAULTS AND WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY, NON-INFRINGEMENT OR FITNESS FOR ANY PARTICULAR PURPOSE. Further, use of any of these smart contracts may be restricted or prohibite