Assessment reports>Prisma Finance>Threat Models>_adjustTrove

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

  • collateralToken

    • Control: Fully controlled.

    • Constraints: Should be one of the accepted collaterals.

    • Impact: The collateral to be provided to the system.

  • account

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: Either the caller or the delegated caller.

  • _maxFeePercentage

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: The maximum fee the user is willing to accept.

  • _collDeposit

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: The amount of collateral to deposit.

  • _collWithdrawal

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: The amount of collateral to withdraw.

  • _debtChange

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: The amount of change in debt tokens.

  • _isDebtIncrease

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: True if debt is increased, otherwise false.

  • _upperHint

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: The prevId of the two adjacent nodes in the linked list that are (or would become) the neighbors of the given trove.

  • _lowerHint

    • Control: Fully controlled.

    • Constraints: No constraints.

    • Impact: The nextId of 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.sender and vars.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, and msg.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.

Zellic © 2025Back to top ↑