Remove some redunancy in RepayPrinciple (#577)

* fix exhibit 30 - remove redunant conversions in adding principle to fee
amount, and store debt denom in local var to avoid calling getter
several times

* add deleted comment back
This commit is contained in:
Nick DeLuca 2020-06-11 14:32:39 -05:00 committed by GitHub
parent 5ba2706d56
commit 25abdd10b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,12 +106,17 @@ func (k Keeper) RepayPrincipal(ctx sdk.Context, owner sdk.AccAddress, denom stri
// burn the corresponding amount of debt coins
cdpDebt := k.getModAccountDebt(ctx, types.ModuleName)
paymentAmount := feePayment.Amount.Add(principalPayment.Amount)
coinsToBurn := sdk.NewCoin(k.GetDebtDenom(ctx), paymentAmount)
paymentAmount := feePayment.Add(principalPayment).Amount
debtDenom := k.GetDebtDenom(ctx)
coinsToBurn := sdk.NewCoin(debtDenom, paymentAmount)
if paymentAmount.GT(cdpDebt) {
coinsToBurn = sdk.NewCoin(k.GetDebtDenom(ctx), cdpDebt)
coinsToBurn = sdk.NewCoin(debtDenom, cdpDebt)
}
err = k.BurnDebtCoins(ctx, types.ModuleName, k.GetDebtDenom(ctx), coinsToBurn)
err = k.BurnDebtCoins(ctx, types.ModuleName, debtDenom, coinsToBurn)
if err != nil {
panic(err)
}