Vault Deployment
Smart contracts deployment
1. StrategVault & ERC3525 deployment
The vault creation is done by calling deployNewVault
on the StrategUserInteractions
contract:
function deployNewVault(string _name, string _symbol, address _asset, uint256 _middlewareStrategy, uint256 _bufferSize, uint256 _creatorFees, uint256 _harvestFees, string _ipfsHash) external nonpayable
where
_name
and_symbol
are ERC20 corresponding attributes_asset
is the vault asset_middlewareStrategy
,_creatorFees
and_harvestFees
are vault configuration described here_ipfsHash
IPFS hash of the file containing vault's metadatas
When a vault is created, an ERC3525 contract is also deployed. This ERC3525 token is used for defining the current owner of the vault (tokenId 1), who has the authority to modify vaults parameters and manage the distribution of creator fees through the values assigned to different tokenIds of the ERC3525.
2. Position manager deployment
If the need need position manager(s) in its strategy, they have to be deployed after the vault deployment to set the vault as the owner of itself.
To have more informations about position managers, check in borrow module documentation
3. Vault strategy setup
Each vault's strategy comprises two lists of blocks: one for executing the strategy itself and another for executing the harvest process.
A "block" is a standardized contract that performs a specific action on a DeFi protocol. There are two types of blocks: StrategyBlock and HarvestBlock, each dedicated to execution in their respective block lists.
For blocks to be utilized in vaults, they must first be registered in the block registry.
So, after being deployed, a vault need to have a strategy configured by calling setVaultStrategy
on the StrategUserInteractions
contract
setVaultStrategy(
address vault,
address[] memory _positionManagers,
address[] memory _stratBlocks,
bytes[] memory _stratBlocksParameters,
bool[] memory _isFinalBlock,
address[] memory _harvestBlocks,
bytes[] memory _harvestBlocksParameters
) external;
where:
_vault
is the vault's address_positionManagers
: List of position managers owned by the vault. This addresses have the possibility to call protected function in the position manager rebalance context._stratBlocks
: Ordered list of block addresses executed on the strategy execution._stratBlocksParameters
: Ordered list of bytes containing encoded parameters of block in the same index in_stratBlocks
list_isFinalBlock
: Ordered list of boolean to set a block in the stratBlocks as a final block. This is used only on strategy exit. When a block is a final block, it will receive the real percent to exit else it will receive 100% as exit percentage._harvestBlocks
: Ordered list of block addresses executed on the harvest execution._harvestBlocksParameters
: Ordered list of bytes containing encoded parameters of block in the same index in harvestBlocks list
NB: Since the vault strategy is setup, it will be immutable.
4. Edit Vault parameters
A Vault has many configuration editable by its owner (described here) and to change them after the vault deployment, the vault owner have to call the following function:
function editVaultParams(
address _vault,
IStrategVault.StrategVaultSettings[] memory _settings,
bytes[] memory _data
) public
where:
_vault
is the vault's address_settings
is the ordered list of setting ids to edits_data
is the ordered list of settings data to apply on the vault
5. Give StrategOperatingPaymentToken operation allowance
The gas cost of vaults operations isn't handle by the protocol.
To be operated, a vault need to have a minimal operation approval from an address holding StrategOperatingPaymentToken tokens.
Basically, SOPT is a wrapped gas token giving the possibility to operator to get refunded of operation gas cost. See this section to have more information
Last updated