SuperVaults is a smart contract project for managing and optimizing decentralized finance (DeFi) positions across multiple protocols.
The SuperVault contract adheres to the ERC-4626 standard, with additional functions to support dynamic rebalancing and other operational activities.
SuperVaults allow users to deposit assets and automatically distribute them across various DeFi protocols (Superforms) to optimize yield and manage risk. The project includes features such as:
- Deposit and withdrawal of assets
- Automatic rebalancing of positions
- Yield optimization across multiple protocols
- Risk management through diversification
Note: SuperVaults only operates with underlying Superforms that are on the same chain and have the same underlying asset.
SuperVaultFactory.sol: Factory contract for creating and managing SuperVaultsSuperVault.sol: Main contract for managing user deposits and interactions with Superforms
- Clone the repository
- Install dependencies:
forge install - Compile contracts:
make build - Run tests:
make ftest
Step by step instructions on setting up the project and running it
- Make sure Foundry is installed with the following temporary workarounds (see: foundry-rs/foundry#8014)
- For minimal ram usage, do
foundryup -v nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9 - For compatibility with safe signing operations do
foundryup -v nightly-ea2eff95b5c17edd3ffbdfc6daab5ce5cc80afc0
- Set the rpc variables in the makefile using your own nodes and disable any instances that run off 1password
POLYGON_RPC_URL=
AVALANCHE_RPC_URL=
FANTOM_RPC_URL=
BSC_RPC_URL=
ARBITRUM_RPC_URL=
OPTIMISM_RPC_URL=
ETHEREUM_RPC_URL=
BASE_RPC_URL=
FANTOM_RPC_URL=
.
├── script
├── security-review
├── src
├── interfaces
├── ISuperVault.sol
├── ISuperVaultFactory.sol
├── SuperVault.sol
├── SuperVaultFactory.sol
├── test
├── foundry.toml
├── Makefile
└── README.md
scriptcontains deployment and utility scripts and outputs/scriptsecurity-reviewcontains information relevant to prior security reviews/security-reviewsrcis the source folder for all smart contract code/srcinterfacesdefine interactions with other contracts/src/interfacesSuperVault.solandSuperVaultFactory.soldefine the core functionality of the SuperVaults/src/SuperVault.soland/src/SuperVaultFactory.sol
testcontains tests for contracts in src/test
- Users can view the available deposit limit for a SuperVault by calling the
availableDepositLimit()function - A user sends
ERC20tokens (e.g., USDC) to the SuperformRouter contract. - The
SuperformRoutercontract deposits these tokens into the SuperVault via its Superform contract. - The
SuperVaultcontract makes a multi-deposit into its underlying vaults through theSuperformRoutercontract. - The
SuperVaultmints shares based on the receivedSuperPositions(SPs) and sends them to itsSuperformcontract.- The
Superformcontract mints SPs at a 1:1 ratio corresponding to the receivedSuperVaultshares. - The user receives the
SuperVaultSPs in their wallet or smart wallet.
- The
- A user initiates the withdrawal process by sending a transaction to the
SuperformRoutercontract with a specified amount of SPs. - The
SuperformRoutercontract burns the given amount of SPs and initiates the withdrawal from theSuperVaultvia itsSuperformcontract. - The
SuperVaultwithdraws the corresponding funds from its underlying vaults and sends the funds back to the user.
- The Keeper obtains the total value of the
SuperVault’s underlying vaults. - The Keeper calculates the current share prices based on the assets in the underlying vaults and their current APYs.
- The Keeper determines the amounts to be deposited into and withdrawn from the underlying vaults, based on share prices, predefined coefficients in the
SuperVault, and current allocations. - The Keeper sends a transaction to the
SuperVaultto initiate the rebalancing process, including all necessary data for the rebalance. - The
SuperVaultexecutes the rebalancing using theSuperformRouterWrappercontract.
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
MIT License