Skip to content

feat(loan_manager): adjust total_outstanding on liquidation#42

Merged
ogazboiz merged 2 commits into
LabsCrypt:mainfrom
EbukaMoses:feat/loan-manager-liquidate
Jun 23, 2026
Merged

feat(loan_manager): adjust total_outstanding on liquidation#42
ogazboiz merged 2 commits into
LabsCrypt:mainfrom
EbukaMoses:feat/loan-manager-liquidate

Conversation

@EbukaMoses

Copy link
Copy Markdown
Contributor

close #15

Summary

  • Decrement TotalOutstanding when a loan is liquidated, matching repay and check_default
  • Add test_liquidation_frees_outstanding_for_approve_loan to verify freed liquidity in approve_loan
  • Add .gitignore to exclude target/ build artifacts

Test plan

  • cargo fmt --check
  • cargo test (all 232 tests pass)

EbukaMoses and others added 2 commits June 22, 2026 16:13
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 ogazboiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ogazboiz ogazboiz merged commit 98acb73 into LabsCrypt:main Jun 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Contracts] LoanManager liquidate does not adjust total_outstanding, permanently understating available liquidity

2 participants