Use user_challenges.amount in claim, not static reward config#783
Merged
dylanjeffers merged 1 commit intomainfrom May 1, 2026
Merged
Use user_challenges.amount in claim, not static reward config#783dylanjeffers merged 1 commit intomainfrom
dylanjeffers merged 1 commit intomainfrom
Conversation
The /v1/rewards/claim handler was passing the static reward config amount (always 1000 for tt/tut) into both the validator attestation fetch and the EvaluateAttestation Solana instruction, ignoring the per-row amount stored on user_challenges. This breaks rank-dependent payouts. Trending tracks and trending underground winners 6-10 are written with amount=100 in user_challenges (ranks 1-5 keep 1000), but the API was claiming 1000 for everyone - overpaying ranks 6-10 by 10x when claims succeeded, and likely contributing to on-chain failures on retries where prior partial state referenced different amounts. Adds the amount column to GetUndisbursedChallenges, plumbs it through to RewardClaim. The static config amount is no longer consulted for the claim itself; we still call getReward() to validate that the challenge id is configured. Co-Authored-By: Claude Opus 4.7 (1M context) <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
The
/v1/rewards/claimhandler ignoresuser_challenges.amountand falls back to the static reward config (always 1000 fortt/tut). This breaks rank-dependent payouts introduced for the top-10 trending change — ranks 6-10 are written withamount=100but the API was claiming 1000 for everyone.Visible symptoms during today's
/disburse 2026-05-01from the trending-challenge-rewards bot:ttand 0 of 10tutclaims succeededIncorrectOwner(custom code 0) on the EvaluateAttestation step — likely amount-mismatch state on verified_messages PDAs from earlier attemptsChanges
api/dbv1/queries/get_undisbursed_challenges.sql— selectuser_challenges.amountapi/dbv1/get_undisbursed_challenges.sql.go—GetUndisbursedChallengesRow.Amount int32api/v1_claim_rewards.go— userow.Amountfor bothresults[i].AmountandRewardClaim.Amount. Still callgetReward()to validate the challenge id is configured, but discard the static amount.Test plan
go build ./...cleantt:<week>:6(rank 6, amount=100 in user_challenges) and verify the on-chain transfer is 100 AUDIO, not 1000/disbursecycle for a recent week with 10 tt + 10 tut, confirm ranks 1-5 get 1000 and 6-10 get 100/disburse 2026-05-01from pedalboard after deploy, confirm the 11 currently-failing claims now succeed🤖 Generated with Claude Code