Section 8 of 15
BorrowerOperations: adjustTrove and closeTrove
Key takeaway:
addColl,withdrawColl,withdrawLUSD, andrepayLUSDare 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 combinedadjustTroveexternal 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.closeTroveis the only borrowing function that doesn't go through_adjustTrovebecause 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
Requirements
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 continueAlready have an account? Log in