feat: total rewards distributed and backer rewards claimed from state… - #2157
Closed
franciscotobar wants to merge 1 commit into
Closed
feat: total rewards distributed and backer rewards claimed from state…#2157franciscotobar wants to merge 1 commit into
franciscotobar wants to merge 1 commit into
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR shifts several reward metrics to prefer StateSync/DB-derived data (cycles + claimed rewards) while keeping an on-chain event-log fallback path, and updates the backer “claimed” shape from per-event logs to per-gauge bigint totals.
Changes:
- Add hooks to compute “Total Rewards Distributed” from
/api/cycles(primary) with a NotifyReward event fallback. - Add a new API route and hook to fetch backer rewards claimed from the DB when StateSync is healthy, with Blockscout event fallback when unhealthy.
- Update backer reward consumers to treat
claimedasRecord<gauge, bigint>instead of arrays of claim events.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/my-rewards/backers/hooks/useBackerTotalEarned.ts | Adjust claimed aggregation to sum bigint totals per gauge. |
| src/app/collective-rewards/rewards/hooks/useGetTotalRewardsFromEvents.ts | New fallback hook aggregating NotifyReward logs into per-token + combined fiat totals. |
| src/app/collective-rewards/rewards/hooks/useGetTotalRewardsFromCycles.ts | New primary hook aggregating rewards across all DB cycles with StateSync health gating. |
| src/app/collective-rewards/rewards/hooks/useGetGaugesEvents.ts | Add enabled param and disable query when no gauges. |
| src/app/collective-rewards/rewards/hooks/index.ts | Export new total-rewards hooks. |
| src/app/collective-rewards/rewards/backers/hooks/useGetRBI.ts | Update claimed computation to sum bigint totals. |
| src/app/collective-rewards/rewards/backers/hooks/useGetGaugesBackerRewardsClaimed.ts | Thread enabled through to the shared gauge-events hook. |
| src/app/collective-rewards/rewards/backers/hooks/useGetBackerRewardsClaimed.ts | New hook implementing DB→(Graph placeholder)→Blockscout fallback chain and normalizing to Record<gauge,bigint>. |
| src/app/collective-rewards/rewards/backers/hooks/useGetBackerRewards.ts | Update metrics to use bigint claimed totals per gauge. |
| src/app/collective-rewards/rewards/backers/hooks/index.ts | Export new backer claimed hook. |
| src/app/collective-rewards/rewards/backers/context/BackerRewardsContext.tsx | Switch context claimed type to Record<gauge,bigint> and wire in the new claimed hook. |
| src/app/collective-rewards/components/TotalRewardsDistributed/TotalRewardsDistributed.tsx | Convert component to withDataFallback (cycles primary, events fallback). |
| src/app/api/db/constants.ts | Add allowed columns list for the new backer-claimed endpoint pagination/sorting. |
| src/app/api/backers/[backer]/rewards-claimed/route.ts | New DB-backed endpoint to query claimed rewards (optionally filtered by token) with pagination. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
|
Closed on behalf of #2158 |
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.
… sync