diff --git a/x/cdp/keeper/cdp.go b/x/cdp/keeper/cdp.go index b79d7074..a68b0209 100644 --- a/x/cdp/keeper/cdp.go +++ b/x/cdp/keeper/cdp.go @@ -319,7 +319,7 @@ func (k Keeper) GetDebtDenom(ctx sdk.Context) (denom string) { return } -// GetGovDenom returns the denom of debt in the system +// GetGovDenom returns the denom of the governance token func (k Keeper) GetGovDenom(ctx sdk.Context) (denom string) { store := prefix.NewStore(ctx.KVStore(k.key), types.GovDenomKey) bz := store.Get([]byte{}) @@ -406,7 +406,6 @@ func (k Keeper) ValidateDebtLimit(ctx sdk.Context, collateralDenom string, princ // ValidateCollateralizationRatio validate that adding the input principal doesn't put the cdp below the liquidation ratio func (k Keeper) ValidateCollateralizationRatio(ctx sdk.Context, collateral sdk.Coin, principal sdk.Coin, fees sdk.Coin) error { - // collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, collateral, principal, fees, spot) if err != nil { return err diff --git a/x/cdp/keeper/fees.go b/x/cdp/keeper/fees.go index 3e1a5500..e3bec6ff 100644 --- a/x/cdp/keeper/fees.go +++ b/x/cdp/keeper/fees.go @@ -38,7 +38,6 @@ func (k Keeper) UpdateFeesForAllCdps(ctx sdk.Context, collateralDenom string) er return false } - // note - only works if principal length is one dp, found := k.GetDebtParam(ctx, cdp.Principal.Denom) if !found { return false diff --git a/x/cdp/keeper/seize.go b/x/cdp/keeper/seize.go index e67740df..ca8a073f 100644 --- a/x/cdp/keeper/seize.go +++ b/x/cdp/keeper/seize.go @@ -10,11 +10,10 @@ import ( // SeizeCollateral liquidates the collateral in the input cdp. // the following operations are performed: -// 1. updates the fees for the input cdp, -// 2. sends collateral for all deposits from the cdp module to the liquidator module account -// 3. Applies the liquidation penalty and mints the corresponding amount of debt coins in the cdp module -// 4. moves debt coins from the cdp module to the liquidator module account, -// 5. decrements the total amount of principal outstanding for that collateral type +// 1. Collateral for all deposits is sent from the cdp module to the liquidator module account +// 2. The liquidation penalty is applied +// 3. Debt coins are sent from the cdp module to the liquidator module account +// 4. The total amount of principal outstanding for that collateral type is decremented // (this is the equivalent of saying that fees are no longer accumulated by a cdp once it gets liquidated) func (k Keeper) SeizeCollateral(ctx sdk.Context, cdp types.CDP) error { // Calculate the previous collateral ratio @@ -88,11 +87,10 @@ func (k Keeper) LiquidateCdps(ctx sdk.Context, marketID string, denom string, li return nil } -// ApplyLiquidationPenalty multiplies the input debt amount by the liquidation penalty and mints the debt coins in the cdp module account +// ApplyLiquidationPenalty multiplies the input debt amount by the liquidation penalty func (k Keeper) ApplyLiquidationPenalty(ctx sdk.Context, denom string, debt sdk.Int) sdk.Int { penalty := k.getLiquidationPenalty(ctx, denom) - penaltyAmount := sdk.NewDecFromInt(debt).Mul(penalty).RoundInt() - return penaltyAmount + return sdk.NewDecFromInt(debt).Mul(penalty).RoundInt() } func (k Keeper) getModAccountDebt(ctx sdk.Context, accountName string) sdk.Int {