Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement rewards calculator and merge payout history #2482

Open
wants to merge 48 commits into
base: main
Choose a base branch
from

Conversation

joeljkrb
Copy link
Contributor

@joeljkrb joeljkrb commented Feb 3, 2025

This PR implements a new Rewards Calculator feature and merges it with the Payout History into a single tabbed interface.

Key changes:

  • Create new Rewards Calculator tool with real-time calculations
  • Migrate Payout History to new tabbed interface
  • Add number formatting with locale support
  • Update translations for Spanish and English locales (Chinese pending review)

This enhances both reward projection capabilities and historical tracking in a unified interface.

Addresses #1821

- Create tabbed Rewards Calculator page
- Move PayoutHistory to Rewards Calculator
- Refactor components into Graph, Stats, PayoutList
- Add history tab alongside rewards calculator
- Update imports and file structure
- Removal of Payouts page
- Creation of Rewards & Payouts
- Add English & Spanish translation for updated menu item
- Ting to review /cn/base.json & pages.json
@rossbulat
Copy link
Collaborator

Just making a note of next steps; to finalise the Stats that will be displayed at the top of the current Calculator page, both with Staking API enabled and disabled.

We can leverage historical data with Staking API to get reward estimations based on historical performance. With the API disabled, we can derive stats based on chain state available on-chain at the current era.

Note for Ross: Revise Stat ui components to enable a calculator stat-as-a-button.

Copy link
Collaborator

@rossbulat rossbulat left a comment

Choose a reason for hiding this comment

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

Am I correct in assuming that everything from pages/Payouts has been duplicated into pages/Rewards? If so, pages/Payouts can be deleted.

title={t('rewards.rewardsCalculator')}
tabs={[
{
title: t('rewards.calculator'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This page can be Overview. The payout history graph currently present in "Payout History" tab can be displayed at this top of this page, with the new "Projected Rewards" module being displayed below it.

The Payout History tab can then just list historical payout records.

@rossbulat
Copy link
Collaborator

rossbulat commented Feb 13, 2025

I've just been experimenting with what we have so far and noticed that we should probably include a toggle that factors the average validator commission into the projections table. Otherwise the projections are always going to be around 10% larger than the actual rewards received.

// Determine label depending if custom balance is active
const balanceLabel = isCustomStake
? t('rewards.customBalance')
: t('rewards.currentStakedBalance')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we remove "Current" from this key? Just "Staked Balance" would suffice here i think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✂️ In progress
Development

Successfully merging this pull request may close these issues.

2 participants