From d887266c249ecf694641164603bb89df4a6a3599 Mon Sep 17 00:00:00 2001 From: Ruaridh Date: Mon, 20 Jan 2020 19:28:30 +0000 Subject: [PATCH] Run begin blocker (#321) * add cdp begin blocker * fix: use reasonable defaults for surplus/debt auctions Co-authored-by: Kevin Davis --- app/app.go | 4 ++-- x/cdp/keeper/auctions_test.go | 12 ++++++------ x/cdp/types/params.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/app.go b/app/app.go index 70ea5031..839391ac 100644 --- a/app/app.go +++ b/app/app.go @@ -270,9 +270,9 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, // During begin block slashing happens after distr.BeginBlocker so that // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. - app.mm.SetOrderBeginBlockers(mint.ModuleName, distr.ModuleName, slashing.ModuleName, validatorvesting.ModuleName) + app.mm.SetOrderBeginBlockers(mint.ModuleName, distr.ModuleName, slashing.ModuleName, validatorvesting.ModuleName, cdp.ModuleName) - app.mm.SetOrderEndBlockers(crisis.ModuleName, gov.ModuleName, staking.ModuleName, pricefeed.ModuleName, auction.ModuleName) // TODO is this correct order? + app.mm.SetOrderEndBlockers(crisis.ModuleName, gov.ModuleName, staking.ModuleName, pricefeed.ModuleName, auction.ModuleName) // Note: genutils must occur after staking so that pools are properly // initialized with tokens from genesis accounts. diff --git a/x/cdp/keeper/auctions_test.go b/x/cdp/keeper/auctions_test.go index bfa6b94a..59cb45fa 100644 --- a/x/cdp/keeper/auctions_test.go +++ b/x/cdp/keeper/auctions_test.go @@ -51,24 +51,24 @@ func (suite *AuctionTestSuite) TestNetDebtSurplus() { func (suite *AuctionTestSuite) TestSurplusAuction() { sk := suite.app.GetSupplyKeeper() - err := sk.MintCoins(suite.ctx, types.LiquidatorMacc, cs(c("usdx", 10000))) + err := sk.MintCoins(suite.ctx, types.LiquidatorMacc, cs(c("usdx", 10000000000))) suite.NoError(err) - err = sk.MintCoins(suite.ctx, types.LiquidatorMacc, cs(c("debt", 1000))) + err = sk.MintCoins(suite.ctx, types.LiquidatorMacc, cs(c("debt", 1000000000))) suite.NoError(err) suite.keeper.RunSurplusAndDebtAuctions(suite.ctx) acc := sk.GetModuleAccount(suite.ctx, auction.ModuleName) - suite.Equal(cs(c("usdx", 9000)), acc.GetCoins()) + suite.Equal(cs(c("usdx", 9000000000)), acc.GetCoins()) } func (suite *AuctionTestSuite) TestDebtAuction() { sk := suite.app.GetSupplyKeeper() - err := sk.MintCoins(suite.ctx, types.LiquidatorMacc, cs(c("usdx", 1000))) + err := sk.MintCoins(suite.ctx, types.LiquidatorMacc, cs(c("usdx", 1000000000))) suite.NoError(err) - err = sk.MintCoins(suite.ctx, types.LiquidatorMacc, cs(c("debt", 10000))) + err = sk.MintCoins(suite.ctx, types.LiquidatorMacc, cs(c("debt", 10000000000))) suite.NoError(err) suite.keeper.RunSurplusAndDebtAuctions(suite.ctx) acc := sk.GetModuleAccount(suite.ctx, auction.ModuleName) - suite.Equal(cs(c("debt", 9000)), acc.GetCoins()) + suite.Equal(cs(c("debt", 9000000000)), acc.GetCoins()) } func TestAuctionTestSuite(t *testing.T) { diff --git a/x/cdp/types/params.go b/x/cdp/types/params.go index 5fb33325..2d8c78d4 100644 --- a/x/cdp/types/params.go +++ b/x/cdp/types/params.go @@ -24,8 +24,8 @@ var ( DefaultCdpStartingID = uint64(1) DefaultDebtDenom = "debt" DefaultGovDenom = "ukava" - DefaultSurplusThreshold = sdk.NewInt(1000) - DefaultDebtThreshold = sdk.NewInt(1000) + DefaultSurplusThreshold = sdk.NewInt(1000000000) + DefaultDebtThreshold = sdk.NewInt(1000000000) DefaultPreviousBlockTime = tmtime.Canonical(time.Unix(0, 0)) minCollateralPrefix = 0 maxCollateralPrefix = 255