Skip to content

Fix/issues 303 314 578 7 - #921

Merged
ogazboiz merged 7 commits into
LabsCrypt:mainfrom
OsagieCynthia:fix/issues-303-314-578-7
May 27, 2026
Merged

Fix/issues 303 314 578 7#921
ogazboiz merged 7 commits into
LabsCrypt:mainfrom
OsagieCynthia:fix/issues-303-314-578-7

Conversation

@OsagieCynthia

Copy link
Copy Markdown
Contributor

Fix Multiple Issues: Late Fees, Score Deltas, Decimal Precision, Health Check

Summary

This PR addresses four issues across the backend and frontend:

Issue #303: Late Fee Compounding

Problem: Late fee cap (25% of principal) was ineffective when principal was zero, allowing fees to compound on themselves.
Solution: Changed late fee calculation to use original loan.amount (principal) as the base instead of remaining debt. Late fees now stop accruing once principal is fully paid.
Files: contracts/loan_manager/src/lib.rs

Issue #314: Hardcoded Score Deltas

Status: Already implemented ✓
Details: Score deltas are configurable via environment variables:

  • SCORE_DELTA_REPAY (default: 15)
  • SCORE_DELTA_DEFAULT (default: 50)
  • SCORE_DELTA_LATE (default: 5)
    Files: backend/src/config/env.ts, backend/src/services/sorobanService.ts

Issue #578: Decimal Precision Enforcement

Problem: Amount inputs didn't enforce decimal precision limits per asset type (XLM: 7, USDC: 2, EURC: 2, PHP: 2).
Solution:

  • Added ASSET_DECIMALS map and getAssetDecimals() utility
  • Added formatAmountOnBlur() to format amounts on blur
  • Updated all amount input forms with step attribute and onBlur formatting
  • Updated helper text to show max decimal places per asset
    Files:
  • frontend/src/app/utils/amount.ts
  • frontend/src/app/components/loan-wizard/StepAmountAsset.tsx
  • frontend/src/app/components/borrower/LoanRepaymentForm.tsx
  • frontend/src/app/components/remittance/RemittanceForm.tsx
  • frontend/src/app/[locale]/repay/[loanId]/page.tsx
  • frontend/src/app/[locale]/lend/LendPageClient.tsx

Issue #7: Health Check Endpoint

Status: Already implemented ✓
Details: GET /health endpoint returns:

  • Status: "ok", "degraded", or "down"
  • Individual checks: api, database, redis, soroban_rpc
  • Uptime and timestamp
  • HTTP 200 for healthy, 503 for degraded/down
    Files: backend/src/app.ts

Testing

  • ✓ Backend health endpoint tests pass
  • ✓ Frontend linting passes
  • ✓ All changes follow project conventions

Closes #303
Closes #314
Closes #578
Closes #7

- Add ASSET_DECIMALS map with XLM (7), USDC (2), EURC (2), PHP (2)
- Add getAssetDecimals() to retrieve decimals per asset
- Add formatAmountOnBlur() to format amounts on blur event
- Update getPrecisionError() to use asset-specific decimals
- Enables proper decimal validation for different asset types
…nput

- Add step attribute based on asset decimals
- Add onBlur formatting to enforce precision
- Update helper text to show max decimal places
- Import getAssetDecimals and formatAmountOnBlur utilities
- Add step attribute for USDC (2 decimals)
- Add onBlur formatting to enforce precision
- Update helper text to show max decimal places
- Import formatAmountOnBlur and getAssetDecimals utilities
- Add step attribute based on asset decimals
- Add onBlur formatting to enforce precision
- Update helper text to show max decimal places per asset
- Support USDC (2), EURC (2), PHP (2) decimal precision
- Import formatAmountOnBlur and getAssetDecimals utilities
- Add step attribute for USDC (2 decimals)
- Add onBlur formatting to enforce precision
- Update helper text to show max decimal places
- Import formatAmountOnBlur and getAssetDecimals utilities
…thdraw

- Add step attributes based on asset decimals
- Add onBlur formatting for both deposit and withdraw inputs
- Update helper text to show max decimal places
- Import formatAmountOnBlur and getAssetDecimals utilities
- Change late fee base from remaining_debt to original loan.amount
- Prevents late fees from compounding on themselves when principal is zero
- Ensures 25% late fee cap is meaningful regardless of payment state
- Stop accruing late fees once principal is fully paid
@ogazboiz
ogazboiz merged commit 0acfad4 into LabsCrypt:main May 27, 2026
3 of 6 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

2 participants