Section 8 of 15

Build
+15 Lynx

BorrowerOperations: adjustTrove and closeTrove

Key takeaway: addColl, withdrawColl, withdrawLUSD, and repayLUSD are all thin wrappers around a single internal function: _adjustTrove. This unified function takes a (collChange, isCollIncrease, debtChange, isDebtIncrease) quad and handles every borrowing operation — including the combined adjustTrove external entry point that lets a user change collateral and debt in one transaction. The same validation pipeline (Recovery Mode check, ICR check, TCR check, fee handling) runs for every operation; only the direction of the changes differs. closeTrove is the only borrowing function that doesn't go through _adjustTrove because it has fundamentally different semantics: full debt repayment, full collateral return, and Trove deletion.

What You Are Building

Five public functions and one internal workhorse:

addColl       ─┐
withdrawColl  ─┤
withdrawLUSD  ─┼──► _adjustTrove (unified internal function)
repayLUSD     ─┤
adjustTrove   ─┘

closeTrove ─► standalone — full repayment + ETH return + Trove deletion

Plus the convenience wrappers, the supporting internal helpers, and the require-helpers that enforce mode-specific safety rules.

Your Code

Solution.sol
Solidity
Loading editor...

Requirements

Write your implementation, then click Run Tests. Tests execute on the server.

Sign up free — keep reading + earn 15 Lynx

Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.

Sign up free to continue

Already have an account? Log in