Vault Operations
Strategy Operating Payment Token (SOPT)
Basically, it is a token following the ERC20 standard which wrap the gas token of the chain where the protocol is deployed and it is not transferable.
In addition of ERC20 function there is some additional functions to dedicate funds to the operation of a vault with approveOperation function which is working like a traditional ERC20 approval.
function approveOperation(address _spender, uint256 _amount) public returns (bool)where:
_spenderis the address of the vault_amountis the amount of SOPT you want to allocate to the vault
For the operations payment, the StrategOperatorProxy contract call the following function:
function executePayment(address _for, address _operator, uint256 _amount) public returns (bool)where:
_foris the address of the vault_operatoris the address of the operator executing the transaction_amountis the amount of SOPT to pay for the operation
Operators
Operators are whitelisted entities who perform various actions on the vaults when necessary, using the StrategOperatorProxy contract. These actions include:
Rebalancing strategies
Rebalancing position managers
Harvesting strategies
Stopping strategies
For these actions to be executed by operators, vaults must have available gas (gas costs of operations are supported tiers party) via the SOPT.
To know if a vault operation to be rebalanced, operator call the StrategOperatorDataAggregator contract with the following function
function vaultInfo(address _vault) external returns (StrategVaultInfo memory status)The returned struct contain an aggregated data of current configuration and state of the vault. Operator will compute it to determine if an operation is needed on it.
Operations
All operations available on the vault has to be executed through the StrategOperatorProxy contract. All function are restricted to address which have the OPERATOR_ROLE on the Access manager
vaultRebalance
The vaultRebalance function the strategy vault which is triggered when the buffer of a vault is out of the range . This function cannot be called if the vault is locked.
To rebalance the vault, operators have to call this function:
function vaultRebalance(
address _vault,
address _payer,
uint256 _gasCost,
uint256[] memory _dynParamsIndexEnter,
bytes[] memory _dynParamsEnter,
uint256[] memory _dynParamsIndexExit,
bytes[] memory _dynParamsExit
) external;where:
_vaultis the vault address_payeris the address which will pay for operation gas cost_gasCostis the estimated gas cost_dynParamsIndexEnteris the ordered list of block index which need dynamic parameters_dynParamsEnteris the ordered list of bytes containing dynamic parameters to execute the enter execution_dynParamsIndexExitis the ordered list of block index which need dynamic parameters_dynParamsExitis the ordered list of bytes containing dynamic parameters to execute the exit execution
vaultHarvest
Executes the harvest function on the strategy vault when the harvest fees cover 2 SOPT when they are swapped.
To harvest the vault, operators have to call this function:
function vaultHarvest(
address _vault,
address _payer,
uint256 _gasCost,
uint256[] memory _dynParamsIndex,
bytes[] memory _dynParams,
bytes memory _portalPayload
) external;where:
_vaultis the vault address_payeris the address which will pay for operation gas cost_gasCostis the estimated gas cost_dynParamsIndexis the ordered list of harvest block index which need dynamic parameters_dynParamsis the ordered list of bytes containing dynamic parameters to execute the harvest execution_portalPayloadis the dynamic parameters to swap harvest fees to SOPT
stopStrategy
Exit all assets from the strategy.
This function is called when the vault dosn't have sufficient SOPT to be maintained or when a critical issue has been detected on a protocol used on the vault strategy.
To stop the strategy, operators have to call this function:
function vaultStopStrategy(
address _vault,
address _payer,
uint256 _gasCost,
uint256[] memory _dynParamsIndex,
bytes[] memory _dynParams
) external;where:
_vaultis the vault address_payeris the address which will pay for operation gas cost_gasCostis the estimated gas cost_dynParamsIndexis the ordered list of harvest block index which need dynamic parameters_dynParamsis the ordered list of bytes containing dynamic parameters to execute the harvest execution
vaultWithdrawalRebalance
The withdrawal rebalance function is the only one function which is not restricted to operators and can be called by vault shares owner. The gas cost of this transaction is charged to the user, no SOPT will be charged to the vault gas payer
This operation is called when a user need to withdraw its liquidity and there is not sufficient amount of asset in the buffer to fulfill its withdraw. In this case, this operation execute the withdraw and the vault rebalance in the same transaction.
If the strategy's blocks doesn't need dynamic params to be executed, it can be called by users without particular permissions.
In the case where dynamic parameters are needed, dynamic parameters have to be provided and signed by an operator. if the signature isn't provided, the transaction will revert.
The hash to sign have to be computed like the following:
bytes32 signedHash = keccak256(
abi.encode(
_user,
userWithdrawalRebalancedNonce[_user],
_deadline,
_dynParamsIndexExit,
_dynParamsExit
)
);
To execute this function, users have to call this function on the StrategUserInteractions contract:
function vaultWithdrawalRebalance(
address _vault,
uint256 _deadline,
uint256 _amount,
bytes memory _signature,
bytes memory _portalPayload,
bytes memory _permitParams,
uint256[] memory _dynParamsIndexExit,
bytes[] memory _dynParamsExit
) external payable returns (uint256 returnedAssets);where:
_vaultis the vault address_deadlineis the execution deadline of the transaction_amountis the amount of shares to withdraw_signaturethe signature of the hash generated on dynamic parameters if needed_portalPayloadthe portal payload if the user want to swap withdrawed assets to another asset_permitParamsthe permit payload if the user want to use permit to make his approval on his vault shares_dynParamsIndexis the ordered list of harvest block index which need dynamic parameters_dynParamsis the ordered list of bytes containing dynamic parameters to execute the harvest execution
positionManagerRebalance
The function is used to rebalance a borrow or a leverage done in a strategy with position manager of the borrow module.
The positon manager have an exclusive access to the following function on the vault:
function partialStrategyExecution(
bool _isEnter,
address _neededTokenToRebalance,
uint256[] memory _from,
uint256[] memory _to,
uint256[] memory _dynParamsIndex,
bytes[] memory _dynParams
) external; This function allow a position manager to execute partially the vault strategy to retrieve borrowed assets before rebalancing the position manager or to execute enter function of next blocks if more assets are borrowed.
Block to execute on partial strategy function is computed by the operators in function of the provided strategy design.
To execute a position manager, you have to call the following function on the StrategOperatorProxy contract:
function positionManagerOperation(
address _positionManager,
address _payer,
uint256 _gasCost,
bytes calldata _payload
) external;where:
_positionManageris the position manager address_payeris the address which will pay for operation gas cost_gasCostis the estimated gas cost_payloadthe payload needed by the position manager to be rebalanced
Guardians functions
This function has to be called when there is an issue of protocol used by a vault.
When it's happen, guardians have to lock vault. When a vault is locked, operators will call the stop operation to exit vault's liquidity from its strategy and secure funds in the buffer
lockVaults
Locks the specified vaults, preventing rebalance operations on them. This function is restricted to address which have the OPERATOR_GUARDIAN role on the Access Manager.
function unlockVaults(address[] memory _vaults) public;unlockVaults
Unlocks the specified vaults, allowing rebalance operations on them. This function is restricted to address which have the OPERATOR_GUARDIAN role on the Access Manager.
function unlockVaults(address[] memory _vaults) public;Last updated