ChadVault is a modular, secure, and upgradeable decentralized finance (DeFi) vault system built on the ERC-4626 tokenized vault standard. It enables users to deposit assets (currently focusing on DAI) and earn yield from external protocols like Aave. Users receive vault shares representing their proportional ownership, which grows as the underlying assets generate returns.
The project will include a full-stack web application with a backend to handle on-chain interactions and off-chain monitoring, along with a React-based frontend that provides a user-friendly interface for deposits, withdrawals, and real-time performance tracking.
The system follows a modular design for scalability and security, allowing for future expansion to support multiple tokens and protocols.
-
BaseVault (abstract):
- Manages core deposit, withdrawal, and accounting logic.
- Implements ERC-4626.
- Provides basic security mechanisms, such as reentrancy protection.
-
ChadVault (implementation):
- Extends the BaseVault for DAI-specific implementation.
- Allocates deposited funds to a yield manager (e.g., Aave).
- Manages permit-based deposits and withdrawals to save gas.
-
DAIYieldManager (Yield Manager for Aave):
- Handles the allocation of DAI to Aave.
- Tracks total invested assets and manages withdrawals.
- Designed to support future multi-protocol expansion.
-
ConfigurationManager:
- Manages system parameters, including deposit limits, fee settings, and emergency configurations.
- Controlled through role-based access.
-
VaultAccessControl:
- Provides role-based access control for managing emergency functions, strategy updates, and system configuration.
-
Strategies:
- Pluggable strategy contracts handle yield generation and rebalancing across various protocols.
- Single-Token Vault: Supports deposits and withdrawals of DAI using the ERC-4626 standard.
- Basic Yield Generation: Allocates DAI to Aave for yield.
- Permit-Based Interactions: Saves users gas by allowing them to deposit or withdraw using signed approvals.
- Upgradeable Contracts: Designed using OpenZeppelin’s proxy patterns for future upgrades.
- Cross-Contract Reentrancy Protection: Mitigates risks associated with external contract interactions.
- Access Control: Role-based permissions using VaultAccessControl for emergency functions and system management.
- Emergency Mechanisms: Pause/unpause deposits and withdrawals in case of critical issues.
- Slippage Protection: Plans to implement slippage checks on withdrawals to prevent losses due to volatile market conditions.
- Multi-Protocol Support: Expand to include multiple yield sources (e.g., Compound, Yearn).
- Rebalancing Mechanism: Reallocate funds between protocols based on yield performance.
- Fee Structures: Introduce management and performance fees.
- Multi-Asset Vault: Enable deposits of multiple ERC-20 tokens.
- Decimal Handling: Ensure proper conversions for tokens with different decimals.
- On-Chain Monitoring: Track APY, total value locked (TVL), and risk metrics.
- Advanced Events: Emit detailed events for deposit, withdrawal, rebalancing, and strategy updates.
-
Backend (Rust):
- Manage off-chain logic such as yield monitoring, strategy rebalancing, and event handling.
- Handle secure interactions with on-chain contracts and user authentication.
- Implement APIs for frontend interaction, including deposit/withdrawal requests and performance data.
-
Frontend (React):
- User-friendly UI for depositing and withdrawing assets.
- Display performance metrics like APY, user balances, and yield distribution.
- Visualize share growth, yield generation, and portfolio breakdown.
-
Key UI Features:
- Deposit/Withdraw Dashboard: Easy-to-use interface for managing vault shares.
- Performance Monitoring: Real-time APY, share price, and protocol exposure.
- Historical Tracking: Graphs displaying past performance and growth.
- Strategy Insights: Information about current yield sources and allocation.
ChadVault prioritizes security at every level of the architecture, with the following key measures:
- Reentrancy Protection: OpenZeppelin’s
ReentrancyGuard
prevents reentrancy attacks. - Access Control: Role-based permissions restrict sensitive operations to authorized addresses.
- Emergency Mechanisms: Immediate pause/unpause functionality for critical issues.
- Rate Limiting: Limit large deposits and withdrawals to protect system stability.
- Fallback Mechanisms: Circuit breakers and recovery procedures for failed protocol interactions.
ChadVault will introduce a hybrid fee structure:
- Management Fee: A percentage of the total assets under management (charged annually).
- Performance Fee: A percentage of the yield generated.
Fees will be accrued via virtual shares to ensure accurate accounting and minimize gas usage.
- Frontend Interaction: Users initiate deposits through the UI.
- Backend Handling: Backend API validates and routes the request.
- On-Chain Execution: The Vault checks limits and routes funds to the yield manager.
- Event Tracking: Deposits trigger events for monitoring and analytics.
- Frontend Interaction: Users request withdrawals via the UI.
- Backend Handling: Backend validates the request and initiates withdrawal.
- On-Chain Execution: The Vault retrieves funds from the YieldManager and transfers assets.
- Event Tracking: Withdrawals emit events for monitoring and analytics.
- Monitoring: The backend monitors yield performance and protocol health.
- Trigger Mechanism: Threshold-based or time-based triggers initiate rebalancing.
- On-Chain Execution: The Vault reallocates assets between protocols.
- Event Tracking: Events are emitted to track rebalancing actions.
- Single-Token ERC-4626 Vault: ✅
- Basic Yield Generation through Aave: ✅
- Security Enhancements: 🚧
- Multi-Protocol and Multi-Token Support: 🚧
- Fee Structure Implementation: 🚧
- Rebalancing Mechanism: 🚧
- Full-Stack Integration (Backend/Frontend): 🚧
- Monitoring and Analytics: 🚧
-
Clone the repository:
git clone https://github.com/0xChaddB/ChadVault cd ChadVault
-
Compile contracts:
forge build
-
Run tests:
forge test
-
Run forked integration tests:
forge test --fork-url <RPC_ENDPOINT>
- Unit Tests: Validate core functionalities such as deposits, withdrawals, and yield generation.
- Fuzz Tests: Test the system under randomized input conditions.
- Invariant Tests: Ensure critical properties remain consistent across state transitions.
- Integration Tests: Test interactions with real protocols on forked networks.
- Dynamic Strategy Rebalancing: Automatically optimize protocol allocation based on performance.
- Multi-Chain Deployment: Expand deployment to chains beyond Ethereum (e.g., Polygon, Arbitrum).
- Advanced Risk Management: Implement risk-adjusted yield strategies.
- Analytics Dashboard: Provide users with actionable insights into their investments.
This project is licensed under the MIT License.