diff --git a/x/cdp/simulation/operations/msgs.go b/x/cdp/simulation/operations/msgs.go index 7600d87b..dd1eb506 100644 --- a/x/cdp/simulation/operations/msgs.go +++ b/x/cdp/simulation/operations/msgs.go @@ -122,8 +122,10 @@ func SimulateMsgCdp(ak auth.AccountKeeper, k cdp.Keeper, pfk pricefeed.Keeper) s if shouldDraw(r) { collateralShifted := ShiftDec(sdk.NewDecFromInt(existingCDP.Collateral.AmountOf(randCollateralParam.Denom)), randCollateralParam.ConversionFactor.Neg()) collateralValue := collateralShifted.Mul(priceShifted) + newFeesAccumulated := k.CalculateFees(ctx, existingCDP.Principal, sdk.NewInt(ctx.BlockTime().Unix()-existingCDP.FeesUpdated.Unix()), randCollateralParam.Denom).AmountOf(randDebtParam.Denom) + totalFees := existingCDP.AccumulatedFees.AmountOf(randCollateralParam.Denom).Add(newFeesAccumulated) // given the current collateral value, calculate how much debt we could add while maintaining a valid liquidation ratio - debt := (existingCDP.Principal.Add(existingCDP.AccumulatedFees)).AmountOf(randDebtParam.Denom) + debt := existingCDP.Principal.AmountOf(randDebtParam.Denom).Add(totalFees) maxTotalDebt := collateralValue.Quo(randCollateralParam.LiquidationRatio) maxDebt := maxTotalDebt.Sub(sdk.NewDecFromInt(debt)).TruncateInt() if maxDebt.LTE(sdk.OneInt()) {