diff --git a/x/bep3/simulation/operations.go b/x/bep3/simulation/operations.go index 681512a9..254dacf7 100644 --- a/x/bep3/simulation/operations.go +++ b/x/bep3/simulation/operations.go @@ -158,7 +158,7 @@ func SimulateMsgCreateAtomicSwap(ak types.AccountKeeper, k keeper.Keeper) simula // Get an amount of coins between 0.1 and 2% of total coins amount := maximumAmount.Quo(sdk.NewInt(int64(simulation.RandIntBetween(r, 50, 1000)))) minAmountPlusFee := asset.MinSwapAmount.Add(asset.FixedFee) - if amount.LT(minAmountPlusFee) { + if amount.LTE(minAmountPlusFee) { return simulation.NewOperationMsgBasic(types.ModuleName, fmt.Sprintf("no-operation (account funds exhausted for asset %s)", asset.Denom), "", false, nil), nil, nil } coins := sdk.NewCoins(sdk.NewCoin(asset.Denom, amount)) diff --git a/x/cdp/simulation/operations.go b/x/cdp/simulation/operations.go index 38d71a86..947f6c0f 100644 --- a/x/cdp/simulation/operations.go +++ b/x/cdp/simulation/operations.go @@ -137,6 +137,10 @@ func SimulateMsgCdp(ak types.AccountKeeper, k keeper.Keeper, pfk types.Pricefeed // close 25% of the time if canClose(spendableCoins, existingCDP, debtParam.Denom) && shouldClose(r) { repaymentAmount := spendableCoins.AmountOf(debtParam.Denom) + // check that repayment isn't below the debt floor + if existingCDP.Principal.Amount.Add(existingCDP.AccumulatedFees.Amount).Sub(repaymentAmount).LT(debtParam.DebtFloor) { + repaymentAmount = existingCDP.Principal.Amount.Add(existingCDP.AccumulatedFees.Amount).Sub(debtParam.DebtFloor) + } msg := types.NewMsgRepayDebt(acc.GetAddress(), randCollateralParam.Type, sdk.NewCoin(debtParam.Denom, repaymentAmount)) tx := helpers.GenTx( @@ -225,7 +229,7 @@ func SimulateMsgCdp(ak types.AccountKeeper, k keeper.Keeper, pfk types.Pricefeed // repay debt 25% of the time if hasCoins(spendableCoins, debtParam.Denom) { - debt := existingCDP.Principal.Amount + debt := existingCDP.Principal.Amount.Add(existingCDP.AccumulatedFees.Amount) payableDebt := debt.Sub(debtParam.DebtFloor) if payableDebt.IsZero() { return simulation.NewOperationMsgBasic(types.ModuleName, "no-operation", "cannot make partial repayment, cdp at debt floor", false, nil), nil, nil