Fix Ineffectual if statements (#568)

* fix exhibits 19,20,28,32 ineffectual if statements

* Apply suggestions from code review

* Apply suggestions from code review

* Update x/cdp/keeper/cdp.go

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
Nick DeLuca 2020-06-09 06:07:58 -05:00 committed by GitHub
parent 547c651c95
commit 44467569af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 25 deletions

View File

@ -116,21 +116,13 @@ func (k Keeper) SetCdpAndCollateralRatioIndex(ctx sdk.Context, cdp types.CDP, ra
// MintDebtCoins mints debt coins in the cdp module account
func (k Keeper) MintDebtCoins(ctx sdk.Context, moduleAccount string, denom string, principalCoins sdk.Coin) error {
debtCoins := sdk.NewCoins(sdk.NewCoin(denom, principalCoins.Amount))
err := k.supplyKeeper.MintCoins(ctx, moduleAccount, debtCoins)
if err != nil {
return err
}
return nil
return k.supplyKeeper.MintCoins(ctx, moduleAccount, debtCoins)
}
// BurnDebtCoins burns debt coins from the cdp module account
func (k Keeper) BurnDebtCoins(ctx sdk.Context, moduleAccount string, denom string, paymentCoins sdk.Coin) error {
debtCoins := sdk.NewCoins(sdk.NewCoin(denom, paymentCoins.Amount))
err := k.supplyKeeper.BurnCoins(ctx, moduleAccount, debtCoins)
if err != nil {
return err
}
return nil
return k.supplyKeeper.BurnCoins(ctx, moduleAccount, debtCoins)
}
// GetCdpID returns the id of the cdp corresponding to a specific owner and collateral denom

View File

@ -47,11 +47,7 @@ func (k Keeper) DepositCollateral(ctx sdk.Context, owner, depositor sdk.AccAddre
cdp.Collateral = cdp.Collateral.Add(collateral)
collateralToDebtRatio := k.CalculateCollateralToDebtRatio(ctx, cdp.Collateral, cdp.Principal.Add(cdp.AccumulatedFees))
err = k.SetCdpAndCollateralRatioIndex(ctx, cdp, collateralToDebtRatio)
if err != nil {
return err
}
return nil
return k.SetCdpAndCollateralRatioIndex(ctx, cdp, collateralToDebtRatio)
}
// WithdrawCollateral removes collateral from a cdp if it does not put the cdp below the liquidation ratio

View File

@ -68,11 +68,7 @@ func (k Keeper) AddPrincipal(ctx sdk.Context, owner sdk.AccAddress, denom string
// set cdp state and indexes in the store
collateralToDebtRatio := k.CalculateCollateralToDebtRatio(ctx, cdp.Collateral, cdp.Principal.Add(cdp.AccumulatedFees))
err = k.SetCdpAndCollateralRatioIndex(ctx, cdp, collateralToDebtRatio)
if err != nil {
return err
}
return nil
return k.SetCdpAndCollateralRatioIndex(ctx, cdp, collateralToDebtRatio)
}
// RepayPrincipal removes debt from the cdp
@ -164,11 +160,7 @@ func (k Keeper) RepayPrincipal(ctx sdk.Context, owner sdk.AccAddress, denom stri
// set cdp state and update indexes
collateralToDebtRatio := k.CalculateCollateralToDebtRatio(ctx, cdp.Collateral, cdp.Principal.Add(cdp.AccumulatedFees))
err = k.SetCdpAndCollateralRatioIndex(ctx, cdp, collateralToDebtRatio)
if err != nil {
return err
}
return nil
return k.SetCdpAndCollateralRatioIndex(ctx, cdp, collateralToDebtRatio)
}
// ValidatePaymentCoins validates that the input coins are valid for repaying debt