Vault operations
Operators are in charge of managing the vaults.
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.
Operator functions
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:
_vault
: The address of the vault to rebalance_payer
: The address of the payer of the operation_gasCost
: The amount of gas to pay for the operation_dynParamsIndex
: The dynamic parameters block index_dynParams
: The dynamic parameters exit
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:
_vault
: The address of the vault to harvest_payer
: The address of the payer of the operation_gasCost
: The amount of gas to pay for the operation_dynParamsIndex
: The dynamic parameters block index_dynParams
: The dynamic parameters exit_portalPayload
: The payload to send to the portal
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:
_vault
: The address of the vault to stop_payer
: The address of the payer of the operation_gasCost
: The amount of gas to pay for the operation_dynParamsIndex
: The dynamic parameters block index_dynParams
: The dynamic parameters exit
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:
_vault
is the vault address_deadline
is the execution deadline of the transaction_amount
is the amount of shares to withdraw_signature
the signature of the hash generated on dynamic parameters if needed_portalPayload
the portal payload if the user want to swap withdrawed assets to another asset_permitParams
the permit payload if the user want to use permit to make his approval on his vault shares_dynParamsIndexExit
is the ordered list of harvest block index which need dynamic parameters_dynParamsExit
is 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 rebalance, you have to call the following function on the StrategOperatorProxy contract:
function positionManagerOperation(
address _positionManager,
address _payer,
uint256 _gasCost,
bytes calldata _payload
) external;
Where:
_positionManager
is the position manager address_payer
is the address which will pay for operation gas cost_gasCost
is the estimated gas cost_payload
the 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.
lockVault
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 vaultLock(address _vault) external;
Where:
_vault
is the vault address
unlockVault
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 vaultUnlock(address _vault) external;
Where:
_vault
is the vault address