Function: openTrove(IERC20 collateralToken, address account, uint256 _maxFeePercentage, uint256 _collateralAmount, uint256 _debtAmount, address _upperHint, address _lowerHint)
The function is used to open a new trove.
Inputs
collateralTokenControl: Fully controlled.
Constraints: Should be one of the accepted collaterals.
Impact: The collateral to be provided to the system.
accountControl: Fully controlled.
Constraints: No constraints.
Impact: Address of the borrower.
_maxFeePercentageControl: Fully controlled.
Constraints: No constraints.
Impact: The maximum fee the user is willing to accept.
_collateralAmountControl: Fully controlled.
Constraints: No constraints.
Impact: The amount of collateral provided by the borrower.
_debtAmountControl: Fully controlled.
Constraints: No constraints.
Impact: The amount of debt tokens requested by the borrower.
_upperHintControl: Fully controlled.
Constraints: No constraints.
Impact: The
prevIdof the two adjacent nodes in the linked list that are (or would become) the neighbors of the given trove.
_lowerHintControl: Fully controlled.
Constraints: No constraints.
Impact: The
nextIdof the two adjacent nodes in the linked list that are (or would become) the neighbors of the given trove.
Branches and code coverage (including function calls)
Intended branches
If the system is in recovery mode, the borrowing fee should be neglected.
If the system is in recovery mode, the ICR should be above CCR.
If the system is not in recovery mode, the ICR should be above MCR.
If the system is not in recovery mode, the
newTCRafter the trove change should be above CCR.
Negative behavior
The function should revert if
netDebtis less than the minimum debt required to open the trove.The function should revert if collateral transfer fails.
The function should revert if collateral is sunsetting.
The function should revert if collateral debt limit is reached.
Function call analysis
troveManager.openTrove(account,_collateralAmount,vars.compositeDebt,vars.NICR,_upperHint,_lowerHint)
What is controllable?
account,_collateralAmount,_upperHint, and_lowerHint.If return value controllable, how is it used and how can it go wrong? Return value is not controllable.
What happens if it reverts, reenters, or does other unusual control flow? The entire function would revert if the external call reverts --- no reentrancy scenarios.
collateralToken.transferFrom(msg.sender, address(troveManager), _collateralAmount)
What is controllable?
msg.senderand_collateralAmount.If return value controllable, how is it used and how can it go wrong? Return value is not controllable.
What happens if it reverts, reenters, or does other unusual control flow? No reentrancy scenarios.