A decentralized ERC4626-compliant index fund vault that allows participants to deposit tokens and invest in a basket of assets. The indices can be voted on by a DAO, but are initially implemented by the vault owner.
This project implements a web3-based index fund using Solidity smart contracts with the following key components:
- ERC4626 Vault: A standard-compliant tokenized vault that handles deposits, withdrawals, and accounting
- Index Registry: Manages the composition of the index (tokens and their weights)
- DAO Governance: Allows token holders to vote on index changes (optional)
- Price Oracle Integration: For accurate asset pricing
- DEX Integration: For rebalancing and trading between assets
- Automated Rebalancing: Maintains the desired asset allocation
- Fee Structure: Management and performance fees
- DAO Governance: Decentralized control of the index composition
- Cross-Chain Support: Extensible for cross-chain assets (future enhancement)
- RWA Support: Extensible for real-world assets (future enhancement)
├── src/
│ ├── IndexFundVault.sol # Main vault contract
│ ├── IndexRegistry.sol # Index composition registry
│ ├── interfaces/ # Contract interfaces
│ └── mocks/ # Mock contracts for testing
├── script/ # Deployment scripts
├── test/ # Test files
└── frontend/ # React TypeScript UI
├── src/
│ ├── components/ # Reusable UI components
│ ├── contexts/ # React contexts including Web3Context
│ ├── hooks/ # Custom hooks for contracts
│ ├── pages/ # Page components for different user roles
│ ├── theme/ # UI theme configuration
│ └── contracts/ # Contract interfaces and ABIs
└── public/ # Static assets
- Foundry installed
- Git
- Node.js (v14 or later) for the frontend
- npm or yarn
- MetaMask or another Ethereum wallet browser extension
- Clone the repository:
git clone https://github.com/yourusername/web3-index-fund.git
cd web3-index-fund
- Install dependencies:
forge install
Compile the contracts:
forge build
Run the test suite:
forge test
Run tests with verbosity for more details:
forge test -vvv
Run a specific test:
forge test --match-test testDeposit -vvv
- Start a local Anvil node:
anvil
- In a new terminal, deploy the contracts to the local node:
forge script script/Deploy.s.sol:Deploy --rpc-url http://localhost:8545 --broadcast --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Note: The private key above is the default private key for the first account in Anvil.
- Create a
.env
file with your private key:
PRIVATE_KEY=your_private_key_here
- Deploy to Sepolia testnet:
source .env
forge script script/DeploySepolia.s.sol:DeploySepolia --rpc-url https://sepolia.infura.io/v3/YOUR_INFURA_KEY --broadcast
Replace YOUR_INFURA_KEY
with your actual Infura API key.
cast send <VAULT_ADDRESS> "deposit(uint256,address)" <AMOUNT> <RECEIVER> --rpc-url <RPC_URL> --private-key <PRIVATE_KEY>
cast send <VAULT_ADDRESS> "withdraw(uint256,address,address)" <AMOUNT> <RECEIVER> <OWNER> --rpc-url <RPC_URL> --private-key <PRIVATE_KEY>
cast send <VAULT_ADDRESS> "rebalance()" --rpc-url <RPC_URL> --private-key <PRIVATE_KEY>
The main vault contract that implements the ERC4626 standard. It handles deposits, withdrawals, and rebalancing of the index.
Manages the composition of the index, including token addresses and their weights.
Allows token holders to vote on proposals to change the index composition.
- Management Fee: Annual fee based on total assets under management (default: 1%)
- Performance Fee: Fee on profits above the high water mark (default: 10%)
- The contracts use OpenZeppelin's security libraries
- Reentrancy protection is implemented for critical functions
- Fee limits are enforced to prevent excessive fees
The project includes a React TypeScript frontend that provides a user interface for interacting with the smart contracts.
- User Roles: Support for Investors, DAO Members, and Portfolio Managers
- Dark Mode UI: Modern Material UI design with dark mode
- Wallet Integration: Connect with MetaMask and other Ethereum wallets
- Role-Based Dashboards: Different interfaces for different user types
- Navigate to the frontend directory:
cd frontend
- Install dependencies:
npm install
- Start the development server:
npm start
- Open http://localhost:3000 in your browser
- View vault statistics and index composition
- Deposit assets into the vault
- Withdraw assets by redeeming shares
- View index composition
- Add, update, and remove tokens from the index
- (Future) Participate in governance proposals
- Rebalance the portfolio
- Collect management and performance fees
- Configure vault parameters
For more details about the frontend, see the frontend README.
- Integration with more DEXes for better liquidity
- Cross-chain asset support
- Real-world asset (RWA) synthetic tokens
- Enhanced DAO governance features
- Advanced analytics dashboard
- Mobile-responsive design improvements
This project is licensed under the MIT License - see the LICENSE file for details.
This project uses Foundry, a blazing fast, portable, and modular toolkit for Ethereum application development written in Rust.
For more information about Foundry, visit the documentation.