-
Notifications
You must be signed in to change notification settings - Fork 23
Rewards in extension: projections take into account current balances #2062
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
Conversation
| const currentBalance = Object.entries(this.portfolio.balancePerNetwork) | ||
| .filter(([k]) => | ||
| portfolioAccountState.projectedRewards?.result?.supportedChainIds | ||
| .map((n) => n.toString()) | ||
| .includes(k) | ||
| ) | ||
| .map(([, v]): number => v) | ||
| .reduce((a, b) => a + b, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this has a very slim chance of happening in the real world, but what if the user has some rewards network disabled and has balance on that network? Then that will decrease his rewards, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, is there a way to get the balance of disabled network? I do not think this is a big issue, since those live balances are used only for projection and rewardss are not actually decided based on that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there isn't and yes it's not decided based on that but then users will see a wrong projection at all times because both rewards and the extension will calculate it like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, but if we decide to not take into account the current user balance when there is a disabled network will be more inaccurate than taking into account the current balance without the disabled netork
Change:
Instead of calculating projected rewards based solely on snapshot data from relayer, now we take into account the current balances from the wallet:
To test