Skip to content

Commit

Permalink
upgrade refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikasr committed Nov 24, 2023
1 parent 15d4bf6 commit 4306f81
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 187 deletions.
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ import (

cwasm "github.com/comdex-official/comdex/app/wasm"

tv13 "github.com/comdex-official/comdex/app/upgrades/testnet/v13"
mv13 "github.com/comdex-official/comdex/app/upgrades/mainnet/v13"
tv13 "github.com/comdex-official/comdex/app/upgrades/testnet/v13"
)

const (
Expand Down Expand Up @@ -1457,7 +1457,7 @@ func (a *App) ModuleAccountsPermissions() map[string][]string {
func (a *App) registerUpgradeHandlers() {
a.UpgradeKeeper.SetUpgradeHandler(
mv13.UpgradeName,
mv13.CreateUpgradeHandlerV13(a.mm, a.configurator, a.cdc, a.keys[capabilitytypes.ModuleName], a.CapabilityKeeper, a.WasmKeeper, a.ParamsKeeper, a.ConsensusParamsKeeper, *a.IbcKeeper, a.ICQKeeper, a.GovKeeper, *a.StakingKeeper, a.MintKeeper, a.SlashingKeeper, a.BandoracleKeeper, a.AssetKeeper, a.LendKeeper, a.NewliqKeeper, a.NewaucKeeper, a.AuctionKeeper, a.LiquidationKeeper, a.MarketKeeper, a.VaultKeeper),
mv13.CreateUpgradeHandlerV13(a.mm, a.configurator, a.cdc, a.WasmKeeper, a.ParamsKeeper, a.ConsensusParamsKeeper, *a.IbcKeeper, a.ICQKeeper, a.GovKeeper, a.MintKeeper, a.SlashingKeeper, a.BandoracleKeeper, a.AssetKeeper, a.LendKeeper, a.NewliqKeeper, a.NewaucKeeper),
)
// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
Expand Down
167 changes: 0 additions & 167 deletions app/upgrades/mainnet/v13/auctions_migration.go

This file was deleted.

15 changes: 0 additions & 15 deletions app/upgrades/mainnet/v13/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,23 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
assetkeeper "github.com/comdex-official/comdex/x/asset/keeper"
assettypes "github.com/comdex-official/comdex/x/asset/types"
auctionkeeperold "github.com/comdex-official/comdex/x/auction/keeper"
auctionV2keeper "github.com/comdex-official/comdex/x/auctionsV2/keeper"
auctionsV2types "github.com/comdex-official/comdex/x/auctionsV2/types"
bandoraclemodulekeeper "github.com/comdex-official/comdex/x/bandoracle/keeper"
lendkeeper "github.com/comdex-official/comdex/x/lend/keeper"
lendtypes "github.com/comdex-official/comdex/x/lend/types"
liquidationkeeperold "github.com/comdex-official/comdex/x/liquidation/keeper"
liquidationV2keeper "github.com/comdex-official/comdex/x/liquidationsV2/keeper"
liquidationV2types "github.com/comdex-official/comdex/x/liquidationsV2/types"
marketkeeper "github.com/comdex-official/comdex/x/market/keeper"
vaultkeeper "github.com/comdex-official/comdex/x/vault/keeper"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v7/keeper"
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"
Expand All @@ -42,26 +35,19 @@ func CreateUpgradeHandlerV13(
mm *module.Manager,
configurator module.Configurator,
cdc codec.Codec,
capabilityStoreKey *storetypes.KVStoreKey,
capabilityKeeper *capabilitykeeper.Keeper,
wasmKeeper wasmkeeper.Keeper,
paramsKeeper paramskeeper.Keeper,
consensusParamsKeeper consensusparamkeeper.Keeper,
IBCKeeper ibckeeper.Keeper,
icqkeeper *icqkeeper.Keeper,
GovKeeper govkeeper.Keeper,
StakingKeeper stakingkeeper.Keeper,
MintKeeper mintkeeper.Keeper,
SlashingKeeper slashingkeeper.Keeper,
bandoracleKeeper bandoraclemodulekeeper.Keeper,
assetKeeper assetkeeper.Keeper,
lendKeeper lendkeeper.Keeper,
liquidationV2Keeper liquidationV2keeper.Keeper,
auctionV2Keeper auctionV2keeper.Keeper,
auctionKeeperOld auctionkeeperold.Keeper,
liquidationKeeperOld liquidationkeeperold.Keeper,
marketKeeper marketkeeper.Keeper,
vaultKeeper vaultkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Applying main net upgrade - v.13.2.0")
Expand Down Expand Up @@ -152,7 +138,6 @@ func CreateUpgradeHandlerV13(

UpdateLendParams(ctx, lendKeeper, assetKeeper)
InitializeStates(ctx, liquidationV2Keeper, auctionV2Keeper)
MigrateAuctionsHarbor(ctx, assetKeeper, auctionKeeperOld, auctionV2Keeper, liquidationKeeperOld, liquidationV2Keeper, marketKeeper, vaultKeeper)

return vm, err
}
Expand Down
7 changes: 5 additions & 2 deletions x/auctionsV2/keeper/bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, auctionID uint64, bidder s
if bid.Denom != auctionData.DebtToken.Denom {
return bidId, types.ErrorUnknownDebtToken
}
liquidationData, _ := k.LiquidationsV2.GetLockedVault(ctx, auctionData.AppId, auctionData.LockedVaultId)
liquidationData, found := k.LiquidationsV2.GetLockedVault(ctx, auctionData.AppId, auctionData.LockedVaultId)
if !found {
return 0, types.ErrorInGettingLockedVault
}
//Price data of the token from market module
debtToken, _ := k.market.GetTwa(ctx, auctionData.DebtAssetId)
debtPrice := sdk.NewDecFromInt(sdk.NewInt(int64(debtToken.Twa)))
Expand Down Expand Up @@ -163,7 +166,7 @@ func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, auctionID uint64, bidder s
if keeperIncentive.GT(sdk.ZeroInt()) {
liquidationPenalty = liquidationPenalty.Sub(sdk.NewCoin(auctionData.DebtToken.Denom, keeperIncentive))
addr, _ := sdk.AccAddressFromBech32(liquidationData.InternalKeeperAddress)
err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, auctionsV2types.ModuleName, addr, sdk.NewCoins(sdk.NewCoin(auctionData.DebtToken.Denom, keeperIncentive)))
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, auctionsV2types.ModuleName, addr, sdk.NewCoins(sdk.NewCoin(auctionData.DebtToken.Denom, keeperIncentive)))
if err != nil {
return bidId, err
}
Expand Down
1 change: 1 addition & 0 deletions x/auctionsV2/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ var (
ErrorDiscountGreaterThanMaxDiscount = sdkerrors.Register(ModuleName, 713, "Premium discount entered is greater than max discount")
ErrAuctionLookupTableNotFound = sdkerrors.Register(ModuleName, 714, "auctionLookupTable not found")
ErrorUnableToSetNetFees = sdkerrors.Register(ModuleName, 715, "Unable To set net fees collected after auction closed")
ErrorInGettingLockedVault = sdkerrors.Register(ModuleName, 716, "error in bid dutch auction - locked vault not found")
)
2 changes: 1 addition & 1 deletion x/lend/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ func (k Keeper) RemoveFaultyAuctions(ctx sdk.Context) error {
//send debt from reserve to the pool
err := k.bank.SendCoinsFromModuleToModule(ctx, reserveModuleName, cPoolModuleName, sdk.NewCoins(dutchAuction.InflowTokenTargetAmount))
if err != nil {
return err
continue
}
//send collateral to the reserve from auction module outflow_token_current_amount
err = k.bank.SendCoinsFromModuleToModule(ctx, auctiontypes.ModuleName, reserveModuleName, sdk.NewCoins(dutchAuction.OutflowTokenCurrentAmount))
Expand Down

0 comments on commit 4306f81

Please sign in to comment.