Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dev #592

Merged
merged 18 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 20 additions & 47 deletions app/upgrades/mainnet/v5/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@ func InitializeStates(
rewardsKeeper rewardskeeper.Keeper,
liquidationKeeper liquidationkeeper.Keeper,
) {
genesisToken := assettypes.MintGenesisToken{
AssetId: 9,
GenesisSupply: sdk.NewIntFromUint64(500000000000000),
IsGovToken: true,
Recipient: "comdex1663kc7kwlqxg5s35wuq4nleuqvy5j2tstlkeg2",
}
var gToken []assettypes.MintGenesisToken
gToken = append(gToken, genesisToken)

apps := []assettypes.AppData{
{Name: "cswap", ShortName: "cswap", MinGovDeposit: sdk.ZeroInt(), GovTimeInSeconds: 0, GenesisToken: []assettypes.MintGenesisToken{}},
{Name: "harbor", ShortName: "hbr", MinGovDeposit: sdk.NewInt(10000000), GovTimeInSeconds: 300, GenesisToken: []assettypes.MintGenesisToken{}},
{Name: "harbor", ShortName: "hbr", MinGovDeposit: sdk.NewInt(10000000000), GovTimeInSeconds: 259200, GenesisToken: gToken},
}
for _, app := range apps {
err := assetKeeper.AddAppRecords(ctx, app)
Expand All @@ -60,6 +69,7 @@ func InitializeStates(
{Name: "CCMST", Denom: "uccmst", Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: false, IsCdpMintable: true},
{Name: "COSMO", Denom: "ucosmo", Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: false, IsCdpMintable: true},
{Name: "HARBOR", Denom: "uharbor", Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: false, IsCdpMintable: false},
{Name: "AXLUSDC", Denom: "uusdc", Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: true, IsCdpMintable: false},
}

for _, asset := range assets {
Expand All @@ -73,6 +83,7 @@ func InitializeStates(
{AssetIn: 1, AssetOut: 3},
{AssetIn: 2, AssetOut: 3},
{AssetIn: 4, AssetOut: 3},
{AssetIn: 10, AssetOut: 3},
}

for _, pair := range pairs {
Expand All @@ -85,49 +96,9 @@ func InitializeStates(
// add extended pairs
extPairs := []*bindings.MsgAddExtendedPairsVault{
{
AppID: 2, PairID: 2, StabilityFee: sdk.MustNewDecFromStr("0.045"), ClosingFee: sdk.MustNewDecFromStr("0.005"), LiquidationPenalty: sdk.MustNewDecFromStr("0.15"),
DrawDownFee: sdk.MustNewDecFromStr("0.005"), IsVaultActive: true, DebtCeiling: sdk.NewInt(100000000000000), DebtFloor: sdk.NewInt(100000000), IsStableMintVault: false, MinCr: sdk.MustNewDecFromStr("2.0"),
PairName: "CMDX-A", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
},
{
AppID: 2, PairID: 2, StabilityFee: sdk.MustNewDecFromStr("0.035"), ClosingFee: sdk.MustNewDecFromStr("0.005"), LiquidationPenalty: sdk.MustNewDecFromStr("0.15"),
DrawDownFee: sdk.MustNewDecFromStr("0.005"), IsVaultActive: true, DebtCeiling: sdk.NewInt(100000000000000), DebtFloor: sdk.NewInt(100000000), IsStableMintVault: false, MinCr: sdk.MustNewDecFromStr("2.4"),
PairName: "CMDX-B", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
},
{
AppID: 2, PairID: 2, StabilityFee: sdk.MustNewDecFromStr("0.025"), ClosingFee: sdk.MustNewDecFromStr("0.005"), LiquidationPenalty: sdk.MustNewDecFromStr("0.15"),
DrawDownFee: sdk.MustNewDecFromStr("0.005"), IsVaultActive: true, DebtCeiling: sdk.NewInt(100000000000000), DebtFloor: sdk.NewInt(100000000), IsStableMintVault: false, MinCr: sdk.MustNewDecFromStr("2.8"),
PairName: "CMDX-C", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
},
{
AppID: 2, PairID: 3, StabilityFee: sdk.MustNewDecFromStr("0.045"), ClosingFee: sdk.MustNewDecFromStr("0.005"), LiquidationPenalty: sdk.MustNewDecFromStr("0.15"),
DrawDownFee: sdk.MustNewDecFromStr("0.005"), IsVaultActive: true, DebtCeiling: sdk.NewInt(100000000000000), DebtFloor: sdk.NewInt(100000000), IsStableMintVault: false, MinCr: sdk.MustNewDecFromStr("1.6"),
PairName: "OSMO-A", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
},
{
AppID: 2, PairID: 3, StabilityFee: sdk.MustNewDecFromStr("0.035"), ClosingFee: sdk.MustNewDecFromStr("0.005"), LiquidationPenalty: sdk.MustNewDecFromStr("0.15"),
DrawDownFee: sdk.MustNewDecFromStr("0.005"), IsVaultActive: true, DebtCeiling: sdk.NewInt(100000000000000), DebtFloor: sdk.NewInt(100000000), IsStableMintVault: false, MinCr: sdk.MustNewDecFromStr("1.9"),
PairName: "OSMO-B", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
},
{
AppID: 2, PairID: 3, StabilityFee: sdk.MustNewDecFromStr("0.025"), ClosingFee: sdk.MustNewDecFromStr("0.005"), LiquidationPenalty: sdk.MustNewDecFromStr("0.15"),
DrawDownFee: sdk.MustNewDecFromStr("0.005"), IsVaultActive: true, DebtCeiling: sdk.NewInt(100000000000000), DebtFloor: sdk.NewInt(100000000), IsStableMintVault: false, MinCr: sdk.MustNewDecFromStr("2.2"),
PairName: "OSMO-C", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
},
{
AppID: 2, PairID: 1, StabilityFee: sdk.MustNewDecFromStr("0.045"), ClosingFee: sdk.MustNewDecFromStr("0.005"), LiquidationPenalty: sdk.MustNewDecFromStr("0.15"),
DrawDownFee: sdk.MustNewDecFromStr("0.005"), IsVaultActive: true, DebtCeiling: sdk.NewInt(100000000000000), DebtFloor: sdk.NewInt(100000000), IsStableMintVault: false, MinCr: sdk.MustNewDecFromStr("1.4"),
PairName: "ATOM-A", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
},
{
AppID: 2, PairID: 1, StabilityFee: sdk.MustNewDecFromStr("0.035"), ClosingFee: sdk.MustNewDecFromStr("0.005"), LiquidationPenalty: sdk.MustNewDecFromStr("0.15"),
DrawDownFee: sdk.MustNewDecFromStr("0.005"), IsVaultActive: true, DebtCeiling: sdk.NewInt(100000000000000), DebtFloor: sdk.NewInt(100000000), IsStableMintVault: false, MinCr: sdk.MustNewDecFromStr("1.7"),
PairName: "ATOM-B", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
},
{
AppID: 2, PairID: 1, StabilityFee: sdk.MustNewDecFromStr("0.025"), ClosingFee: sdk.MustNewDecFromStr("0.005"), LiquidationPenalty: sdk.MustNewDecFromStr("0.15"),
DrawDownFee: sdk.MustNewDecFromStr("0.005"), IsVaultActive: true, DebtCeiling: sdk.NewInt(100000000000000), DebtFloor: sdk.NewInt(100000000), IsStableMintVault: false, MinCr: sdk.MustNewDecFromStr("2.0"),
PairName: "ATOM-C", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
AppID: 2, PairID: 4, StabilityFee: sdk.ZeroDec(), ClosingFee: sdk.ZeroDec(), LiquidationPenalty: sdk.ZeroDec(),
DrawDownFee: sdk.MustNewDecFromStr("0.001"), IsVaultActive: true, DebtCeiling: sdk.NewInt(40000000000000), DebtFloor: sdk.NewInt(1000000), IsStableMintVault: true, MinCr: sdk.MustNewDecFromStr("1"),
PairName: "AXL-USDC-CMST", AssetOutOraclePrice: false, AssetOutPrice: 1000000, MinUsdValueLeft: 10000000000,
},
}

Expand All @@ -145,7 +116,7 @@ func InitializeStates(
SurplusThreshold: sdk.NewInt(50000000000),
DebtThreshold: sdk.NewInt(0),
LockerSavingRate: sdk.MustNewDecFromStr("0.00"),
LotSize: sdk.NewInt(10000),
LotSize: sdk.NewInt(10000000000),
BidFactor: sdk.MustNewDecFromStr("0.01"),
DebtLotSize: sdk.NewInt(1000000000000),
}
Expand Down Expand Up @@ -230,8 +201,10 @@ func InitializeStates(
}

liquidityPairs := []LiquidityPair{
{AppID: 1, From: "comdex12gfx7e3p08ljrwhq4lxz0360czcv9jpzajlytv", BaseCoinDenom: "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9", QuoteCoinDenom: "ucmdx"},
{AppID: 1, From: "comdex12gfx7e3p08ljrwhq4lxz0360czcv9jpzajlytv", BaseCoinDenom: "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518", QuoteCoinDenom: "ucmdx"},
{AppID: 1, From: "comdex12gfx7e3p08ljrwhq4lxz0360czcv9jpzajlytv", BaseCoinDenom: "ucmdx", QuoteCoinDenom: "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9"},
{AppID: 1, From: "comdex12gfx7e3p08ljrwhq4lxz0360czcv9jpzajlytv", BaseCoinDenom: "ucmdx", QuoteCoinDenom: "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518"},
{AppID: 1, From: "comdex12gfx7e3p08ljrwhq4lxz0360czcv9jpzajlytv", BaseCoinDenom: "ucmdx", QuoteCoinDenom: "ucmst"},
{AppID: 1, From: "comdex12gfx7e3p08ljrwhq4lxz0360czcv9jpzajlytv", BaseCoinDenom: "ucmdx", QuoteCoinDenom: "uharbor"},
}

for _, lpair := range liquidityPairs {
Expand Down
17 changes: 15 additions & 2 deletions proto/comdex/liquidation/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ option go_package = "github.com/comdex-official/comdex/x/liquidation/types";
option (gogoproto.equal_all) = false;
option (gogoproto.goproto_getters_all) = false;

service Msg {
}
message MsgLiquidateVaultRequest {
string from = 1 [ (gogoproto.moretags) = "yaml:\"from\"" ];
uint64 app_id = 2 [
(gogoproto.customname) = "AppId",
(gogoproto.moretags) = "yaml:\"app_id\""];

uint64 vault_id = 3 [
(gogoproto.customname) = "VaultId",
(gogoproto.moretags) = "yaml:\"vault_id\""];
}
message MsgLiquidateVaultResponse{}

service Msg {
rpc MsgLiquidateVault(MsgLiquidateVaultRequest) returns (MsgLiquidateVaultResponse);
}

4 changes: 2 additions & 2 deletions scripts/comdex_local_setup/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,8 @@
"app_id": 1,
"target_value": {"amount": "200", "denom": "uharbor"},
"cool_off_period": 7200,
"asset_id": [4,13],
"rates": [1000000,1000000],
"asset_id": [4,3,13],
"rates": [1000000,1000000,1000000],
}
}
],
Expand Down
5 changes: 3 additions & 2 deletions x/asset/keeper/app.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
protobuftypes "github.com/gogo/protobuf/types"
"regexp"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
protobuftypes "github.com/gogo/protobuf/types"

"github.com/comdex-official/comdex/x/asset/types"
)

Expand Down
44 changes: 44 additions & 0 deletions x/auction/abci.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package auction

import (
"fmt"

"github.com/comdex-official/comdex/x/auction/expected"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -25,6 +27,21 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, assetKeeper expected.AssetKe
_ = utils.ApplyFuncIfNoError(ctx, func(ctx sdk.Context) error {
err1 := k.SurplusActivator(ctx, data, killSwitchParams, status)
if err1 != nil {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeSurplusActivatorErr,
sdk.NewAttribute(types.DataAppID, fmt.Sprintf("%d", data.AppId)),
sdk.NewAttribute(types.DataAssetID, fmt.Sprintf("%d", data.AssetId)),
sdk.NewAttribute(types.DataAssetOutOraclePrice, fmt.Sprintf("%t", data.AssetOutOraclePrice)),
sdk.NewAttribute(types.DataAssetOutPrice, fmt.Sprintf("%d", data.AssetOutPrice)),
sdk.NewAttribute(types.DatIsAuctionActive, fmt.Sprintf("%t", data.IsAuctionActive)),
sdk.NewAttribute(types.DataIsDebtAuction, fmt.Sprintf("%t", data.IsDebtAuction)),
sdk.NewAttribute(types.DataIsDistributor, fmt.Sprintf("%t", data.IsDistributor)),
sdk.NewAttribute(types.DataIsSurplusAuction, fmt.Sprintf("%t", data.IsSurplusAuction)),
sdk.NewAttribute(types.KillSwitchParamsBreakerEnabled, fmt.Sprintf("%t", killSwitchParams.BreakerEnable)),
sdk.NewAttribute(types.Status, fmt.Sprintf("%t", status)),
),
)
ctx.Logger().Error("error in surplus activator")
return err1
}
Expand All @@ -33,6 +50,21 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, assetKeeper expected.AssetKe
_ = utils.ApplyFuncIfNoError(ctx, func(ctx sdk.Context) error {
err2 := k.DebtActivator(ctx, data, killSwitchParams, status)
if err2 != nil {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeDebtActivatorErr,
sdk.NewAttribute(types.DataAppID, fmt.Sprintf("%d", data.AppId)),
sdk.NewAttribute(types.DataAssetID, fmt.Sprintf("%d", data.AssetId)),
sdk.NewAttribute(types.DataAssetOutOraclePrice, fmt.Sprintf("%t", data.AssetOutOraclePrice)),
sdk.NewAttribute(types.DataAssetOutPrice, fmt.Sprintf("%d", data.AssetOutPrice)),
sdk.NewAttribute(types.DatIsAuctionActive, fmt.Sprintf("%t", data.IsAuctionActive)),
sdk.NewAttribute(types.DataIsDebtAuction, fmt.Sprintf("%t", data.IsDebtAuction)),
sdk.NewAttribute(types.DataIsDistributor, fmt.Sprintf("%t", data.IsDistributor)),
sdk.NewAttribute(types.DataIsSurplusAuction, fmt.Sprintf("%t", data.IsSurplusAuction)),
sdk.NewAttribute(types.KillSwitchParamsBreakerEnabled, fmt.Sprintf("%t", killSwitchParams.BreakerEnable)),
sdk.NewAttribute(types.Status, fmt.Sprintf("%t", status)),
),
)
ctx.Logger().Error("error in debt activator")
return err2
}
Expand All @@ -47,11 +79,23 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, assetKeeper expected.AssetKe
for _, app := range apps {
err4 := k.RestartDutch(ctx, app.Id)
if err4 != nil {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeRestartDutchErr,
sdk.NewAttribute(types.DataAppID, fmt.Sprintf("%d", app.Id)),
),
)
ctx.Logger().Error("error in restart dutch activator")
}

err6 := k.RestartLendDutch(ctx, app.Id)
if err6 != nil {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeRestartLendDutchErr,
sdk.NewAttribute(types.DataAppID, fmt.Sprintf("%d", app.Id)),
),
)
ctx.Logger().Error("error in restart lend dutch activator")
}
}
Expand Down
4 changes: 2 additions & 2 deletions x/auction/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, state *types.GenesisState) {
k.SetGenLendDutchLendAuction(ctx, item)
lendAuctionID = item.AuctionId
}
k.SetLendAuctionID(ctx,lendAuctionID)
k.SetLendAuctionID(ctx, lendAuctionID)
}

func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
Expand All @@ -50,7 +50,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
k.GetAllDutchAuctions(ctx),
k.GetAllProtocolStat(ctx),
k.GetAllAuctionParams(ctx),
k.GetDutchLendAuctions(ctx,3),
k.GetDutchLendAuctions(ctx, 3),
k.GetParams(ctx),
k.GetUserBiddingID(ctx),
)
Expand Down
20 changes: 17 additions & 3 deletions x/auction/keeper/dutch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"fmt"
"strconv"
"time"

liquidationtypes "github.com/comdex-official/comdex/x/liquidation/types"
Expand Down Expand Up @@ -144,6 +145,18 @@ func (k Keeper) StartDutchAuction(
return err
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
auctiontypes.EventTypeDutchNewAuction,
sdk.NewAttribute(auctiontypes.DataAppID, strconv.FormatUint(auction.AppId, 10)),
sdk.NewAttribute(auctiontypes.AttributeKeyOwner, auction.VaultOwner.String()),
sdk.NewAttribute(auctiontypes.AttributeKeyCollateral, auction.OutflowTokenInitAmount.String()),
sdk.NewAttribute(auctiontypes.AttributeKeyDebt, auction.InflowTokenTargetAmount.String()),
sdk.NewAttribute(auctiontypes.AttributeKeyStartTime, auction.StartTime.String()),
sdk.NewAttribute(auctiontypes.AttributeKeyEndTime, auction.EndTime.String()),
),
)

return nil
}

Expand Down Expand Up @@ -510,7 +523,8 @@ func (k Keeper) RestartDutchAuctions(ctx sdk.Context, appID uint64) error {
// if exists append in existing
// close auction func call
inflowLeft := dutchAuction.InflowTokenTargetAmount.Amount.Sub(dutchAuction.InflowTokenCurrentAmount.Amount)
vaultID, userExists := k.vault.GetUserAppExtendedPairMappingData(ctx, string(dutchAuction.VaultOwner), dutchAuction.AppId, lockedVault.ExtendedPairId)
penaltyAmt := dutchAuction.InflowTokenTargetAmount.Amount.Sub(lockedVault.AmountOut)
vaultID, userExists := k.vault.GetUserAppExtendedPairMappingData(ctx, dutchAuction.VaultOwner.String(), dutchAuction.AppId, lockedVault.ExtendedPairId)
if userExists {
vaultData, _ := k.vault.GetVault(ctx, vaultID.VaultId)
if dutchAuction.OutflowTokenCurrentAmount.Amount.GT(sdk.ZeroInt()) {
Expand All @@ -521,7 +535,7 @@ func (k Keeper) RestartDutchAuctions(ctx sdk.Context, appID uint64) error {
}
// append to existing vault
vaultData.AmountIn = vaultData.AmountIn.Add(dutchAuction.OutflowTokenCurrentAmount.Amount)
vaultData.AmountOut = vaultData.AmountOut.Add(inflowLeft)
vaultData.AmountOut = vaultData.AmountOut.Add(inflowLeft).Sub(penaltyAmt)
k.vault.SetVault(ctx, vaultData)
} else {
if dutchAuction.OutflowTokenCurrentAmount.Amount.GT(sdk.ZeroInt()) {
Expand All @@ -531,7 +545,7 @@ func (k Keeper) RestartDutchAuctions(ctx sdk.Context, appID uint64) error {
}
}
// create new vault done
err := k.vault.CreateNewVault(ctx, dutchAuction.VaultOwner.String(), lockedVault.AppId, lockedVault.ExtendedPairId, dutchAuction.OutflowTokenCurrentAmount.Amount, inflowLeft)
err := k.vault.CreateNewVault(ctx, dutchAuction.VaultOwner.String(), lockedVault.AppId, lockedVault.ExtendedPairId, dutchAuction.OutflowTokenCurrentAmount.Amount, inflowLeft.Sub(penaltyAmt))
if err != nil {
return err
}
Expand Down
24 changes: 24 additions & 0 deletions x/auction/types/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package types

const (
EventTypeSurplusActivatorErr = "surplus_activator_err"
EventTypeDebtActivatorErr = "debt_activator_err"
EventTypeRestartDutchErr = "restart_dutch_err"
EventTypeRestartLendDutchErr = "restart_lend_dutch_err"
EventTypeDutchNewAuction = "dutch_new_auction"
AttributeKeyOwner = "vault_owner"
AttributeKeyCollateral = "collateral_token"
AttributeKeyDebt = "debt_token"
AttributeKeyStartTime = "start_time"
AttributeKeyEndTime = "end_time"
DataAppID = "data_app_id"
DataAssetID = "data_asset_id"
DataAssetOutOraclePrice = "data_asset_out_oracle_price"
DataAssetOutPrice = "data_asset_out_price"
DatIsAuctionActive = "data_is_auction_active"
DataIsDebtAuction = "data_is_debt_auction"
DataIsDistributor = "data_is_distributor"
DataIsSurplusAuction = "data_is_surplus_auction"
KillSwitchParamsBreakerEnabled = "data_is_surplus_auction"
Status = "status"
)
12 changes: 6 additions & 6 deletions x/bandoracle/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) {
req := k.GetTempFetchPriceID(ctx)
res := k.OraclePriceValidationByRequestID(ctx, req)
discardData := k.GetDiscardData(ctx)
//By default discard height -1 - set while adding band proposal
//addd new parameter in kvv store to save the accepted discard height
//one more bool value to save the result of the operation---bydefault false
// By default discard height -1 - set while adding band proposal
// addd new parameter in kvv store to save the accepted discard height
// one more bool value to save the result of the operation---bydefault false
if !res && discardData.BlockHeight < 0 {
discardData.BlockHeight = ctx.BlockHeight()
} else if res && discardData.BlockHeight > 0 {
if (ctx.BlockHeight() - discardData.BlockHeight) < msg.AcceptedHeightDiff {
//No issues
// No issues
discardData.BlockHeight = -1
} else if (ctx.BlockHeight() - discardData.BlockHeight) >= msg.AcceptedHeightDiff {
discardData.DiscardBool = true
Expand All @@ -57,5 +57,5 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) {
}
}

//if discardBool true------> setCounter to 0 , price to false ----should be a if condition at the top----> at the end of condition set Discard Bool to false
//if discardBool false-------> nothing to do.
// if discardBool true------> setCounter to 0 , price to false ----should be a if condition at the top----> at the end of condition set Discard Bool to false
// if discardBool false-------> nothing to do.
4 changes: 2 additions & 2 deletions x/esm/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper, as
continue
}
if found && esmStatus.Status {
//Should check if price exists in the band or not. else should skip---- k.market.isPriceValidationActive
//to add this check at all abci as well where price is important
// Should check if price exists in the band or not. else should skip---- k.market.isPriceValidationActive
// to add this check at all abci as well where price is important
if !esmStatus.SnapshotStatus {
err := k.SnapshotOfPrices(ctx, esmStatus)
if err != nil {
Expand Down
Loading