Skip to content

Commit

Permalink
Merge pull request #533 from comdex-official/hbr-test
Browse files Browse the repository at this point in the history
Hbr test
  • Loading branch information
pratikasr authored Oct 24, 2022
2 parents 0054317 + 29812bb commit 8251dc3
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ func upgradeHandlers(upgradeInfo storetypes.UpgradeInfo, a *App, storeUpgrades *
storeUpgrades = &storetypes.StoreUpgrades{}
case upgradeInfo.Name == tv4_0_0.UpgradeNameV4_4_0 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{
Deleted: []string{"assetv1", "lendV1", "liquidationV1", "market", "rewardsV1"},
Added: []string{
assettypes.ModuleName,
lendtypes.ModuleName,
Expand Down
5 changes: 5 additions & 0 deletions app/upgrades/testnet/v4_0_0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ func CreateUpgradeHandlerV440(
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// This change is only for testnet upgrade
SetVaultLengthCounter(ctx, vaultkeeper)
//delete(fromVM, "assetv1")
//delete(fromVM, "lendV1")
//delete(fromVM, "liquidationV1")
//delete(fromVM, "market")
//delete(fromVM, "rewardsV1")
newVM, err := mm.RunMigrations(ctx, configurator, fromVM)
if err != nil {
return newVM, err
Expand Down
2 changes: 1 addition & 1 deletion x/asset/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

const (
ModuleName = "assetv1"
ModuleName = "assetV2"
ParamsSubspace = ModuleName
QuerierRoute = ModuleName
RouterKey = ModuleName
Expand Down
2 changes: 1 addition & 1 deletion x/lend/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) {
//if err != nil {
// ctx.Logger().Error("error in ReBalance Stable Rates")
//}
if ctx.BlockHeight() == 280 {
if ctx.BlockHeight() == 183 {
err2 := k.MigrateData(ctx)
if err2 != nil {
ctx.Logger().Error("error in Migrate Data")
Expand Down
2 changes: 1 addition & 1 deletion x/lend/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

const (
// ModuleName defines the module name.
ModuleName = "lendV1"
ModuleName = "lendV2"

// ModuleAcc1 , ModuleAcc2 & ModuleAcc3 defines different module accounts to store selected pairs of asset.
ModuleAcc1 = "cmdx"
Expand Down
2 changes: 1 addition & 1 deletion x/liquidation/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

const (
ModuleName = "liquidationV1"
ModuleName = "liquidationV2"
ParamsSubspace = ModuleName
QuerierRoute = ModuleName
RouterKey = ModuleName
Expand Down
54 changes: 54 additions & 0 deletions x/market/keeper/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,57 @@ func (k Keeper) CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price s
}
return sdk.ZeroDec(), types.ErrorPriceNotActive
}

// UNComment below and comment respective functions

//func (k Keeper) CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Dec, err error) {
// asset, found := k.assetKeeper.GetAsset(ctx, id)
// if !found {
// return sdk.ZeroDec(), assetTypes.ErrorAssetDoesNotExist
// }
// // twa, found := k.GetTwa(ctx, id)
// var rate uint64
// if id == 1 {
// rate = 11632845
// }
// if id == 2 {
// rate = 14053
// }
// if id == 3 {
// rate = 1000000
// }
// if id == 4 {
// rate = 2200000
// }
// if id == 10 {
// rate = 1297119384
// }
// if found {
// numerator := sdk.NewDecFromInt(amt).Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(rate)))
// denominator := sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(asset.Decimals)))
// return numerator.Quo(denominator), nil
// }
// return sdk.ZeroDec(), types.ErrorPriceNotActive
//}
//
//func (k Keeper) GetTwa(ctx sdk.Context, id uint64) (twa types.TimeWeightedAverage, found bool) {
// twa.AssetID = id
// twa.IsPriceActive = true
// if id == 1 {
// twa.Twa = 11632845
// }
// if id == 2 {
// twa.Twa = 140530
// }
// if id == 3 {
// twa.Twa = 1000000
// }
// if id == 4 {
// twa.Twa = 2200000
// }
// if id == 10 {
// twa.Twa = 1297119384
// }
//
// return twa, true
//}
2 changes: 1 addition & 1 deletion x/market/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

const (
ModuleName = "market"
ModuleName = "marketV2"
ParamsSubspace = ModuleName
QuerierRoute = ModuleName
RouterKey = ModuleName
Expand Down
2 changes: 1 addition & 1 deletion x/rewards/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

const (
// ModuleName defines the module name.
ModuleName = "rewardsV1"
ModuleName = "rewardsV2"

// StoreKey defines the primary module store key.
StoreKey = ModuleName
Expand Down

0 comments on commit 8251dc3

Please sign in to comment.