Skip to content

Add late-payment penalty surcharge for delinquent credit lines#432

Merged
greatest0fallt1me merged 1 commit into
Creditra:mainfrom
Topmatrixmor2014:feature/late-payment-penalty
Jun 2, 2026
Merged

Add late-payment penalty surcharge for delinquent credit lines#432
greatest0fallt1me merged 1 commit into
Creditra:mainfrom
Topmatrixmor2014:feature/late-payment-penalty

Conversation

@Topmatrixmor2014
Copy link
Copy Markdown

Closes #355

Summary

Implements an admin-configurable penalty surcharge (in basis points) that applies on top of the base \interest_rate_bps\ when a credit line is delinquent. The penalty serves as a deterrent for late payments and encourages timely repayment.

Implementation Details

  • Storage: Added \PenaltySurchargeBps\ enum variant to store admin-configurable penalty rate
  • Risk Module: Added \set_penalty_surcharge_bps\ and \get_penalty_surcharge_bps\ public functions with admin auth and bounded validation
  • Accrual Logic: Modified \�pply_accrual\ to check delinquency status and apply penalty surcharge when applicable
  • Events: Added \PenaltyRateEnteredEvent\ and \PenaltyRateExitedEvent\ for tracking rate transitions
  • Contract API: Exposed penalty surcharge functions in lib.rs
  • Tests: Created comprehensive test suite in \penalty_surcharge.rs\ covering all edge cases

Acceptance Criteria (from #355)

  • Surcharge applied only while delinquent
  • Effective rate clamped to \MAX_INTEREST_RATE_BPS\
  • Enter/exit penalty events emitted

Test Coverage

Created comprehensive test suite covering:

  • Setting/getting penalty surcharge
  • Default value validation (0)
  • Maximum rate enforcement (cannot exceed 10_000 bps)
  • Application to delinquent vs. non-delinquent lines
  • Event emission for penalty rate transitions
  • Clamping to max rate when base + surcharge exceeds limit
  • Zero surcharge behavior (no effect)

Notes

  • Overflow-safe clamp math implemented using \saturating_add\ and \min()\
  • Effective rate computed as \�ase_rate.saturating_add(penalty_surcharge).min(MAX_INTEREST_RATE_BPS)\
  • Penalty only applies when \is_delinquent\ returns true
  • Default penalty surcharge is 0 (disabled)
  • All functions include inline documentation

Generated with Devin (https://cli.devin.ai/docs)

- Add PenaltySurchargeBps storage key for admin-configurable penalty rate
- Add set_penalty_surcharge_bps/get_penalty_surcharge_bps public functions in risk module
- Add PenaltyRateEnteredEvent and PenaltyRateExitedEvent for penalty rate transitions
- Apply penalty surcharge to delinquent lines during accrual in accrual module
- Expose penalty surcharge functions in contract API (lib.rs)
- Add comprehensive tests for penalty surcharge functionality

The penalty surcharge (in basis points) is added on top of the base
interest_rate_bps when a credit line is delinquent, providing a
deterrent for late payments. The effective rate is clamped to
MAX_INTEREST_RATE_BPS to prevent overflow.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 31, 2026

@Topmatrixmor2014 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me greatest0fallt1me merged commit 4f89d13 into Creditra:main Jun 2, 2026
0 of 7 checks 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.

Add late-payment penalty interest surcharge for delinquent credit lines

3 participants