Skip to content

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

Closed

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

Activity

  1. BigJohn-dev commented on Jun 17, 2026

    @BigJohn-dev
    Contributor

    I’d like to work on this issue because it aligns closely with the kind of engineering problems I enjoy solving — building reliable, maintainable, and user-focused software. I’m particularly interested in contributing to real-world systems where code quality, scalability, and thoughtful implementation matter.

  2. Dopezapha commented on Jun 20, 2026

    @Dopezapha
    Contributor

    Hey maintainer, I would love to work on this issue. Kindly assign me the issue. Thanks

  3. grantfox-oss commented on Jun 20, 2026

    @grantfox-oss
    Author

    🦊 GrantFox — @BigJohn-dev has been assigned to this issue as part of the Official Campaign campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #8)
    2. Your PR will be reviewed by the LabsCrypt maintainers

    Good luck! Track your progress on GrantFox.

  4. grantfox-oss commented on Jun 20, 2026

    @grantfox-oss
    Author

    🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign campaign!

    @BigJohn-dev's PR #37 was approved and merged by @ogazboiz.

    🏆 @BigJohn-dev: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (83 total points). Track your full progress on GrantFox.

    👏 Great work, @BigJohn-dev! Keep contributing to LabsCrypt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions