ERC4626 Vault Patterns

Detects inflation attacks, rounding errors, and donation vulnerabilities in ERC4626 tokenized vaults.

66|17|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/BitterSecurity/Vigilo --skill erc4626-vault-patterns-bittersecurity
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ERC4626 Vault Patterns
Source: https://github.com/BitterSecurity/Vigilo/tree/main/packages/claude/skills/protocol-patterns/vault-erc4626
Command: npx skills add https://github.com/BitterSecurity/Vigilo --skill erc4626-vault-patterns-bittersecurity

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Auditing ERC4626 tokenized vaults requires deep knowledge of subtle attack vectors like first depositor inflation attacks, incorrect rounding directions, and donation-based manipulation, which are easy to miss during manual smart contract review. ## Core Features & Use Cases - Inflation Attack Detection: Identifies missing virtual share offsets, dead share burning, or minimum deposit enforcement that enable first depositor attacks. - Rounding Direction Validation: Verifies that deposit, mint, withdraw, and redeem operations round in favor of the vault to prevent value extraction. - Donation Attack Analysis: Checks whether totalAssets relies on manipulable token balances instead of internal accounting. - Use Case: When auditing a yield vault contract, apply the included checklist to confirm share/asset conversion formulas handle zero supply, zero assets, and dust deposits correctly. ## Quick Start Audit this ERC4626 vault contract for inflation attacks, rounding direction errors, and donation vulnerabilities using the vault patterns checklist.

Frequently Asked Questions about ERC4626 Vault Patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit an ERC4626 vault for inflation attacks?▼

Check whether the vault implements virtual shares/assets offsets, burns dead shares on first deposit, or enforces a minimum deposit. Without these mitigations, an attacker can deposit 1 wei, donate tokens directly, and steal value from subsequent depositors through rounding.

What is the correct rounding direction for ERC4626 conversions?▼

Rounding must always favor the vault: deposit rounds shares down, mint rounds assets up, withdraw rounds shares up, and redeem rounds assets down. Rounding in the opposite direction lets attackers extract value through repeated dust operations.

Why is using balanceOf for totalAssets dangerous in vaults?▼

Reading asset.balanceOf directly makes totalAssets manipulable through direct token donations, which distorts share pricing and reward distribution. Vaults should track assets internally with a state variable updated only through deposit and withdrawal flows.

What mitigations prevent the first depositor attack?▼

Three common mitigations exist: adding virtual shares and assets offsets to conversion math, burning a fixed amount of dead shares to a dead address on first deposit, or enforcing a minimum deposit amount that makes the attack unprofitable.

What edge cases break ERC4626 share calculations?▼

Zero totalSupply and zero totalAssets cause division errors or incorrect 1:1 conversions, and very small deposits can mint zero shares due to rounding down. Vaults should handle these cases explicitly and reject deposits that yield zero shares.