From 3662c43b27581a26c382e787f994ccdd07aca877 Mon Sep 17 00:00:00 2001 From: jelysn <129082781+jelysn@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:26:17 +0800 Subject: [PATCH] Usdc earn query fix (#373) * fix denom problem, add upgrade handler for stablestake * Resolve the usage of deposit denom * fix GetDepositDenom function * add migration for interest range from 10% - 50% --- x/stablestake/keeper/params.go | 5 ++--- x/stablestake/migrations/v3_migration.go | 13 +++++++++++++ x/stablestake/module.go | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 x/stablestake/migrations/v3_migration.go diff --git a/x/stablestake/keeper/params.go b/x/stablestake/keeper/params.go index 778ae4775..5417b4ec4 100644 --- a/x/stablestake/keeper/params.go +++ b/x/stablestake/keeper/params.go @@ -18,10 +18,9 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { func (k Keeper) GetDepositDenom(ctx sdk.Context) string { params := k.GetParams(ctx) - depositDenom := params.DepositDenom entry, found := k.assetProfileKeeper.GetEntry(ctx, params.DepositDenom) if !found { - depositDenom = entry.Denom + return params.DepositDenom } - return depositDenom + return entry.Denom } diff --git a/x/stablestake/migrations/v3_migration.go b/x/stablestake/migrations/v3_migration.go new file mode 100644 index 000000000..5b0184c70 --- /dev/null +++ b/x/stablestake/migrations/v3_migration.go @@ -0,0 +1,13 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (m Migrator) V3Migration(ctx sdk.Context) error { + params := m.keeper.GetParams(ctx) + params.InterestRateMin = sdk.NewDecWithPrec(10, 2) // 10% + params.InterestRateMax = sdk.NewDecWithPrec(50, 2) // 50% + m.keeper.SetParams(ctx, params) + return nil +} diff --git a/x/stablestake/module.go b/x/stablestake/module.go index ed2ef7b88..16ea46d57 100644 --- a/x/stablestake/module.go +++ b/x/stablestake/module.go @@ -117,7 +117,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) m := migrations.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 1, m.V2Migration) + err := cfg.RegisterMigration(types.ModuleName, 2, m.V3Migration) if err != nil { panic(err) }