fix: remove erroneous 10^6 multiplier in claim_payout accounting#15
Open
optimus-fulcria wants to merge 1 commit intoStockpileLabs:masterfrom
Open
fix: remove erroneous 10^6 multiplier in claim_payout accounting#15optimus-fulcria wants to merge 1 commit intoStockpileLabs:masterfrom
optimus-fulcria wants to merge 1 commit intoStockpileLabs:masterfrom
Conversation
The adj_payout variable was being multiplied by 10^6 AFTER the token transfer but BEFORE updating project.raised and project.balance. This caused a severe accounting mismatch where: - Actual tokens transferred: adj_payout - project.balance recorded: adj_payout * 10^6 This bug would cause withdraw_all to fail (trying to transfer more tokens than available) or lead to incorrect financial reporting. The fix removes the 10^6 multiplication so that project accounting matches the actual token amounts transferred. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
This PR fixes a critical accounting bug in the
claim_payoutfunction whereproject.balanceandproject.raisedwere being inflated by a factor of 10^6 compared to the actual tokens transferred.Bug Details
File:
programs/stockpile-v2/src/instructions/claim_payout.rsThe
adj_payoutvariable was being multiplied by10^6after the token transfer but before updating project accounting:Impact
Fund Locking:
withdraw_allusesproject.balance.into()as the transfer amount, which would fail due to insufficient funds (trying to transfer 10^6x more tokens than available)Accounting Inconsistency: Projects would report inflated
raisedamountsFix
Removed the erroneous
10^6multiplication so project accounting matches actual token amounts.Testing
The fix is straightforward - removing one line of code. The existing test suite should validate that claims and withdrawals work correctly with consistent amounts.
Found during Superteam Earn security bounty audit