fix(scoring): reduce spike sensitivity and cap retentionRate#56
Open
daree-dev wants to merge 1 commit into
Open
fix(scoring): reduce spike sensitivity and cap retentionRate#56daree-dev wants to merge 1 commit into
daree-dev wants to merge 1 commit into
Conversation
…on1#42) - Replace 1/(daysAgo+1) time decay with soft 30-day half-life: weight = 1 / (1 + daysAgo/30). Old formula let a single large recent deposit dominate; new formula keeps older deposits relevant. - Normalize weightedVolume by totalDeposited so score reflects consistency rather than raw deposit size. - Cap retentionRate at 1 to prevent a grown balance from inflating score. - Add hard score ceiling at 1000 (Platino max). - Export computeFinancialReputation for unit testing. - Add 8 regression tests covering: eligibility gate, spike tier cap, retentionRate cap, drain penalty, score ceiling, tier mapping. Closes Kalebtron1#42
|
@daree-dev is attempting to deploy a commit to the alankcr1-6443's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@daree-dev 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! 🚀 |
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.
Closes #42
What changed
Before:
timeWeight = 1/(daysAgo+1)— a single large deposit made today could dominate the entire score.retentionRatehad no upper bound, so a balance that grew beyond total deposits inflated the score. No score ceiling existed.After:
1/(daysAgo+1)— aggressive, spike-sensitive1/(1+daysAgo/30)— soft 30-day half-lifetotalDeposited(range 0–1)How to review
npm run test— all 9 tests should pass.npm run build— should compile cleanly.POST /api/calculate-scorewith:{ address, totalDeposited: 10200 }on a wallet with one 10 000 XLM deposit today and two 100 XLM deposits 60/90 days ago → score should be in Plata tier (50–149), not Oro.totalDeposited: 5000with balance 8000 →metrics.retentionshould be1.00, not1.6.Test data
8 regression tests added in
src/test/calculate-score.test.tscovering: