fix: consolidate credit tier resolution into CreditScoringService and…#108
Open
KingFRANKHOOD wants to merge 1 commit into
Open
fix: consolidate credit tier resolution into CreditScoringService and…#108KingFRANKHOOD wants to merge 1 commit into
KingFRANKHOOD wants to merge 1 commit into
Conversation
… match contract parameters - Remove duplicate mapScoreToCreditTier() from loans.service.ts - Wire getAvailableCredit through CreditScoringService.resolveTier() - Define CREDIT_TIERS as the single source of truth in credit-scoring.service.ts - Match authoritative values from parameters-contract (gold: 10000/4%, silver: 5000/6%, bronze: 2500/8%, starter: 1000/10%) - Reconcile tier naming: 'poor' -> 'starter' across all DTOs, services, and tests - Add contract-alignment test ensuring CREDIT_TIERS never drifts from parameters-contract - Add boundary score tests for 90, 89, 75, 74, 60, 59 - Update ReputationService to share CREDIT_TIERS constants BREAKING CHANGE: API tier name changes from 'poor' to 'starter' in /reputation and /loans/available-credit responses. Credit limits and interest rates updated to match deployed contract parameters (gold 10000/4%, silver 5000/6%, bronze 2500/8%, starter 1000/10%). StepFi-Web and StepFi-App must update tier name references.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the duplicate credit tier table in
loans.service.tsand establishesCreditScoringServiceas the single source of truth for tier resolution, interest rates, and credit limits. All values now match the authoritative parameters-contract deployed on Stellar testnet.Closes #100
Problem
There were two credit tier tables:
CreditScoringService(credit-scoring.service.ts) — proper NestJS service, injected but only used for loan assessment decisionsLoansService.mapScoreToCreditTier()(loans.service.ts:675) — private hardcoded table used bygetAvailableCredit, contradicting both the service and the documented protocol parametersNeither matched the contracts:
A learner could be shown a credit limit the chain would reject.
What Changed
Core fix
mapScoreToCreditTier()fromloans.service.ts— no longer existsgetAvailableCredit()throughCreditScoringService.resolveTier()— both paths now use the same serviceCREDIT_TIERSconstant array incredit-scoring.service.ts— one table, one place, named constants matching the parameters-contractCreditScoringService.resolveTier(score)method — public, canonical tier resolutionTier naming reconciliation
poortostarteracross all DTOs, services, and consumers to match the contractsstarterinstead ofpoorfor the lowest tierContract-aligned values
Consumers updated
ReputationService.mapToReputation()now usesCREDIT_TIERSinstead of inline if/elseReputationTiertype:poor->starterTests
Breaking Changes
StepFi-Web and StepFi-App must update:
poortier name references withstarterin tier-based rendering logicFiles Changed
CI
npm run build— 0 errorsnpm run lint— 0 errorsnpm test— all 94 unit tests pass