Skip to content

Commit

Permalink
upgrade handlers for beta-net
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanmay committed Apr 13, 2022
1 parent a329e3b commit 7efddc2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 98 deletions.
62 changes: 0 additions & 62 deletions x/clp/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,65 +43,3 @@ func (m Migrator) MigrateToVer2(ctx sdk.Context) error {
}
return nil
}

func (m Migrator) MigrateToVer3(ctx sdk.Context) error {
// Initiate Rewards
m.keeper.SetRewardParams(ctx, types.GetDefaultRewardParams())
// Initiate PMTP
m.keeper.SetPmtpRateParams(ctx, types.PmtpRateParams{
PmtpPeriodBlockRate: sdk.ZeroDec(),
PmtpCurrentRunningRate: sdk.ZeroDec(),
PmtpInterPolicyRate: sdk.ZeroDec(),
})
m.keeper.SetPmtpEpoch(ctx, types.PmtpEpoch{
EpochCounter: 0,
BlockCounter: 0,
})
m.keeper.SetPmtpParams(ctx, types.GetDefaultPmtpParams())
m.keeper.SetPmtpInterPolicyRate(ctx, sdk.NewDec(0))
pools := m.keeper.GetPools(ctx)
for _, pool := range pools {
spe := sdk.ZeroDec()
spn := sdk.ZeroDec()
rpnd := sdk.ZeroUint()
pool.SwapPriceExternal = &spe
pool.SwapPriceNative = &spn
pool.RewardPeriodNativeDistributed = rpnd
err := m.keeper.SetPool(ctx, pool)
if err != nil {
panic(err)
}
}
return nil
}

func (m Migrator) MigrateToVer4(ctx sdk.Context) error {
// Initiate Rewards
m.keeper.SetRewardParams(ctx, types.GetDefaultRewardParams())
// Initiate PMTP
m.keeper.SetPmtpRateParams(ctx, types.PmtpRateParams{
PmtpPeriodBlockRate: sdk.ZeroDec(),
PmtpCurrentRunningRate: sdk.ZeroDec(),
PmtpInterPolicyRate: sdk.ZeroDec(),
})
m.keeper.SetPmtpEpoch(ctx, types.PmtpEpoch{
EpochCounter: 0,
BlockCounter: 0,
})
m.keeper.SetPmtpParams(ctx, types.GetDefaultPmtpParams())
m.keeper.SetPmtpInterPolicyRate(ctx, sdk.NewDec(0))
pools := m.keeper.GetPools(ctx)
for _, pool := range pools {
spe := sdk.ZeroDec()
spn := sdk.ZeroDec()
rpnd := sdk.ZeroUint()
pool.SwapPriceExternal = &spe
pool.SwapPriceNative = &spn
pool.RewardPeriodNativeDistributed = rpnd
err := m.keeper.SetPool(ctx, pool)
if err != nil {
panic(err)
}
}
return nil
}
10 changes: 1 addition & 9 deletions x/clp/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
if err != nil {
panic(err)
}
err = cfg.RegisterMigration(types.ModuleName, 2, m.MigrateToVer3)
if err != nil {
panic(err)
}
err = cfg.RegisterMigration(types.ModuleName, 3, m.MigrateToVer4)
if err != nil {
panic(err)
}
}

// InitGenesis performs genesis initialization for the clp module. It returns
Expand Down Expand Up @@ -173,4 +165,4 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
return EndBlocker(ctx, am.keeper)
}

func (AppModule) ConsensusVersion() uint64 { return 4 }
func (AppModule) ConsensusVersion() uint64 { return 2 }
19 changes: 0 additions & 19 deletions x/clp/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,6 @@ func GetLiquidityProviderKey(externalTicker string, lp string) []byte {
return append(LiquidityProviderPrefix, key...)
}

// TODO remove
// func DefaultRewardsPeriod() []*RewardPeriod {
// rp_1_allocation := sdk.NewUintFromString("10000000000000000000000")
// cethMultiplier := sdk.MustNewDecFromStr("1.5")
// rewardPeriods := []*RewardPeriod{
// {
// RewardPeriodId: "RP_1",
// RewardPeriodStartBlock: 1,
// RewardPeriodEndBlock: 12 * 60 * 24 * 7,
// RewardPeriodAllocation: &rp_1_allocation,
// RewardPeriodPoolMultipliers: []*PoolMultiplier{{
// PoolMultiplierAsset: "ceth",
// Multiplier: &cethMultiplier,
// }},
// },
// }
// return rewardPeriods
// }

func GetDefaultRewardParams() *RewardParams {
return &RewardParams{
LiquidityRemovalLockPeriod: 12 * 60 * 24 * 7,
Expand Down
10 changes: 2 additions & 8 deletions x/tokenregistry/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ func (m Migrator) MigrateToVer2(ctx sdk.Context) error {
}

func (m Migrator) MigrateToVer3(ctx sdk.Context) error {
accounts := tkrtypes.AdminAccounts{}
if ctx.ChainID() == "sifchain-1" {
gen := tkrtypes.ProdAdminAccounts()
accounts = *gen
} else {
gen := tkrtypes.InitialAdminAccounts()
accounts = *gen
}
gen := tkrtypes.ProdAdminAccounts()
accounts := *gen
m.keeper.DeleteOldAdminAccount(ctx)
for _, account := range accounts.AdminAccounts {
m.keeper.SetAdminAccount(ctx, account)
Expand Down

0 comments on commit 7efddc2

Please sign in to comment.