Skip to content

feat: total rewards distributed and backer rewards claimed from state… - #2157

Closed
franciscotobar wants to merge 1 commit into
mainfrom
state-sync-rewards
Closed

feat: total rewards distributed and backer rewards claimed from state…#2157
franciscotobar wants to merge 1 commit into
mainfrom
state-sync-rewards

Conversation

@franciscotobar

Copy link
Copy Markdown
Collaborator

… sync

@franciscotobar
franciscotobar requested a review from Copilot June 9, 2026 01:59
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 claimed as Record<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.

@franciscotobar

Copy link
Copy Markdown
Collaborator Author

Closed on behalf of #2158

@scguaquetam
scguaquetam deleted the state-sync-rewards branch June 12, 2026 15:10
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.

2 participants