Skip to content

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.

Notifications You must be signed in to change notification settings

afrijaldz/mutual-fund-vault

Repository files navigation

🏦 Mutual Fund Vault (Foundry)

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.

📜 Features

  • 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.

🧱 Contract Details

  • 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

🛠 Functions

deposit(uint256 amount)

Deposits USDC into the vault and mints shares to the user.

  • Reverts if user has insufficient balance.
  • Emits Deposit(address user, uint256 amount) event.

withdraw(uint256 shares)

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.

distributeYield(uint256 amount)

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.

🔒 Errors

  • InsufficientBalance(): Thrown if the sender does not have enough balance (either in USDC or vault shares).

🧪 Getting Started (with Foundry)

Prerequisites

Install Dependencies

forge install openzeppelin/openzeppelin-contracts

Build

forge build

Test

forge test

📁 Project Structure

.
├── src/
│   └── Vault.sol        # Main vault contract
├── lib/
│   └── openzeppelin-contracts/  # ERC20 library
├── test/                # Foundry test files
└── foundry.toml         # Foundry config

✍️ Author

Afrijal Dzuhri
TwitterLinkedIn


MIT License © 2025

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published