Skip to content

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

@grantfox-oss

Description

@grantfox-oss

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Why this matters

In loan_manager/src/lib.rs liquidate, seized collateral up to total_debt is transferred to the lending pool and apply_debt_recovery reduces the loan's accrued interest/late fee/principal, but total_outstanding is not adjusted on liquidation (unlike repay, check_default, and approve_loan which call adjust_total_outstanding). After liquidation the loan's principal portion remains counted in TotalOutstanding(token), permanently understating available liquidity in approve_loan's pool_balance - total_outstanding check.

Acceptance criteria

  • Adjust total_outstanding on liquidation to remove the liquidated loan's outstanding principal, consistent with repay/check_default
  • Verify available-liquidity accounting in approve_loan after a liquidation
  • Add a test that liquidates a loan and asserts subsequent approve_loan sees the freed liquidity
  • Confirm no path leaves TotalOutstanding permanently inflated

Files to touch

  • loan_manager/src/lib.rs

Out of scope

  • Changing the collateral-to-pool transfer destination
  • Bad-debt socialization design

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't workingenhancementNew feature or requesthardAdvanced / high-difficulty issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions