Skip to content

[Contracts] LoanManager refinance_loan returns InsufficientScore for an insufficient-collateral condition #6

@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 refinance_loan, the check if loan.collateral_amount < new_amount { return Err(LoanError::InsufficientScore); } returns the wrong error variant. A dedicated InsufficientCollateral = 26 variant already exists in the LoanError enum but is unused here, so callers receive a misleading error and cannot distinguish a credit-score failure from a collateral shortfall.

Acceptance criteria

  • Return LoanError::InsufficientCollateral for the collateral coverage check in refinance_loan
  • Audit other LoanError returns for similarly misused variants
  • Add a test asserting refinance with insufficient collateral returns InsufficientCollateral
  • Confirm InsufficientCollateral is actually exercised somewhere after the fix

Files to touch

  • loan_manager/src/lib.rs

Out of scope

  • Reworking refinance collateral ratio policy
  • Adding new error variants

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't workinghardAdvanced / 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