diff --git a/x/cdp/abci.go b/x/cdp/abci.go index 603704b7..e74fccb1 100644 --- a/x/cdp/abci.go +++ b/x/cdp/abci.go @@ -18,7 +18,12 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k Keeper) { for _, cp := range params.CollateralParams { - ok := k.UpdatePricefeedStatus(ctx, cp.MarketID) + ok := k.UpdatePricefeedStatus(ctx, cp.SpotMarketID) + if !ok { + continue + } + + ok = k.UpdatePricefeedStatus(ctx, cp.LiquidationMarketID) if !ok { continue } @@ -28,8 +33,7 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k Keeper) { if err != nil { panic(err) } - - err = k.LiquidateCdps(ctx, cp.MarketID, cp.Denom, cp.LiquidationRatio) + err = k.LiquidateCdps(ctx, cp.LiquidationMarketID, cp.Denom, cp.LiquidationRatio) if err != nil { panic(err) } diff --git a/x/cdp/genesis.go b/x/cdp/genesis.go index 9eaae0d3..e9fde144 100644 --- a/x/cdp/genesis.go +++ b/x/cdp/genesis.go @@ -38,13 +38,21 @@ func InitGenesis(ctx sdk.Context, k Keeper, pk types.PricefeedKeeper, sk types.S } for _, col := range gs.Params.CollateralParams { - _, found := collateralMap[col.MarketID] + _, found := collateralMap[col.SpotMarketID] if !found { panic(fmt.Sprintf("%s collateral not found in pricefeed", col.Denom)) } // sets the status of the pricefeed in the store // if pricefeed not active, debt operations are paused - _ = k.UpdatePricefeedStatus(ctx, col.MarketID) + _ = k.UpdatePricefeedStatus(ctx, col.SpotMarketID) + + _, found = collateralMap[col.LiquidationMarketID] + if !found { + panic(fmt.Sprintf("%s collateral not found in pricefeed", col.Denom)) + } + // sets the status of the pricefeed in the store + // if pricefeed not active, debt operations are paused + _ = k.UpdatePricefeedStatus(ctx, col.LiquidationMarketID) } k.SetParams(ctx, gs.Params) diff --git a/x/cdp/integration_test.go b/x/cdp/integration_test.go index b258a3e0..7623ae50 100644 --- a/x/cdp/integration_test.go +++ b/x/cdp/integration_test.go @@ -46,15 +46,16 @@ func NewCDPGenState(asset string, liquidationRatio sdk.Dec) app.GenesisState { SavingsDistributionFrequency: cdp.DefaultSavingsDistributionFrequency, CollateralParams: cdp.CollateralParams{ { - Denom: asset, - LiquidationRatio: liquidationRatio, - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr - LiquidationPenalty: d("0.05"), - AuctionSize: i(1000000000), - Prefix: 0x20, - ConversionFactor: i(6), - MarketID: asset + ":usd", + Denom: asset, + LiquidationRatio: liquidationRatio, + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr + LiquidationPenalty: d("0.05"), + AuctionSize: i(1000000000), + Prefix: 0x20, + ConversionFactor: i(6), + SpotMarketID: asset + ":usd", + LiquidationMarketID: asset + ":usd", }, }, DebtParam: cdp.DebtParam{ @@ -108,26 +109,28 @@ func NewCDPGenStateMulti() app.GenesisState { SavingsDistributionFrequency: cdp.DefaultSavingsDistributionFrequency, CollateralParams: cdp.CollateralParams{ { - Denom: "xrp", - LiquidationRatio: sdk.MustNewDecFromStr("2.0"), - DebtLimit: sdk.NewInt64Coin("usdx", 500000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr - LiquidationPenalty: d("0.05"), - AuctionSize: i(7000000000), - Prefix: 0x20, - MarketID: "xrp:usd", - ConversionFactor: i(6), + Denom: "xrp", + LiquidationRatio: sdk.MustNewDecFromStr("2.0"), + DebtLimit: sdk.NewInt64Coin("usdx", 500000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr + LiquidationPenalty: d("0.05"), + AuctionSize: i(7000000000), + Prefix: 0x20, + SpotMarketID: "xrp:usd", + LiquidationMarketID: "xrp:usd", + ConversionFactor: i(6), }, { - Denom: "btc", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 500000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000000782997609"), // %2.5 apr - LiquidationPenalty: d("0.025"), - AuctionSize: i(10000000), - Prefix: 0x21, - MarketID: "btc:usd", - ConversionFactor: i(8), + Denom: "btc", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 500000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000000782997609"), // %2.5 apr + LiquidationPenalty: d("0.025"), + AuctionSize: i(10000000), + Prefix: 0x21, + SpotMarketID: "btc:usd", + LiquidationMarketID: "btc:usd", + ConversionFactor: i(8), }, }, DebtParam: cdp.DebtParam{ diff --git a/x/cdp/keeper/cdp.go b/x/cdp/keeper/cdp.go index ebd71adf..f808baf7 100644 --- a/x/cdp/keeper/cdp.go +++ b/x/cdp/keeper/cdp.go @@ -1,6 +1,7 @@ package keeper import ( + "errors" "fmt" "sort" @@ -352,7 +353,11 @@ func (k Keeper) ValidateCollateral(ctx sdk.Context, collateral sdk.Coin) error { if !found { return sdkerrors.Wrap(types.ErrCollateralNotSupported, collateral.Denom) } - ok := k.GetMarketStatus(ctx, cp.MarketID) + ok := k.GetMarketStatus(ctx, cp.SpotMarketID) + if !ok { + return sdkerrors.Wrap(types.ErrPricefeedDown, collateral.Denom) + } + ok = k.GetMarketStatus(ctx, cp.LiquidationMarketID) if !ok { return sdkerrors.Wrap(types.ErrPricefeedDown, collateral.Denom) } @@ -404,7 +409,7 @@ func (k Keeper) ValidateDebtLimit(ctx sdk.Context, collateralDenom string, princ // ValidateCollateralizationRatio validate that adding the input principal doesn't put the cdp below the liquidation ratio func (k Keeper) ValidateCollateralizationRatio(ctx sdk.Context, collateral sdk.Coin, principal sdk.Coin, fees sdk.Coin) error { // - collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, collateral, principal, fees) + collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, collateral, principal, fees, spot) if err != nil { return err } @@ -430,7 +435,7 @@ func (k Keeper) CalculateCollateralToDebtRatio(ctx sdk.Context, collateral sdk.C // LoadAugmentedCDP creates a new augmented CDP from an existing CDP func (k Keeper) LoadAugmentedCDP(ctx sdk.Context, cdp types.CDP) types.AugmentedCDP { // calculate collateralization ratio - collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, cdp.Collateral, cdp.Principal, cdp.AccumulatedFees) + collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, cdp.Collateral, cdp.Principal, cdp.AccumulatedFees, liquidation) if err != nil { return types.AugmentedCDP{CDP: cdp} } @@ -451,11 +456,20 @@ func (k Keeper) LoadAugmentedCDP(ctx sdk.Context, cdp types.CDP) types.Augmented } // CalculateCollateralizationRatio returns the collateralization ratio of the input collateral to the input debt plus fees -func (k Keeper) CalculateCollateralizationRatio(ctx sdk.Context, collateral sdk.Coin, principal sdk.Coin, fees sdk.Coin) (sdk.Dec, error) { +func (k Keeper) CalculateCollateralizationRatio(ctx sdk.Context, collateral sdk.Coin, principal sdk.Coin, fees sdk.Coin, pfType pricefeedType) (sdk.Dec, error) { if collateral.IsZero() { return sdk.ZeroDec(), nil } - marketID := k.getMarketID(ctx, collateral.Denom) + var marketID string + switch pfType { + case spot: + marketID = k.getSpotMarketID(ctx, collateral.Denom) + case liquidation: + marketID = k.getliquidationMarketID(ctx, collateral.Denom) + default: + return sdk.Dec{}, pfType.IsValid() + } + price, err := k.pricefeedKeeper.GetCurrentPrice(ctx, marketID) if err != nil { return sdk.Dec{}, err @@ -473,9 +487,18 @@ func (k Keeper) CalculateCollateralizationRatio(ctx sdk.Context, collateral sdk. } // CalculateCollateralizationRatioFromAbsoluteRatio takes a coin's denom and an absolute ratio and returns the respective collateralization ratio -func (k Keeper) CalculateCollateralizationRatioFromAbsoluteRatio(ctx sdk.Context, collateralDenom string, absoluteRatio sdk.Dec) (sdk.Dec, error) { - // get price collateral - marketID := k.getMarketID(ctx, collateralDenom) +func (k Keeper) CalculateCollateralizationRatioFromAbsoluteRatio(ctx sdk.Context, collateralDenom string, absoluteRatio sdk.Dec, pfType pricefeedType) (sdk.Dec, error) { + // get price of collateral + var marketID string + switch pfType { + case spot: + marketID = k.getSpotMarketID(ctx, collateralDenom) + case liquidation: + marketID = k.getliquidationMarketID(ctx, collateralDenom) + default: + return sdk.Dec{}, pfType.IsValid() + } + price, err := k.pricefeedKeeper.GetCurrentPrice(ctx, marketID) if err != nil { return sdk.Dec{}, err @@ -522,3 +545,18 @@ func (k Keeper) convertDebtToBaseUnits(ctx sdk.Context, debt sdk.Coin) (baseUnit dp, _ := k.GetDebtParam(ctx, debt.Denom) return sdk.NewDecFromInt(debt.Amount).Mul(sdk.NewDecFromIntWithPrec(sdk.OneInt(), dp.ConversionFactor.Int64())) } + +type pricefeedType string + +const ( + spot pricefeedType = "spot" + liquidation = "liquidation" +) + +func (pft pricefeedType) IsValid() error { + switch pft { + case spot, liquidation: + return nil + } + return errors.New(fmt.Sprintf("invalid pricefeed type: %s", pft)) +} diff --git a/x/cdp/keeper/cdp_test.go b/x/cdp/keeper/cdp_test.go index e2fddd58..935e226b 100644 --- a/x/cdp/keeper/cdp_test.go +++ b/x/cdp/keeper/cdp_test.go @@ -285,11 +285,11 @@ func (suite *CdpTestSuite) TestCalculateCollateralizationRatio() { suite.keeper.IndexCdpByOwner(suite.ctx, c) cr := suite.keeper.CalculateCollateralToDebtRatio(suite.ctx, c.Collateral, c.Principal) suite.keeper.IndexCdpByCollateralRatio(suite.ctx, c.Collateral.Denom, c.ID, cr) - cr, err = suite.keeper.CalculateCollateralizationRatio(suite.ctx, c.Collateral, c.Principal, c.AccumulatedFees) + cr, err = suite.keeper.CalculateCollateralizationRatio(suite.ctx, c.Collateral, c.Principal, c.AccumulatedFees, "spot") suite.NoError(err) suite.Equal(d("2.5"), cr) c.AccumulatedFees = sdk.NewCoin("usdx", i(10000000)) - cr, err = suite.keeper.CalculateCollateralizationRatio(suite.ctx, c.Collateral, c.Principal, c.AccumulatedFees) + cr, err = suite.keeper.CalculateCollateralizationRatio(suite.ctx, c.Collateral, c.Principal, c.AccumulatedFees, "spot") suite.NoError(err) suite.Equal(d("1.25"), cr) } diff --git a/x/cdp/keeper/deposit.go b/x/cdp/keeper/deposit.go index 20ead918..3b06562a 100644 --- a/x/cdp/keeper/deposit.go +++ b/x/cdp/keeper/deposit.go @@ -72,7 +72,7 @@ func (k Keeper) WithdrawCollateral(ctx sdk.Context, owner, depositor sdk.AccAddr return sdkerrors.Wrapf(types.ErrInvalidWithdrawAmount, "collateral %s, deposit %s", collateral, deposit.Amount) } - collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, cdp.Collateral.Sub(collateral), cdp.Principal, cdp.AccumulatedFees) + collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, cdp.Collateral.Sub(collateral), cdp.Principal, cdp.AccumulatedFees, spot) if err != nil { return err } diff --git a/x/cdp/keeper/integration_test.go b/x/cdp/keeper/integration_test.go index ae3be395..f9e4403f 100644 --- a/x/cdp/keeper/integration_test.go +++ b/x/cdp/keeper/integration_test.go @@ -46,15 +46,16 @@ func NewCDPGenState(asset string, liquidationRatio sdk.Dec) app.GenesisState { SavingsDistributionFrequency: cdp.DefaultSavingsDistributionFrequency, CollateralParams: cdp.CollateralParams{ { - Denom: asset, - LiquidationRatio: liquidationRatio, - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr - LiquidationPenalty: d("0.05"), - AuctionSize: i(100), - Prefix: 0x20, - ConversionFactor: i(6), - MarketID: asset + ":usd", + Denom: asset, + LiquidationRatio: liquidationRatio, + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr + LiquidationPenalty: d("0.05"), + AuctionSize: i(100), + Prefix: 0x20, + ConversionFactor: i(6), + SpotMarketID: asset + ":usd", + LiquidationMarketID: asset + ":usd", }, }, DebtParam: cdp.DebtParam{ @@ -108,26 +109,28 @@ func NewCDPGenStateMulti() app.GenesisState { SavingsDistributionFrequency: cdp.DefaultSavingsDistributionFrequency, CollateralParams: cdp.CollateralParams{ { - Denom: "xrp", - LiquidationRatio: sdk.MustNewDecFromStr("2.0"), - DebtLimit: sdk.NewInt64Coin("usdx", 500000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr - LiquidationPenalty: d("0.05"), - AuctionSize: i(7000000000), - Prefix: 0x20, - MarketID: "xrp:usd", - ConversionFactor: i(6), + Denom: "xrp", + LiquidationRatio: sdk.MustNewDecFromStr("2.0"), + DebtLimit: sdk.NewInt64Coin("usdx", 500000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr + LiquidationPenalty: d("0.05"), + AuctionSize: i(7000000000), + Prefix: 0x20, + SpotMarketID: "xrp:usd", + LiquidationMarketID: "xrp:usd", + ConversionFactor: i(6), }, { - Denom: "btc", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 500000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000000782997609"), // %2.5 apr - LiquidationPenalty: d("0.025"), - AuctionSize: i(10000000), - Prefix: 0x21, - MarketID: "btc:usd", - ConversionFactor: i(8), + Denom: "btc", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 500000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000000782997609"), // %2.5 apr + LiquidationPenalty: d("0.025"), + AuctionSize: i(10000000), + Prefix: 0x21, + SpotMarketID: "btc:usd", + LiquidationMarketID: "btc:usd", + ConversionFactor: i(8), }, }, DebtParam: cdp.DebtParam{ @@ -156,26 +159,28 @@ func NewCDPGenStateHighDebtLimit() app.GenesisState { SavingsDistributionFrequency: cdp.DefaultSavingsDistributionFrequency, CollateralParams: cdp.CollateralParams{ { - Denom: "xrp", - LiquidationRatio: sdk.MustNewDecFromStr("2.0"), - DebtLimit: sdk.NewInt64Coin("usdx", 50000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr - LiquidationPenalty: d("0.05"), - AuctionSize: i(7000000000), - Prefix: 0x20, - MarketID: "xrp:usd", - ConversionFactor: i(6), + Denom: "xrp", + LiquidationRatio: sdk.MustNewDecFromStr("2.0"), + DebtLimit: sdk.NewInt64Coin("usdx", 50000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr + LiquidationPenalty: d("0.05"), + AuctionSize: i(7000000000), + Prefix: 0x20, + SpotMarketID: "xrp:usd", + LiquidationMarketID: "xrp:usd", + ConversionFactor: i(6), }, { - Denom: "btc", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 50000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000000782997609"), // %2.5 apr - LiquidationPenalty: d("0.025"), - AuctionSize: i(10000000), - Prefix: 0x21, - MarketID: "btc:usd", - ConversionFactor: i(8), + Denom: "btc", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 50000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000000782997609"), // %2.5 apr + LiquidationPenalty: d("0.025"), + AuctionSize: i(10000000), + Prefix: 0x21, + SpotMarketID: "btc:usd", + LiquidationMarketID: "btc:usd", + ConversionFactor: i(8), }, }, DebtParam: cdp.DebtParam{ diff --git a/x/cdp/keeper/params.go b/x/cdp/keeper/params.go index 703cd273..4a38be13 100644 --- a/x/cdp/keeper/params.go +++ b/x/cdp/keeper/params.go @@ -62,12 +62,20 @@ func (k Keeper) getDenomFromByte(ctx sdk.Context, db byte) string { panic(fmt.Sprintf("no collateral denom with prefix %b", db)) } -func (k Keeper) getMarketID(ctx sdk.Context, denom string) string { +func (k Keeper) getSpotMarketID(ctx sdk.Context, denom string) string { cp, found := k.GetCollateral(ctx, denom) if !found { panic(fmt.Sprintf("collateral not found: %s", denom)) } - return cp.MarketID + return cp.SpotMarketID +} + +func (k Keeper) getliquidationMarketID(ctx sdk.Context, denom string) string { + cp, found := k.GetCollateral(ctx, denom) + if !found { + panic(fmt.Sprintf("collateral not found: %s", denom)) + } + return cp.LiquidationMarketID } func (k Keeper) getLiquidationRatio(ctx sdk.Context, denom string) sdk.Dec { diff --git a/x/cdp/keeper/querier.go b/x/cdp/keeper/querier.go index edfdf54b..f9f27a9f 100644 --- a/x/cdp/keeper/querier.go +++ b/x/cdp/keeper/querier.go @@ -98,7 +98,7 @@ func queryGetCdpsByRatio(ctx sdk.Context, req abci.RequestQuery, keeper Keeper) return nil, sdkerrors.Wrap(types.ErrCollateralNotSupported, requestParams.CollateralDenom) } - ratio, err := keeper.CalculateCollateralizationRatioFromAbsoluteRatio(ctx, requestParams.CollateralDenom, requestParams.Ratio) + ratio, err := keeper.CalculateCollateralizationRatioFromAbsoluteRatio(ctx, requestParams.CollateralDenom, requestParams.Ratio, "liquidation") if err != nil { return nil, sdkerrors.Wrap(err, "couldn't get collateralization ratio from absolute ratio") } diff --git a/x/cdp/keeper/querier_test.go b/x/cdp/keeper/querier_test.go index 343b1d0e..ba224001 100644 --- a/x/cdp/keeper/querier_test.go +++ b/x/cdp/keeper/querier_test.go @@ -183,7 +183,7 @@ func (suite *QuerierTestSuite) TestQueryCdpsByRatio() { expectedBtcIds := []int{} for _, cdp := range suite.cdps { absoluteRatio := suite.keeper.CalculateCollateralToDebtRatio(suite.ctx, cdp.Collateral, cdp.Principal) - collateralizationRatio, err := suite.keeper.CalculateCollateralizationRatioFromAbsoluteRatio(suite.ctx, cdp.Collateral.Denom, absoluteRatio) + collateralizationRatio, err := suite.keeper.CalculateCollateralizationRatioFromAbsoluteRatio(suite.ctx, cdp.Collateral.Denom, absoluteRatio, "liquidation") suite.Nil(err) if cdp.Collateral.Denom == "xrp" { if collateralizationRatio.LT(xrpRatio) { diff --git a/x/cdp/simulation/genesis.go b/x/cdp/simulation/genesis.go index e0f4591d..4c465346 100644 --- a/x/cdp/simulation/genesis.go +++ b/x/cdp/simulation/genesis.go @@ -76,37 +76,40 @@ func randomCdpGenState(selection int) types.GenesisState { SavingsDistributionFrequency: types.DefaultSavingsDistributionFrequency, CollateralParams: types.CollateralParams{ { - Denom: "xrp", - LiquidationRatio: sdk.MustNewDecFromStr("2.0"), - DebtLimit: sdk.NewInt64Coin("usdx", 20000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000004431822130"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.075"), - AuctionSize: sdk.NewInt(100000000000), - Prefix: 0x20, - MarketID: "xrp:usd", - ConversionFactor: sdk.NewInt(6), + Denom: "xrp", + LiquidationRatio: sdk.MustNewDecFromStr("2.0"), + DebtLimit: sdk.NewInt64Coin("usdx", 20000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000004431822130"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.075"), + AuctionSize: sdk.NewInt(100000000000), + Prefix: 0x20, + SpotMarketID: "xrp:usd", + LiquidationMarketID: "xrp:usd", + ConversionFactor: sdk.NewInt(6), }, { - Denom: "btc", - LiquidationRatio: sdk.MustNewDecFromStr("1.25"), - DebtLimit: sdk.NewInt64Coin("usdx", 50000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000000782997609"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(1000000000), - Prefix: 0x21, - MarketID: "btc:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "btc", + LiquidationRatio: sdk.MustNewDecFromStr("1.25"), + DebtLimit: sdk.NewInt64Coin("usdx", 50000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000000782997609"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(1000000000), + Prefix: 0x21, + SpotMarketID: "btc:usd", + LiquidationMarketID: "btc:usd", + ConversionFactor: sdk.NewInt(8), }, { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 30000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000002293273137"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.15"), - AuctionSize: sdk.NewInt(1000000000000), - Prefix: 0x22, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 30000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000002293273137"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.15"), + AuctionSize: sdk.NewInt(1000000000000), + Prefix: 0x22, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, DebtParam: types.DebtParam{ @@ -132,15 +135,16 @@ func randomCdpGenState(selection int) types.GenesisState { SavingsDistributionFrequency: types.DefaultSavingsDistributionFrequency, CollateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 100000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000002293273137"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.075"), - AuctionSize: sdk.NewInt(10000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 100000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000002293273137"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.075"), + AuctionSize: sdk.NewInt(10000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, DebtParam: types.DebtParam{ diff --git a/x/cdp/simulation/operations.go b/x/cdp/simulation/operations.go index 3fedccba..47eef7e3 100644 --- a/x/cdp/simulation/operations.go +++ b/x/cdp/simulation/operations.go @@ -64,7 +64,7 @@ func SimulateMsgCdp(ak types.AccountKeeper, k keeper.Keeper, pfk types.Pricefeed return simulation.NoOpMsg(types.ModuleName), nil, nil } - price, err := pfk.GetCurrentPrice(ctx, randCollateralParam.MarketID) + price, err := pfk.GetCurrentPrice(ctx, randCollateralParam.SpotMarketID) if err != nil { return simulation.NoOpMsg(types.ModuleName), nil, err } diff --git a/x/cdp/spec/01_concepts.md b/x/cdp/spec/01_concepts.md index 26805251..b7a51006 100644 --- a/x/cdp/spec/01_concepts.md +++ b/x/cdp/spec/01_concepts.md @@ -32,7 +32,7 @@ Module interactions: In the event of a decrease in the price of the collateral, the total value of all collateral in CDPs may drop below the value of all the issued stable assets. This undesirable event is countered through two mechanisms: -**CDP Liquidations** The ratio of collateral value to debt value in each CDP is monitored. When this drops too low the collateral and debt is automatically seized by the system. The collateral is sold off through an auction to bring in stable asset which is burned against the seized debt. +**CDP Liquidations** The ratio of collateral value to debt value in each CDP is monitored. When this drops too low the collateral and debt is automatically seized by the system. The collateral is sold off through an auction to bring in stable asset which is burned against the seized debt. The price used to determine liquidation is controlled by the `LiquidationMarketID` parameter, which can be the same as the `SpotMarketID` or use a different calculation of price, such as a time-weighted average. **Debt Auctions** In extreme cases where liquidations fail to raise enough to cover the seized debt, another mechanism kicks in: Debt Auctions. System governance tokens are minted and sold through auction to raise enough stable asset to cover the remaining debt. The governors of the system represent the lenders of last resort. diff --git a/x/cdp/spec/06_params.md b/x/cdp/spec/06_params.md index 9b250af2..8065aed5 100644 --- a/x/cdp/spec/06_params.md +++ b/x/cdp/spec/06_params.md @@ -12,15 +12,16 @@ The cdp module contains the following parameters: Each CollateralParam has the following parameters: -| Key | Type | Example | Description | -|------------------|---------------|---------------------------------------------|----------------------------------------------------------------------------------------------------------------| -| Denom | string | "bnb" | collateral coin denom | -| LiquidationRatio | string (dec) | "1.500000000000000000" | the ratio under which a cdp with this collateral type will be liquidated | -| DebtLimit | coin | {"denom":"bnb","amount":"1000000000000"} | maximum pegged asset that can be minted backed by this collateral type | -| StabilityFee | string (dec) | "1.000000001547126" | per second fee | -| Prefix | number (byte) | 34 | identifier used in store keys - **must** be unique across collateral types | -| MarketID | string | "bnb:usd" | price feed identifier for this collateral type | -| ConversionFactor | string (int) | "6" | 10^_ multiplier to go from external amount (say BTC1.50) to internal representation of that amount (150000000) | +| Key | Type | Example | Description | +|---------------------| |---------------|---------------------------------------------|----------------------------------------------------------------------------------------------------------------| +| Denom | string | "bnb" | collateral coin denom | +| LiquidationRatio | string (dec) | "1.500000000000000000" | the ratio under which a cdp with this collateral type will be liquidated | +| DebtLimit | coin | {"denom":"bnb","amount":"1000000000000"} | maximum pegged asset that can be minted backed by this collateral type | +| StabilityFee | string (dec) | "1.000000001547126" | per second fee | +| Prefix | number (byte) | 34 | identifier used in store keys - **must** be unique across collateral types | +| SpotMarketID | string | "bnb:usd" | price feed identifier for the spot price of this collateral type | +| LiquidationMarketID | string | "bnb:usd:30" | price feed identifier for the liquidation price of this collateral type | +| ConversionFactor | string (int) | "6" | 10^_ multiplier to go from external amount (say BTC1.50) to internal representation of that amount (150000000) | DebtParam has the following parameters: diff --git a/x/cdp/types/params.go b/x/cdp/types/params.go index 02bf75cb..561d99bb 100644 --- a/x/cdp/types/params.go +++ b/x/cdp/types/params.go @@ -89,15 +89,16 @@ func DefaultParams() Params { // CollateralParam governance parameters for each collateral type within the cdp module type CollateralParam struct { - Denom string `json:"denom" yaml:"denom"` // Coin name of collateral type - LiquidationRatio sdk.Dec `json:"liquidation_ratio" yaml:"liquidation_ratio"` // The ratio (Collateral (priced in stable coin) / Debt) under which a CDP will be liquidated - DebtLimit sdk.Coin `json:"debt_limit" yaml:"debt_limit"` // Maximum amount of debt allowed to be drawn from this collateral type - StabilityFee sdk.Dec `json:"stability_fee" yaml:"stability_fee"` // per second stability fee for loans opened using this collateral - AuctionSize sdk.Int `json:"auction_size" yaml:"auction_size"` // Max amount of collateral to sell off in any one auction. - LiquidationPenalty sdk.Dec `json:"liquidation_penalty" yaml:"liquidation_penalty"` // percentage penalty (between [0, 1]) applied to a cdp if it is liquidated - Prefix byte `json:"prefix" yaml:"prefix"` - MarketID string `json:"market_id" yaml:"market_id"` // marketID for fetching price of the asset from the pricefeed - ConversionFactor sdk.Int `json:"conversion_factor" yaml:"conversion_factor"` // factor for converting internal units to one base unit of collateral + Denom string `json:"denom" yaml:"denom"` // Coin name of collateral type + LiquidationRatio sdk.Dec `json:"liquidation_ratio" yaml:"liquidation_ratio"` // The ratio (Collateral (priced in stable coin) / Debt) under which a CDP will be liquidated + DebtLimit sdk.Coin `json:"debt_limit" yaml:"debt_limit"` // Maximum amount of debt allowed to be drawn from this collateral type + StabilityFee sdk.Dec `json:"stability_fee" yaml:"stability_fee"` // per second stability fee for loans opened using this collateral + AuctionSize sdk.Int `json:"auction_size" yaml:"auction_size"` // Max amount of collateral to sell off in any one auction. + LiquidationPenalty sdk.Dec `json:"liquidation_penalty" yaml:"liquidation_penalty"` // percentage penalty (between [0, 1]) applied to a cdp if it is liquidated + Prefix byte `json:"prefix" yaml:"prefix"` + SpotMarketID string `json:"spot_market_id" yaml:"spot_market_id"` // marketID of the spot price of the asset from the pricefeed - used for opening CDPs, depositing, withdrawing + LiquidationMarketID string `json:"liquidation_market_id" yaml:"liquidation_market_id` // marketID of the pricefeed used for liquidation + ConversionFactor sdk.Int `json:"conversion_factor" yaml:"conversion_factor"` // factor for converting internal units to one base unit of collateral } // String implements fmt.Stringer @@ -110,9 +111,10 @@ func (cp CollateralParam) String() string { Debt Limit: %s Auction Size: %s Prefix: %b - Market ID: %s + Spot Market ID: %s + Liquidation Market ID: %s Conversion Factor: %s`, - cp.Denom, cp.LiquidationRatio, cp.StabilityFee, cp.LiquidationPenalty, cp.DebtLimit, cp.AuctionSize, cp.Prefix, cp.MarketID, cp.ConversionFactor) + cp.Denom, cp.LiquidationRatio, cp.StabilityFee, cp.LiquidationPenalty, cp.DebtLimit, cp.AuctionSize, cp.Prefix, cp.SpotMarketID, cp.LiquidationMarketID, cp.ConversionFactor) } // CollateralParams array of CollateralParam @@ -276,8 +278,12 @@ func validateCollateralParams(i interface{}) error { return fmt.Errorf("collateral denom invalid %s", cp.Denom) } - if strings.TrimSpace(cp.MarketID) == "" { - return fmt.Errorf("market id cannot be blank %s", cp) + if strings.TrimSpace(cp.SpotMarketID) == "" { + return fmt.Errorf("spot market id cannot be blank %s", cp) + } + + if strings.TrimSpace(cp.LiquidationMarketID) == "" { + return fmt.Errorf("liquidation market id cannot be blank %s", cp) } prefix := int(cp.Prefix) diff --git a/x/cdp/types/params_test.go b/x/cdp/types/params_test.go index 5bba5871..810b1cf0 100644 --- a/x/cdp/types/params_test.go +++ b/x/cdp/types/params_test.go @@ -61,15 +61,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 4000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -95,15 +96,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 4000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -129,15 +131,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -163,26 +166,28 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 4000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, { - Denom: "xrp", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x21, - MarketID: "xrp:usd", - ConversionFactor: sdk.NewInt(6), + Denom: "xrp", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x21, + SpotMarketID: "xrp:usd", + LiquidationMarketID: "xrp:usd", + ConversionFactor: sdk.NewInt(6), }, }, debtParam: types.DebtParam{ @@ -208,26 +213,28 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, { - Denom: "xrp", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x21, - MarketID: "xrp:usd", - ConversionFactor: sdk.NewInt(6), + Denom: "xrp", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x21, + SpotMarketID: "xrp:usd", + LiquidationMarketID: "xrp:usd", + ConversionFactor: sdk.NewInt(6), }, }, debtParam: types.DebtParam{ @@ -253,26 +260,28 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 4000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, { - Denom: "xrp", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("susd", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x21, - MarketID: "xrp:usd", - ConversionFactor: sdk.NewInt(6), + Denom: "xrp", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("susd", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x21, + SpotMarketID: "xrp:usd", + LiquidationMarketID: "xrp:usd", + ConversionFactor: sdk.NewInt(6), }, }, debtParam: types.DebtParam{ @@ -298,15 +307,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -332,15 +342,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "", + LiquidationMarketID: "", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -366,26 +377,28 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x21, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x21, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -411,26 +424,28 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, { - Denom: "xrp", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "xrp:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "xrp", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "xrp:usd", + LiquidationMarketID: "xrp:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -456,15 +471,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.Coin{}, - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.Coin{}, + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -490,15 +506,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("1.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("1.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -524,15 +541,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.ZeroInt(), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.ZeroInt(), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -558,15 +576,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.1"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.1"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -592,15 +611,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ @@ -626,15 +646,16 @@ func (suite *ParamsTestSuite) TestParamValidation() { globalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), collateralParams: types.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("1.5"), - DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), - LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), - AuctionSize: sdk.NewInt(50000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: sdk.NewInt(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("1.5"), + DebtLimit: sdk.NewInt64Coin("usdx", 2000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), + LiquidationPenalty: sdk.MustNewDecFromStr("0.05"), + AuctionSize: sdk.NewInt(50000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: sdk.NewInt(8), }, }, debtParam: types.DebtParam{ diff --git a/x/committee/keeper/param_permission_test.go b/x/committee/keeper/param_permission_test.go index 726b2727..213028bd 100644 --- a/x/committee/keeper/param_permission_test.go +++ b/x/committee/keeper/param_permission_test.go @@ -31,26 +31,28 @@ func (suite *PermissionTestSuite) TestSubParamChangePermission_Allows() { // cdp CollateralParams testCPs := cdptypes.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: d("2.0"), - DebtLimit: c("usdx", 1000000000000), - StabilityFee: d("1.000000001547125958"), - LiquidationPenalty: d("0.05"), - AuctionSize: i(100), - Prefix: 0x20, - ConversionFactor: i(6), - MarketID: "bnb:usd", + Denom: "bnb", + LiquidationRatio: d("2.0"), + DebtLimit: c("usdx", 1000000000000), + StabilityFee: d("1.000000001547125958"), + LiquidationPenalty: d("0.05"), + AuctionSize: i(100), + Prefix: 0x20, + ConversionFactor: i(6), + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", }, { - Denom: "btc", - LiquidationRatio: d("1.5"), - DebtLimit: c("usdx", 1000000000), - StabilityFee: d("1.000000001547125958"), - LiquidationPenalty: d("0.10"), - AuctionSize: i(1000), - Prefix: 0x30, - ConversionFactor: i(8), - MarketID: "btc:usd", + Denom: "btc", + LiquidationRatio: d("1.5"), + DebtLimit: c("usdx", 1000000000), + StabilityFee: d("1.000000001547125958"), + LiquidationPenalty: d("0.10"), + AuctionSize: i(1000), + Prefix: 0x30, + ConversionFactor: i(8), + SpotMarketID: "btc:usd", + LiquidationMarketID: "btc:usd", }, } testCPUpdatedDebtLimit := make(cdptypes.CollateralParams, len(testCPs)) diff --git a/x/committee/keeper/proposal_test.go b/x/committee/keeper/proposal_test.go index 9a3d5b67..20c1b480 100644 --- a/x/committee/keeper/proposal_test.go +++ b/x/committee/keeper/proposal_test.go @@ -86,15 +86,16 @@ func (suite *KeeperTestSuite) TestSubmitProposal() { } testCP := cdptypes.CollateralParams{{ - Denom: "bnb", - LiquidationRatio: d("1.5"), - DebtLimit: c("usdx", 1000000000000), - StabilityFee: d("1.000000001547125958"), // %5 apr - LiquidationPenalty: d("0.05"), - AuctionSize: i(100), - Prefix: 0x20, - ConversionFactor: i(6), - MarketID: "bnb:usd", + Denom: "bnb", + LiquidationRatio: d("1.5"), + DebtLimit: c("usdx", 1000000000000), + StabilityFee: d("1.000000001547125958"), // %5 apr + LiquidationPenalty: d("0.05"), + AuctionSize: i(100), + Prefix: 0x20, + ConversionFactor: i(6), + LiquidationMarketID: "bnb:usd", + SpotMarketID: "bnb:usd", }} testCDPParams := cdptypes.DefaultParams() testCDPParams.CollateralParams = testCP @@ -106,7 +107,7 @@ func (suite *KeeperTestSuite) TestSubmitProposal() { newInvalidCP := make(cdptypes.CollateralParams, len(testCP)) copy(newInvalidCP, testCP) - newInvalidCP[0].MarketID = "btc:usd" + newInvalidCP[0].SpotMarketID = "btc:usd" testcases := []struct { name string diff --git a/x/committee/types/param_permissions_test.go b/x/committee/types/param_permissions_test.go index 07d8aa2d..961bedca 100644 --- a/x/committee/types/param_permissions_test.go +++ b/x/committee/types/param_permissions_test.go @@ -16,37 +16,40 @@ func cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) } func (suite *PermissionsTestSuite) TestAllowedCollateralParams_Allows() { testCPs := cdptypes.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: d("2.0"), - DebtLimit: c("usdx", 1000000000000), - StabilityFee: d("1.000000001547125958"), - LiquidationPenalty: d("0.05"), - AuctionSize: i(100), - Prefix: 0x20, - ConversionFactor: i(6), - MarketID: "bnb:usd", + Denom: "bnb", + LiquidationRatio: d("2.0"), + DebtLimit: c("usdx", 1000000000000), + StabilityFee: d("1.000000001547125958"), + LiquidationPenalty: d("0.05"), + AuctionSize: i(100), + Prefix: 0x20, + ConversionFactor: i(6), + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", }, { - Denom: "btc", - LiquidationRatio: d("1.5"), - DebtLimit: c("usdx", 1000000000), - StabilityFee: d("1.000000001547125958"), - LiquidationPenalty: d("0.10"), - AuctionSize: i(1000), - Prefix: 0x30, - ConversionFactor: i(8), - MarketID: "btc:usd", + Denom: "btc", + LiquidationRatio: d("1.5"), + DebtLimit: c("usdx", 1000000000), + StabilityFee: d("1.000000001547125958"), + LiquidationPenalty: d("0.10"), + AuctionSize: i(1000), + Prefix: 0x30, + ConversionFactor: i(8), + SpotMarketID: "btc:usd", + LiquidationMarketID: "btc:usd", }, { - Denom: "atom", - LiquidationRatio: d("2.0"), - DebtLimit: c("usdx", 1000000000), - StabilityFee: d("1.000000001547125958"), - LiquidationPenalty: d("0.07"), - AuctionSize: i(100), - Prefix: 0x40, - ConversionFactor: i(6), - MarketID: "atom:usd", + Denom: "atom", + LiquidationRatio: d("2.0"), + DebtLimit: c("usdx", 1000000000), + StabilityFee: d("1.000000001547125958"), + LiquidationPenalty: d("0.07"), + AuctionSize: i(100), + Prefix: 0x40, + ConversionFactor: i(6), + SpotMarketID: "atom:usd", + LiquidationMarketID: "atom:usd", }, } updatedTestCPs := make(cdptypes.CollateralParams, len(testCPs)) @@ -78,15 +81,16 @@ func (suite *PermissionsTestSuite) TestAllowedCollateralParams_Allows() { StabilityFee: true, }, { // allow all fields - Denom: "atom", - LiquidationRatio: true, - DebtLimit: true, - StabilityFee: true, - AuctionSize: true, - LiquidationPenalty: true, - Prefix: true, - MarketID: true, - ConversionFactor: true, + Denom: "atom", + LiquidationRatio: true, + DebtLimit: true, + StabilityFee: true, + AuctionSize: true, + LiquidationPenalty: true, + Prefix: true, + SpotMarketID: true, + LiquidationMarketID: true, + ConversionFactor: true, }, }, current: testCPs[:2], @@ -102,15 +106,16 @@ func (suite *PermissionsTestSuite) TestAllowedCollateralParams_Allows() { }, { // allow all fields - Denom: "btc", - LiquidationRatio: true, - DebtLimit: true, - StabilityFee: true, - AuctionSize: true, - LiquidationPenalty: true, - Prefix: true, - MarketID: true, - ConversionFactor: true, + Denom: "btc", + LiquidationRatio: true, + DebtLimit: true, + StabilityFee: true, + AuctionSize: true, + LiquidationPenalty: true, + Prefix: true, + SpotMarketID: true, + LiquidationMarketID: true, + ConversionFactor: true, }, }, current: testCPs[:2], @@ -376,24 +381,25 @@ func (suite *PermissionsTestSuite) TestAllowedMarkets_Allows() { func (suite *PermissionsTestSuite) TestAllowedCollateralParam_Allows() { testCP := cdptypes.CollateralParam{ - Denom: "bnb", - LiquidationRatio: d("1.5"), - DebtLimit: c("usdx", 1000000000000), - StabilityFee: d("1.000000001547125958"), // %5 apr - LiquidationPenalty: d("0.05"), - AuctionSize: i(100), - Prefix: 0x20, - ConversionFactor: i(6), - MarketID: "bnb:usd", + Denom: "bnb", + LiquidationRatio: d("1.5"), + DebtLimit: c("usdx", 1000000000000), + StabilityFee: d("1.000000001547125958"), // %5 apr + LiquidationPenalty: d("0.05"), + AuctionSize: i(100), + Prefix: 0x20, + ConversionFactor: i(6), + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", } newMarketIDCP := testCP - newMarketIDCP.MarketID = "btc:usd" + newMarketIDCP.SpotMarketID = "btc:usd" newDebtLimitCP := testCP newDebtLimitCP.DebtLimit = c("usdx", 1000) newMarketIDAndDebtLimitCP := testCP - newMarketIDCP.MarketID = "btc:usd" + newMarketIDCP.SpotMarketID = "btc:usd" newDebtLimitCP.DebtLimit = c("usdx", 1000) testcases := []struct { diff --git a/x/committee/types/permissions.go b/x/committee/types/permissions.go index 38491c11..13b3f369 100644 --- a/x/committee/types/permissions.go +++ b/x/committee/types/permissions.go @@ -372,15 +372,16 @@ func (acps AllowedCollateralParams) Allows(current, incoming cdptypes.Collateral } type AllowedCollateralParam struct { - Denom string `json:"denom" yaml:"denom"` - LiquidationRatio bool `json:"liquidation_ratio" yaml:"liquidation_ratio"` - DebtLimit bool `json:"debt_limit" yaml:"debt_limit"` - StabilityFee bool `json:"stability_fee" yaml:"stability_fee"` - AuctionSize bool `json:"auction_size" yaml:"auction_size"` - LiquidationPenalty bool `json:"liquidation_penalty" yaml:"liquidation_penalty"` - Prefix bool `json:"prefix" yaml:"prefix"` - MarketID bool `json:"market_id" yaml:"market_id"` - ConversionFactor bool `json:"conversion_factor" yaml:"conversion_factor"` + Denom string `json:"denom" yaml:"denom"` + LiquidationRatio bool `json:"liquidation_ratio" yaml:"liquidation_ratio"` + DebtLimit bool `json:"debt_limit" yaml:"debt_limit"` + StabilityFee bool `json:"stability_fee" yaml:"stability_fee"` + AuctionSize bool `json:"auction_size" yaml:"auction_size"` + LiquidationPenalty bool `json:"liquidation_penalty" yaml:"liquidation_penalty"` + Prefix bool `json:"prefix" yaml:"prefix"` + SpotMarketID bool `json:"spot_market_id" yaml:"spot_market_id"` + LiquidationMarketID bool `json:"liquidation_market_id" yaml:"liquidation_market_id"` + ConversionFactor bool `json:"conversion_factor" yaml:"conversion_factor"` } func (acp AllowedCollateralParam) Allows(current, incoming cdptypes.CollateralParam) bool { @@ -391,7 +392,8 @@ func (acp AllowedCollateralParam) Allows(current, incoming cdptypes.CollateralPa (current.AuctionSize.Equal(incoming.AuctionSize) || acp.AuctionSize) && (current.LiquidationPenalty.Equal(incoming.LiquidationPenalty) || acp.LiquidationPenalty) && ((current.Prefix == incoming.Prefix) || acp.Prefix) && - ((current.MarketID == incoming.MarketID) || acp.MarketID) && + ((current.SpotMarketID == incoming.SpotMarketID) || acp.SpotMarketID) && + ((current.LiquidationMarketID == incoming.LiquidationMarketID) || acp.LiquidationMarketID) && (current.ConversionFactor.Equal(incoming.ConversionFactor) || acp.ConversionFactor) return allowed } diff --git a/x/incentive/keeper/rewards_test.go b/x/incentive/keeper/rewards_test.go index be2951a7..1d9afe94 100644 --- a/x/incentive/keeper/rewards_test.go +++ b/x/incentive/keeper/rewards_test.go @@ -183,15 +183,16 @@ func (suite *KeeperTestSuite) setupCdpChain() { SavingsDistributionFrequency: cdp.DefaultSavingsDistributionFrequency, CollateralParams: cdp.CollateralParams{ { - Denom: "bnb", - LiquidationRatio: sdk.MustNewDecFromStr("2.0"), - DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), - StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr - LiquidationPenalty: d("0.05"), - AuctionSize: i(10000000000), - Prefix: 0x20, - MarketID: "bnb:usd", - ConversionFactor: i(8), + Denom: "bnb", + LiquidationRatio: sdk.MustNewDecFromStr("2.0"), + DebtLimit: sdk.NewInt64Coin("usdx", 1000000000000), + StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr + LiquidationPenalty: d("0.05"), + AuctionSize: i(10000000000), + Prefix: 0x20, + SpotMarketID: "bnb:usd", + LiquidationMarketID: "bnb:usd", + ConversionFactor: i(8), }, }, DebtParam: cdp.DebtParam{