mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 23:35:19 +00:00
Fix misleading comments from audit (#592)
* fix misleading or incorrect comments * fix unnecessary variable declaration * fix punctuation
This commit is contained in:
parent
dda84c79ab
commit
e913dc2ff0
@ -319,7 +319,7 @@ func (k Keeper) GetDebtDenom(ctx sdk.Context) (denom string) {
|
|||||||
return
|
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) {
|
func (k Keeper) GetGovDenom(ctx sdk.Context) (denom string) {
|
||||||
store := prefix.NewStore(ctx.KVStore(k.key), types.GovDenomKey)
|
store := prefix.NewStore(ctx.KVStore(k.key), types.GovDenomKey)
|
||||||
bz := store.Get([]byte{})
|
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
|
// 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 {
|
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)
|
collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, collateral, principal, fees, spot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -38,7 +38,6 @@ func (k Keeper) UpdateFeesForAllCdps(ctx sdk.Context, collateralDenom string) er
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// note - only works if principal length is one
|
|
||||||
dp, found := k.GetDebtParam(ctx, cdp.Principal.Denom)
|
dp, found := k.GetDebtParam(ctx, cdp.Principal.Denom)
|
||||||
if !found {
|
if !found {
|
||||||
return false
|
return false
|
||||||
|
@ -10,11 +10,10 @@ import (
|
|||||||
|
|
||||||
// SeizeCollateral liquidates the collateral in the input cdp.
|
// SeizeCollateral liquidates the collateral in the input cdp.
|
||||||
// the following operations are performed:
|
// the following operations are performed:
|
||||||
// 1. updates the fees for the input cdp,
|
// 1. Collateral for all deposits is sent from the cdp module to the liquidator module account
|
||||||
// 2. sends collateral for all deposits from the cdp module to the liquidator module account
|
// 2. The liquidation penalty is applied
|
||||||
// 3. Applies the liquidation penalty and mints the corresponding amount of debt coins in the cdp module
|
// 3. Debt coins are sent from the cdp module to the liquidator module account
|
||||||
// 4. moves debt coins from the cdp module to the liquidator module account,
|
// 4. The total amount of principal outstanding for that collateral type is decremented
|
||||||
// 5. decrements the total amount of principal outstanding for that collateral type
|
|
||||||
// (this is the equivalent of saying that fees are no longer accumulated by a cdp once it gets liquidated)
|
// (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 {
|
func (k Keeper) SeizeCollateral(ctx sdk.Context, cdp types.CDP) error {
|
||||||
// Calculate the previous collateral ratio
|
// Calculate the previous collateral ratio
|
||||||
@ -88,11 +87,10 @@ func (k Keeper) LiquidateCdps(ctx sdk.Context, marketID string, denom string, li
|
|||||||
return nil
|
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 {
|
func (k Keeper) ApplyLiquidationPenalty(ctx sdk.Context, denom string, debt sdk.Int) sdk.Int {
|
||||||
penalty := k.getLiquidationPenalty(ctx, denom)
|
penalty := k.getLiquidationPenalty(ctx, denom)
|
||||||
penaltyAmount := sdk.NewDecFromInt(debt).Mul(penalty).RoundInt()
|
return sdk.NewDecFromInt(debt).Mul(penalty).RoundInt()
|
||||||
return penaltyAmount
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) getModAccountDebt(ctx sdk.Context, accountName string) sdk.Int {
|
func (k Keeper) getModAccountDebt(ctx sdk.Context, accountName string) sdk.Int {
|
||||||
|
Loading…
Reference in New Issue
Block a user