Skip to content

[Contracts] LoanManager uses raw panics for user-facing failures instead of typed LoanError returns #8

@grantfox-oss

Description

@grantfox-oss

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

Why this matters

Several user-reachable paths in loan_manager/src/lib.rs panic with strings rather than returning LoanError: repay does panic!("repayment amount below minimum"), set_min_repayment_amount panics on negative input, and adjust_total_outstanding does panic!("total outstanding underflow"). Panics produce untyped traps that clients cannot match on, unlike the existing structured LoanError enum used elsewhere.

Acceptance criteria

  • Replace user-reachable panics in repay and set_min_repayment_amount with typed LoanError variants (adding a variant such as RepaymentBelowMinimum if needed)
  • Keep internal invariant panics (truly-unreachable underflow) but document why they cannot be triggered by inputs
  • Add tests asserting the typed errors are returned for below-minimum repayment and negative min repayment
  • Audit the lending_pool withdrawal_cooldown panic for the same treatment

Files to touch

  • loan_manager/src/lib.rs

Out of scope

  • Reworking the repayment split algorithm
  • Changing min-repayment economics

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignenhancementNew feature or requesthardAdvanced / high-difficulty issuehelp wantedExtra attention is needed

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