Vault Fee Module
Pluggable fee system: streaming management, performance, entry, and exit fees with immutable caps.
📁 File Structure 1147 files
📖 Documentation Preview README excerpt
vault-fee-module
Composable fee system for ERC-4626 vaults — management, performance, entry, and exit fees.
Price: $7.99 | Store: vault-forge | Product #3
Overview
FeeModule is an abstract Solidity contract that adds a complete, production-ready fee system to any ERC-4626 vault. Inherit it, configure your fees, and call the collection hooks in your vault's lifecycle functions.
Supported Fee Types
| Fee Type | Mechanism | Default | Cap |
|---|---|---|---|
| Management | Annual bps charged via share inflation (dilutive minting) | 200 bps (2%) | 500 bps (5%) |
| Performance | Bps on yield above high-water mark | 2000 bps (20%) | 5000 bps (50%) |
| Entry | Bps deducted from deposit amounts | 0 bps | 200 bps (2%) |
| Exit | Bps deducted from withdrawal amounts | 0 bps | 200 bps (2%) |
How Fees Work
Management Fee — Charged pro-rata based on time elapsed since last collection. New shares are minted to the fee recipient, diluting all holders proportionally. This follows Yearn's canonical streaming fee pattern.
feeShares = totalSupply * managementFeeBps * elapsed / (365 days * 10_000)
Performance Fee — Charged only on profit above the high-water mark (HWM). When totalAssets > highWaterMark, the profit is totalAssets - HWM, and the fee is a percentage of that profit. The HWM updates after each collection.
feeAssets = profit * performanceFeeBps / 10_000
Entry Fee — A flat percentage deducted from deposit amounts before shares are minted. The fee stays in the vault (increasing share value) or is transferred to the fee recipient.
Exit Fee — A flat percentage deducted from withdrawal amounts before assets are sent. Discourages short-term speculation.
Architecture
FeeModule (abstract)
├── FeeConfig struct — all 4 fee params + recipient
├── Pure calculators — stateless fee math
├── Collection hooks — stateful, update HWM + timestamps
└── Internal setters — for constructors/initializers
Storage Layout (Gas Optimized)
Slot 0: FeeConfig (4x uint16 + address = 28 bytes → 1 slot)
Slot 1: highWaterMark (uint256)
Slot 2: lastCollectionTimestamp (uint256)
... continues with setup instructions, usage examples, and more.