Skip to content

Use user_challenges.amount in claim, not static reward config#783

Merged
dylanjeffers merged 1 commit intomainfrom
fix-claim-rewards-amount
May 1, 2026
Merged

Use user_challenges.amount in claim, not static reward config#783
dylanjeffers merged 1 commit intomainfrom
fix-claim-rewards-amount

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

The /v1/rewards/claim handler ignores user_challenges.amount and falls back to the static reward config (always 1000 for tt/tut). This breaks rank-dependent payouts introduced for the top-10 trending change — ranks 6-10 are written with amount=100 but the API was claiming 1000 for everyone.

Visible symptoms during today's /disburse 2026-05-01 from the trending-challenge-rewards bot:

  • 9 of 10 tt and 0 of 10 tut claims succeeded
  • Ranks 6-10 that succeeded were paid 1000 AUDIO instead of 100 (10x overpay)
  • The ones that failed hit on-chain IncorrectOwner (custom code 0) on the EvaluateAttestation step — likely amount-mismatch state on verified_messages PDAs from earlier attempts

Changes

  • api/dbv1/queries/get_undisbursed_challenges.sql — select user_challenges.amount
  • api/dbv1/get_undisbursed_challenges.sql.goGetUndisbursedChallengesRow.Amount int32
  • api/v1_claim_rewards.go — use row.Amount for both results[i].Amount and RewardClaim.Amount. Still call getReward() to validate the challenge id is configured, but discard the static amount.

Test plan

  • go build ./... clean
  • Local: claim a tt:<week>:6 (rank 6, amount=100 in user_challenges) and verify the on-chain transfer is 100 AUDIO, not 1000
  • Stage: full /disburse cycle for a recent week with 10 tt + 10 tut, confirm ranks 1-5 get 1000 and 6-10 get 100
  • Prod: re-run /disburse 2026-05-01 from pedalboard after deploy, confirm the 11 currently-failing claims now succeed

🤖 Generated with Claude Code

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>
@dylanjeffers dylanjeffers merged commit 1512def into main May 1, 2026
5 checks passed
@dylanjeffers dylanjeffers deleted the fix-claim-rewards-amount branch May 1, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant