yield-vault-patterns

Implement ERC-4626 vault patterns with rounding and first-depositor attack mitigation.

120|12|Updated Apr 10, 2026
One-click install
npx skills add https://github.com/ccashwell/evm-cortex --skill yield-vault-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: yield-vault-patterns
Source: https://github.com/ccashwell/evm-cortex/tree/main/skills/yield-vault-patterns
Command: npx skills add https://github.com/ccashwell/evm-cortex --skill yield-vault-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Implementing secure, efficient ERC-4626 vaults requires solid patterns for share math, rounding, and security against early-depositor exploits.

Core Features & Use Cases

  • Complete ERC-4626 pattern: deposit/mint/withdraw/redeem flows with vault-favorable rounding rules.
  • Attack mitigation: virtual shares/assets and safe initialization to prevent first-depositor attacks.
  • Use Case: Build yield-bearing vaults and simple yield strategies with automated share accounting.

Quick Start

Deploy the yield-vault-patterns template with a test asset and run a basic deposit/withdraw scenario to observe share-price updates.

Frequently Asked Questions about yield-vault-patterns

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

FAQPage Schema
How do I prevent first-depositor attacks in an ERC-4626 vault?

To prevent first-depositor attacks in an ERC-4626 vault, implement virtual shares and assets alongside safe initialization logic. This pattern mitigates early-depositor exploits by ensuring robust share math and capital efficiency from the very first deposit.

What rounding rules should I use for ERC-4626 share math calculations?

ERC-4626 share math calculations should use vault-favorable rounding rules to protect existing depositors. The pattern applies precise rounding during deposit, mint, withdraw, and redeem flows to ensure shares are rounded down for minting and up for burning.

How do I implement a complete ERC-4626 tokenized vault deposit and withdrawal flow?

A complete ERC-4626 tokenized vault implementation covers deposit, mint, withdraw, and redeem flows with automated share accounting. It aligns to the ERC-4626 standard, managing asset deposits and withdrawals while updating share prices accurately.

Do I need any dependencies to build a yield-bearing vault with tokenized shares?

No external dependencies are required to build a yield-bearing vault with tokenized shares using this pattern. It provides a self-contained template for share math, asset management, and withdrawal logic that you can deploy directly with a test asset.

Why does my yield aggregator vault have inaccurate share pricing for early depositors?

Inaccurate share pricing for early depositors in yield aggregator vaults is typically caused by missing virtual-share protection. Without safe initialization and vault-favorable rounding rules, first-depositor attacks can exploit share math to dilute subsequent deposits.