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

fix(inflation): fix default inflation allocation params #1688

Merged
merged 4 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1659](https://github.com/NibiruChain/nibiru/pull/1659) - refactor(oracle): curate oracle default whitelist
* [#1679](https://github.com/NibiruChain/nibiru/pull/1679) - test(perp): add more tests for perp module msg server
* [#1686](https://github.com/NibiruChain/nibiru/pull/1686) - test(perp): add more tests for perp module msg server for DnR
* [#1688](https://github.com/NibiruChain/nibiru/pull/1688) - fix(inflation): make default inflation allocation follow tokenomics
Copy link
Contributor

Choose a reason for hiding this comment

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

The same entry for the fix related to default inflation allocation appears twice in the changelog, which seems to be an oversight and should be consolidated into a single entry.


### Dependencies
- Bump `github.com/prometheus/client_golang` from 1.16.0 to 1.17.0 ([#1605](https://github.com/NibiruChain/nibiru/pull/1605))
Expand Down
7 changes: 0 additions & 7 deletions x/inflation/keeper/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,20 @@ func TestPeriodChangesSkippedEpochsAfterEpochEnd(t *testing.T) {

// Perform Epoch Hooks
futureCtx := ctx.WithBlockTime(time.Now().Add(time.Minute))
fmt.Println("tc.height", tc.height)
nibiruApp.EpochsKeeper.BeforeEpochStart(futureCtx, tc.epochIdentifier, tc.height)
nibiruApp.EpochsKeeper.AfterEpochEnd(futureCtx, tc.epochIdentifier, tc.height)

skippedEpochs := nibiruApp.InflationKeeper.NumSkippedEpochs.Peek(ctx)
period := nibiruApp.InflationKeeper.CurrentPeriod.Peek(ctx)

if tc.periodChanges {
fmt.Println("periodChanges", tc.periodChanges)
newProvision := nibiruApp.InflationKeeper.GetEpochMintProvision(ctx)

expectedProvision := types.CalculateEpochMintProvision(
nibiruApp.InflationKeeper.GetParams(ctx),
period,
)

fmt.Println("periodChanges", tc.periodChanges)
fmt.Println("newProvision", newProvision)
fmt.Println("expectedProvision", expectedProvision)
fmt.Println("originalProvision", originalProvision)

require.Equal(t, expectedProvision, newProvision)
// mint provisions will change
require.NotEqual(t, newProvision, originalProvision)
Expand Down
24 changes: 12 additions & 12 deletions x/inflation/keeper/inflation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func TestMintAndAllocateInflation(t *testing.T) {
{
name: "pass",
coinsToMint: sdk.NewCoin(denoms.NIBI, sdk.NewInt(1_000_000)),
expectedStakingAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(278_000)),
expectedStrategicAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000)),
expectedCommunityAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(622_000)),
expectedStakingRewardsBalance: sdk.NewCoin(denoms.NIBI, sdk.NewInt(278_000)),
expectedStrategicReservesBalance: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000)),
expectedCommunityPoolBalance: sdk.NewDecCoins(sdk.NewDecCoin(denoms.NIBI, sdk.NewInt(622_000))),
expectedStakingAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(277_572)),
expectedStrategicAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(370_837)),
expectedCommunityAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(351_591)),
expectedStakingRewardsBalance: sdk.NewCoin(denoms.NIBI, sdk.NewInt(277_572)),
expectedStrategicReservesBalance: sdk.NewCoin(denoms.NIBI, sdk.NewInt(370_837)),
expectedCommunityPoolBalance: sdk.NewDecCoins(sdk.NewDecCoin(denoms.NIBI, sdk.NewInt(351_591))),
rootAccount: "nibi1qyqf35fkhn73hjr70442fctpq8prpqr9ysj9sn",
},
{
Expand All @@ -59,12 +59,12 @@ func TestMintAndAllocateInflation(t *testing.T) {
{
name: "pass - no root account",
coinsToMint: sdk.NewCoin(denoms.NIBI, sdk.NewInt(1_000_000)),
expectedStakingAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(278_000)),
expectedStrategicAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000)),
expectedCommunityAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(622_000)),
expectedStakingRewardsBalance: sdk.NewCoin(denoms.NIBI, sdk.NewInt(278_000)),
expectedStrategicReservesBalance: sdk.NewCoin(denoms.NIBI, sdk.NewInt(100_000)),
expectedCommunityPoolBalance: sdk.NewDecCoins(sdk.NewDecCoin(denoms.NIBI, sdk.NewInt(622_000))),
expectedStakingAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(277_572)),
expectedStrategicAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(370_837)),
expectedCommunityAmt: sdk.NewCoin(denoms.NIBI, sdk.NewInt(351_591)),
expectedStakingRewardsBalance: sdk.NewCoin(denoms.NIBI, sdk.NewInt(277_572)),
expectedStrategicReservesBalance: sdk.NewCoin(denoms.NIBI, sdk.NewInt(370_837)),
expectedCommunityPoolBalance: sdk.NewDecCoins(sdk.NewDecCoin(denoms.NIBI, sdk.NewInt(351_591))),
rootAccount: "",
},
}
Expand Down
6 changes: 3 additions & 3 deletions x/inflation/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ var (
sdk.MustNewDecFromStr("18063678.8582418"),
}
DefaultInflationDistribution = InflationDistribution{
StakingRewards: sdk.NewDecWithPrec(27_8, 3), // 27.8%
CommunityPool: sdk.NewDecWithPrec(62_20, 4), // 62.20%
StrategicReserves: sdk.NewDecWithPrec(10, 2), // 10%
CommunityPool: sdk.NewDecWithPrec(35_159141, 8), // 35.159141%
StakingRewards: sdk.NewDecWithPrec(27_757217, 8), // 27.757217%
StrategicReserves: sdk.NewDecWithPrec(37_083642, 8), // 37.083642%
Comment on lines +31 to +33
Copy link
Contributor

Choose a reason for hiding this comment

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

The sum of the new percentage values for CommunityPool, StakingRewards, and StrategicReserves exceeds 100%. This is not valid for a distribution where the total should be exactly 100%. Please correct the values to ensure they sum up to 100%.

-		CommunityPool:     sdk.NewDecWithPrec(35_159141, 8), // 35.159141%
-		StakingRewards:    sdk.NewDecWithPrec(27_757217, 8), // 27.757217%
-		StrategicReserves: sdk.NewDecWithPrec(37_083642, 8), // 37.083642%
+		CommunityPool:     sdk.NewDecWithPrec(<correct_value>, 8), // <correct_percentage>%
+		StakingRewards:    sdk.NewDecWithPrec(<correct_value>, 8), // <correct_percentage>%
+		StrategicReserves: sdk.NewDecWithPrec(<correct_value>, 8), // <correct_percentage>%

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
CommunityPool: sdk.NewDecWithPrec(35_159141, 8), // 35.159141%
StakingRewards: sdk.NewDecWithPrec(27_757217, 8), // 27.757217%
StrategicReserves: sdk.NewDecWithPrec(37_083642, 8), // 37.083642%
CommunityPool: sdk.NewDecWithPrec(<correct_value>, 8), // <correct_percentage>%
StakingRewards: sdk.NewDecWithPrec(<correct_value>, 8), // <correct_percentage>%
StrategicReserves: sdk.NewDecWithPrec(<correct_value>, 8), // <correct_percentage>%

}
DefaultEpochsPerPeriod = uint64(30)
DefaultPeriodsPerYear = uint64(12)
Expand Down
Loading