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

Only return net value #1939

Merged
merged 1 commit into from
Sep 20, 2024
Merged

Only return net value #1939

merged 1 commit into from
Sep 20, 2024

Conversation

iamacook
Copy link
Member

Summary

Resolves #1938

We currently return an assumed value by number of validators, e.g. 1 x validator = 32 ETH. This does not, however, take into account slashing. The value can be between 31-32 ETH.

The rewards we return is also historically accumulative. The user can therefore only claim a partial amount of this.

After discussion with Kiln, we now have access to a new net value that combines to claimable staked ETH and rewards. This is now returned as the value of validator exit request/withdrawals and rewards removed. They are combined as we don't show one or the other in the UI.

Changes

  • Add net_claimable_consensus_rewards to Stake schema/entity.
  • Add new query to KilnApi['getStakes'].
  • Remove all instances of rewards.
  • Return value based on new new net_claimable_consensus_rewards value.
  • Update tests accordingly.

@iamacook iamacook self-assigned this Sep 20, 2024
@iamacook iamacook requested a review from a team as a code owner September 20, 2024 08:14
Comment on lines +489 to +491
+stakes[0].net_claimable_consensus_rewards! +
+stakes[1].net_claimable_consensus_rewards!
).toString(),
Copy link
Member Author

Choose a reason for hiding this comment

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

These could be summed programatically but this is done to ensure the tests break if any adjustments are made. The same for all other instances.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 10955690884

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 90.757%

Totals Coverage Status
Change from base Build 10937412206: -0.01%
Covered Lines: 8301
Relevant Lines: 8773

💛 - Coveralls

@@ -353,7 +324,10 @@ export class NativeStakingMapper {
safeAddress: args.safeAddress,
validatorsPublicKeys: this.splitPublicKeys(publicKeys),
});
return stakes.reduce((acc, stake) => acc + Number(stake.rewards), 0);
return stakes.reduce((acc, stake) => {
const netValue = stake.net_claimable_consensus_rewards ?? '0';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: If net_claimable_consensus_rewards is always expected to be a number, could we update the schema to automatically parse it as such?"

Copy link
Member Author

Choose a reason for hiding this comment

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

After discussion, we will keep this as is as schemas don't transform in the project. We will, however, consider this separately.

@iamacook iamacook merged commit 24e2010 into main Sep 20, 2024
18 checks passed
@iamacook iamacook deleted the net-claimable-rewards branch September 20, 2024 09:36
DenSmolonski pushed a commit to Zilliqa/safe-client-gateway that referenced this pull request Oct 24, 2024
Returns the net `value` of validator exit request/withdrawals and removes `rewards`:

- Add `net_claimable_consensus_rewards` to `Stake` schema/entity.
- Add new query to `KilnApi['getStakes']`.
- Remove all instances of `rewards`.
- Return value based on new new `net_claimable_consensus_rewards` value.
- Update tests accordingly.
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.

Return net claimable staked and rewards amount
3 participants