Skip to content

Commit

Permalink
Merge pull request #2637 from Sifchain/chore/betanet-handlers
Browse files Browse the repository at this point in the history
Chore/betanet handlers
  • Loading branch information
Jedi2002 authored Apr 13, 2022
2 parents a329e3b + 9776e45 commit cff2ed4
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 100 deletions.
2 changes: 1 addition & 1 deletion app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

const releaseVersion = "0.13.0-rc3"
const releaseVersion = "0.13.0"

func SetupHandlers(app *SifchainApp) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm m.VersionMap) (m.VersionMap, error) {
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.13.0-rc3
0.13.0
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
8 changes: 8 additions & 0 deletions x/tokenregistry/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ func ProdAdminAccounts() *AdminAccounts {
AdminType: AdminType_ETHBRIDGE,
AdminAddress: "sif144w8cpva2xkly74xrms8djg69y3mljzplx3fjt",
},
{
AdminType: AdminType_TOKENREGISTRY,
AdminAddress: "sif1tpypxpppcf5lea47vcvgy09675nllmcucxydvu",
},
{
AdminType: AdminType_ETHBRIDGE,
AdminAddress: "sif1tpypxpppcf5lea47vcvgy09675nllmcucxydvu",
},
},
}
}
Expand Down

0 comments on commit cff2ed4

Please sign in to comment.