refactor(farming-pool): single source of truth for Position credit accrual - #133
Open
Okorie2000-code wants to merge 1 commit into
Open
Conversation
✅ Deploy Preview for sdcontracts ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
ci test failed |
…ition_credits Extract the amount * credit_rate * elapsed formula into a single compute_position_credits helper used by both checkpoint_position and calculate_credits, eliminating the duplicated calculation. Deliberately kept separate from compute_credits since Positions have no boost or multiplier semantics. Add unit coverage for the shared accrual path, adapted to the pool's min_stake_amount gate. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Okorie2000-code
force-pushed
the
fix/farming-pool-shared-position-credits
branch
from
August 17, 2026 07:59
8ee58aa to
f441d4d
Compare
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 #63
checkpoint_positionandcalculate_creditsduplicated the Position credit-accrual formula (amount * credit_rate * elapsed). This extracts it into a singlecompute_position_creditshelper shared by both paths.Changes
compute_position_credits(amount, credit_rate, elapsed)next to the existingcompute_total_stake/compute_creditshelperscheckpoint_positionnow banks credits via the shared helpercalculate_creditsnow previews credits via the exact same helperamount * credit_rate * elapsed as i128calculation remainscompute_credits(UserStake boost/multiplier semantics), per the issue's design constraint —compute_creditsis not reusedTests
Added focused unit coverage for the shared Position accrual:
elapsed = 0(amount, credit_rate, elapsed)combinationscheckpoint_position) vs previewed (viacalculate_credits) parityAll existing tests preserved.
cargo test --workspacepasses: factory 34, farming-pool 79 (74 existing + 5 new). Closes #63