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(community): add AnnualizedRewards grpc query #1751

Merged
merged 6 commits into from Oct 24, 2023

Conversation

pirtleshell
Copy link
Member

Description

Adds x/community query for annualized rewards which gives the annualized staking reward rate

Checklist

  • Changelog has been updated as necessary.

// this module uses sdkmath.LegacyDec in its parameters
// TODO: remove me after upgrade to cosmos-sdk v50 (LegacyDec is everywhere)
func convertDecToLegacyDec(in sdk.Dec) sdkmath.LegacyDec {
return sdkmath.LegacyNewDecFromBigIntWithPrec(in.BigInt(), sdkmath.LegacyPrecision)
Copy link
Member

Choose a reason for hiding this comment

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

This should be the sdk.Precision or the precision of the in param

Copy link
Member

@nddeluca nddeluca left a comment

Choose a reason for hiding this comment

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

Great overall, just some minor comments and improvements that can be made.

x/community/keeper/rewards.go Outdated Show resolved Hide resolved
x/community/keeper/rewards.go Outdated Show resolved Hide resolved
x/community/keeper/rewards.go Outdated Show resolved Hide resolved
// It assumes that staking comes from one of two sources depending on if inflation is enabled or not.
type StakingRewardCalculator struct {
TotalSupply sdkmath.Int
TotalBonded sdkmath.Int
Copy link
Member

Choose a reason for hiding this comment

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

These data members aren't used outside of internals, so should be private

x/community/keeper/rewards_test.go Outdated Show resolved Hide resolved
x/community/keeper/rewards_test.go Show resolved Hide resolved
@pirtleshell pirtleshell force-pushed the rp-annualized-staking-reward-endpoint branch from 712a4e8 to f6a558a Compare October 24, 2023 19:04
@pirtleshell pirtleshell merged commit 0efe7f2 into master Oct 24, 2023
10 checks passed
@pirtleshell pirtleshell deleted the rp-annualized-staking-reward-endpoint branch October 24, 2023 19:24
@pirtleshell pirtleshell added the A:backport/v0.24.x Backport to release/v0.24.x branch label Oct 24, 2023
mergify bot pushed a commit that referenced this pull request Oct 24, 2023
* add annualized_reward query proto

* use sdkmath.LegacyDec to match RPS param...

* add AnnualizedRewards grpc query

* add changelog entry

* simplify calculation & expand test cases

(cherry picked from commit 0efe7f2)

# Conflicts:
#	CHANGELOG.md
#	client/docs/swagger-ui/swagger.yaml
#	x/community/keeper/staking.go
#	x/community/types/expected_keepers.go
#	x/community/types/query.pb.go
pirtleshell added a commit that referenced this pull request Oct 25, 2023
…1754)

* feat(community): add AnnualizedRewards grpc query (#1751)

* add annualized_reward query proto

* use sdkmath.LegacyDec to match RPS param...

* add AnnualizedRewards grpc query

* add changelog entry

* simplify calculation & expand test cases

(cherry picked from commit 0efe7f2)

* fix conflicts, remove community param references

* backport update to lint CI

* disable internal testnet genesis check

* fix initialization order of keepers in app.go

---------

Co-authored-by: Robert Pirtle <Astropirtle@gmail.com>
pirtleshell added a commit that referenced this pull request Oct 25, 2023
…1754)

* feat(community): add AnnualizedRewards grpc query (#1751)

* add annualized_reward query proto

* use sdkmath.LegacyDec to match RPS param...

* add AnnualizedRewards grpc query

* add changelog entry

* simplify calculation & expand test cases

(cherry picked from commit 0efe7f2)

* fix conflicts, remove community param references

* backport update to lint CI

* disable internal testnet genesis check

* fix initialization order of keepers in app.go

---------

Co-authored-by: Robert Pirtle <Astropirtle@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v0.24.x Backport to release/v0.24.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants