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
script
contains deployment and utility scripts and outputs/script
security-review
contains information relevant to prior security reviews/security-review
src
is the source folder for all smart contract code/src
interfaces
define interactions with other contracts/src/interfaces
SuperVault.sol
andSuperVaultFactory.sol
define the core functionality of the SuperVaults/src/SuperVault.sol
and/src/SuperVaultFactory.sol
test
contains tests for contracts in src/test
- Users can view the available deposit limit for a SuperVault by calling the
availableDepositLimit()
function - A user sends
ERC20
tokens (e.g., USDC) to the SuperformRouter contract. - The
SuperformRouter
contract deposits these tokens into the SuperVault via its Superform contract. - The
SuperVault
contract makes a multi-deposit into its underlying vaults through theSuperformRouter
contract. - The
SuperVault
mints shares based on the receivedSuperPositions
(SPs) and sends them to itsSuperform
contract.- The
Superform
contract mints SPs at a 1:1 ratio corresponding to the receivedSuperVault
shares. - The user receives the
SuperVault
SPs in their wallet or smart wallet.
- The
- A user initiates the withdrawal process by sending a transaction to the
SuperformRouter
contract with a specified amount of SPs. - The
SuperformRouter
contract burns the given amount of SPs and initiates the withdrawal from theSuperVault
via itsSuperform
contract. - The
SuperVault
withdraws 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
SuperVault
to initiate the rebalancing process, including all necessary data for the rebalance. - The
SuperVault
executes the rebalancing using theSuperformRouterWrapper
contract.
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
MIT License