Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(upgrade): change rewards multiplier for mainnet #472

Merged
merged 2 commits into from
Feb 4, 2025
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
28 changes: 27 additions & 1 deletion client/app/upgrades/singularity/virgil/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package virgil

import (
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -16,7 +17,7 @@ const (
// AeneidUpgradeHeight defines the block height at which virgil upgrade is triggered on Aeneid.
AeneidUpgradeHeight = 345158
// StoryUpgradeHeight defines the block height at which virgil upgrade is triggered on Story.
StoryUpgradeHeight = 677886
StoryUpgradeHeight = 809988
)

var Upgrade = upgrades.Upgrade{
Expand All @@ -32,6 +33,12 @@ var Fork = upgrades.Fork{
BeginForkLogic: func(_ sdk.Context, _ *keepers.Keepers) {},
}

type RewardsMultipliers struct {
Short math.LegacyDec
Medium math.LegacyDec
Long math.LegacyDec
}

func GetUpgradeHeight(chainID string) (int64, bool) {
switch chainID {
case upgrades.AeneidChainID:
Expand All @@ -42,3 +49,22 @@ func GetUpgradeHeight(chainID string) (int64, bool) {
return 0, false
}
}

var DefaultRewardsMultiplier = RewardsMultipliers{
Short: math.LegacyNewDecWithPrec(1051, 3), // 1.051
Medium: math.LegacyNewDecWithPrec(116, 2), // 1.16
Long: math.LegacyNewDecWithPrec(134, 2), // 1.34
}

func GetRewardsMultipliers(chainID string) RewardsMultipliers {
switch chainID {
case upgrades.StoryChainID:
return RewardsMultipliers{
Short: math.LegacyNewDecWithPrec(11, 1), // 1.1
Medium: math.LegacyNewDecWithPrec(15, 1), // 1.5
Long: math.LegacyNewDecWithPrec(20, 1), // 2
}
default:
return DefaultRewardsMultiplier
}
}
18 changes: 17 additions & 1 deletion client/app/upgrades/singularity/virgil/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,24 @@ func CreateUpgradeHandler(
}

log.Info(ctx, "Update staking periods...")
newRewardsMultiplier := GetRewardsMultipliers(chainID)
var oldShortPeriodDuration time.Duration
for i := range stakingParams.Periods {
if stakingParams.Periods[i].PeriodType == 1 {
oldShortPeriodDuration = stakingParams.Periods[i].Duration
log.Info(ctx, "Existing short period duration", "Time", oldShortPeriodDuration.String())
log.Info(ctx, "Change short period duration to 90 days (7776000 seconds)")
stakingParams.Periods[i].Duration = NewShortPeriodDuration
log.Info(ctx, "Change short period rewards multiplier", "new_multiplier", newRewardsMultiplier.Short.String())
stakingParams.Periods[i].RewardsMultiplier = newRewardsMultiplier.Short
} else if stakingParams.Periods[i].PeriodType == 2 {
log.Info(ctx, "Existing medium period duration", "Time", stakingParams.Periods[i].Duration.String())
log.Info(ctx, "Change medium period rewards multiplier", "new_multiplier", newRewardsMultiplier.Medium.String())
stakingParams.Periods[i].RewardsMultiplier = newRewardsMultiplier.Medium
} else if stakingParams.Periods[i].PeriodType == 3 {
log.Info(ctx, "Existing long period duration", "Time", stakingParams.Periods[i].Duration.String())
log.Info(ctx, "Change long period rewards multiplier", "new_multiplier", newRewardsMultiplier.Long.String())
stakingParams.Periods[i].RewardsMultiplier = newRewardsMultiplier.Long
}
}

Expand All @@ -71,15 +78,24 @@ func CreateUpgradeHandler(
}

for _, p := range stakingParams.Periods {
if p.PeriodType == 1 {
if p.PeriodType == 1 { //nolint:nestif // no issue
log.Info(ctx, "New short period duration", "Time", p.Duration.String())
if p.Duration != NewShortPeriodDuration {
return vm, errors.New("new short period duration is not correct")
}
if !p.RewardsMultiplier.Equal(newRewardsMultiplier.Short) {
return vm, errors.New("new short period rewards multiplier is not correct")
}
} else if p.PeriodType == 2 {
log.Info(ctx, "New medium period duration", "Time", p.Duration.String())
if !p.RewardsMultiplier.Equal(newRewardsMultiplier.Medium) {
return vm, errors.New("new medium period rewards multiplier is not correct")
}
} else if p.PeriodType == 3 {
log.Info(ctx, "New long period duration", "Time", p.Duration.String())
if !p.RewardsMultiplier.Equal(newRewardsMultiplier.Long) {
return vm, errors.New("new long period rewards multiplier is not correct")
}
}
}

Expand Down
Loading