Function: _adjustTrove(IERC20 collateralToken, address account, uint256 _maxFeePercentage, uint256 _collDeposit, uint256 _collWithdrawal, uint256 _debtChange, bool _isDebtIncrease, address _upperHint, address _lowerHint)
This function is used to adjust a trove (change debt or collateral within the trove). The functions adjustTrove, repayDebt, withdrawDebt, withdrawColl, and addColl are wrappers around this underlying internal function.
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: Either the caller or the delegated caller.
_maxFeePercentageControl: Fully controlled.
Constraints: No constraints.
Impact: The maximum fee the user is willing to accept.
_collDepositControl: Fully controlled.
Constraints: No constraints.
Impact: The amount of collateral to deposit.
_collWithdrawalControl: Fully controlled.
Constraints: No constraints.
Impact: The amount of collateral to withdraw.
_debtChangeControl: Fully controlled.
Constraints: No constraints.
Impact: The amount of change in debt tokens.
_isDebtIncreaseControl: Fully controlled.
Constraints: No constraints.
Impact: True if debt is increased, otherwise false.
_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 debt is increased, the max fee percentage should be valid.
If the system is not in recovery mode, add the borrowing fee.
If debt is decreased, the minimum debt should be maintained after the debt change.
If collateral is increased, transfer collateral from caller to the trove manager.
Negative behavior
Revert if there is no collateral or debt change.
Revert if the new ICR does not satisfy the conditions for the current system mode.
Function call analysis
troveManager.applyPendingRewards(account)What is controllable?
account.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), vars.collChange)What is controllable?
msg.senderandvars.collChange.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.
troveManager.updateTroveFromAdjustment(account,vars.collChange,vars.isCollIncrease,vars.debtChange,_isDebtIncrease,vars.netDebtChange,_upperHint,_lowerHint,msg.sender)What is controllable?
account,vars.collChange,vars.isCollIncrease,vars.debtChange,_isDebtIncrease,vars.netDebtChange,_upperHint,_lowerHint, andmsg.sender.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.