A minimal ERC20-based mutual fund vault smart contract built with Foundry. The contract allows users to deposit USDC, receive vault shares, withdraw funds proportionally, and receive yield distributions.
- Users can deposit USDC and receive proportional shares of the vault.
- Users can withdraw USDC by redeeming their vault shares.
- Vault managers can distribute yield to all share holders.
- Built with OpenZeppelin's ERC20 standard.
- Written in Solidity 0.8.13.
- Token Name:
Vault - Token Symbol:
VAULT - Backed by an external USDC token (or any ERC20-compatible token).
Vault deployed at: 0xeB49f11Bb63d6375d1Dc96a5Ea7F20DbBe02E973 USDC address used: 0xb7Ae14a0393a75Dd07730367dE9E0a2Ca9623668
Deposits USDC into the vault and mints shares to the user.
- Reverts if user has insufficient balance.
- Emits
Deposit(address user, uint256 amount)event.
Burns shares and returns the corresponding USDC to the user.
- Reverts if user has insufficient shares or vault has insufficient funds.
- Emits
Withdraw(address user, uint256 amount)event.
Allows a manager to add USDC to the vault to simulate yield.
- Reverts if sender has insufficient USDC balance.
- Emits
DistributeYield(address user, uint256 amount)event.
InsufficientBalance(): Thrown if the sender does not have enough balance (either in USDC or vault shares).
forge install openzeppelin/openzeppelin-contractsforge buildforge test.
├── src/
│ └── Vault.sol # Main vault contract
├── lib/
│ └── openzeppelin-contracts/ # ERC20 library
├── test/ # Foundry test files
└── foundry.toml # Foundry config
Afrijal Dzuhri
Twitter • LinkedIn
MIT License © 2025