feat(loan_manager): adjust total_outstanding on liquidation#42
Conversation
Decrement TotalOutstanding when a loan is liquidated so approve_loan liquidity checks reflect freed principal. Add test coverage and gitignore target/ build artifacts. Co-authored-by: Cursor <cursoragent@cursor.com>
ogazboiz
left a comment
There was a problem hiding this comment.
correct accounting fix, merging once ci is green. total_outstanding tracks the sum of original loan principals, added in full on approval and removed in full on every other terminal state (repaid, defaulted single + batch), and liquidation was the one terminal path missing the decrement, permanently inflating outstanding and starving available_liquidity. you add adjust_total_outstanding(&env, &token, -loan.amount) in the effects before the cross-contract calls, consistent with the other three, with checked arithmetic. the test proving a second loan is blocked before liquidation and approvable after is a good one. nice.
if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0
close #15
Summary
TotalOutstandingwhen a loan is liquidated, matchingrepayandcheck_defaulttest_liquidation_frees_outstanding_for_approve_loanto verify freed liquidity inapprove_loan.gitignoreto excludetarget/build artifactsTest plan
cargo fmt --checkcargo test(all 232 tests pass)