mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 06:17:27 +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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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 {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user