Skip to content

feat: Increase reputation on successful loan payment#63

Merged
Josue19-08 merged 1 commit intoTrustUp-app:mainfrom
Bosun-Josh121:feat/increase-reputation-successful-loan-repayment
Mar 28, 2026
Merged

feat: Increase reputation on successful loan payment#63
Josue19-08 merged 1 commit intoTrustUp-app:mainfrom
Bosun-Josh121:feat/increase-reputation-successful-loan-repayment

Conversation

@Bosun-Josh121
Copy link
Copy Markdown
Contributor

Pull Request

Description

Integrates reputation score increases on successful loan repayment. Borrowers now receive a score bonus based on payment timing: +15 for early repayment (before the due date) and +10 for on-time/late repayment. Failures in the reputation contract call are handled gracefully and never block a repayment from completing.

Closes #22

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changes Made

  • Added handle_reputation_increase helper function in CreditLineContract that calculates score increase based on payment timing (payment_date < due_date → +15 early bonus, otherwise +10 on-time)
  • Replaced inline full_repayment_reward reputation call in repay_loan with a call to the new helper, using the last installment's due_date as the reference date
  • Reputation call uses try_invoke_contract so failures are silently ignored — repayment always succeeds regardless of reputation contract availability
  • Updated existing e2e test assertion to reflect early repayment now correctly yields +15 instead of +10

Testing

  • Tests pass locally
  • New tests added (if applicable)

New tests added in creditline-contract/src/tests.rs using the full RealIntegrationCtx integration setup:

  • test_on_time_full_repayment_increases_score_by_10 — payment at exactly the due date gives +10
  • test_early_full_repayment_increases_score_by_15 — payment before the due date gives +15
  • test_partial_repayment_does_not_change_reputation_score — partial payment triggers no score change
  • test_reputation_call_failure_does_not_block_repayment — loan moves to Paid even when the reputation contract rejects the call (updater permission revoked)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex code
  • Documentation updated
  • No new warnings generated

@Josue19-08 Josue19-08 merged commit 87449c7 into TrustUp-app:main Mar 28, 2026
2 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.

SC-11: Increase reputation on successful loan repayment

2 participants