mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-13 03:25:20 +00:00
add stability fee validation (#307)
This commit is contained in:
parent
2d9820b3d1
commit
c5043ffabe
@ -162,6 +162,7 @@ func (p *Params) ParamSetPairs() params.ParamSetPairs {
|
|||||||
|
|
||||||
// Validate checks that the parameters have valid values.
|
// Validate checks that the parameters have valid values.
|
||||||
func (p Params) Validate() error {
|
func (p Params) Validate() error {
|
||||||
|
// validate debt params
|
||||||
debtDenoms := make(map[string]int)
|
debtDenoms := make(map[string]int)
|
||||||
debtParamsDebtLimit := sdk.Coins{}
|
debtParamsDebtLimit := sdk.Coins{}
|
||||||
for _, dp := range p.DebtParams {
|
for _, dp := range p.DebtParams {
|
||||||
@ -184,6 +185,7 @@ func (p Params) Validate() error {
|
|||||||
p.GlobalDebtLimit, debtParamsDebtLimit)
|
p.GlobalDebtLimit, debtParamsDebtLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate collateral params
|
||||||
collateralDupMap := make(map[string]int)
|
collateralDupMap := make(map[string]int)
|
||||||
prefixDupMap := make(map[int]int)
|
prefixDupMap := make(map[int]int)
|
||||||
collateralParamsDebtLimit := sdk.Coins{}
|
collateralParamsDebtLimit := sdk.Coins{}
|
||||||
@ -226,16 +228,19 @@ func (p Params) Validate() error {
|
|||||||
if !cp.AuctionSize.IsPositive() {
|
if !cp.AuctionSize.IsPositive() {
|
||||||
return fmt.Errorf("auction size should be positive, is %s for %s", cp.AuctionSize, cp.Denom)
|
return fmt.Errorf("auction size should be positive, is %s for %s", cp.AuctionSize, cp.Denom)
|
||||||
}
|
}
|
||||||
|
if cp.StabilityFee.LT(sdk.OneDec()) {
|
||||||
|
return fmt.Errorf("stability fee must be ≥ 1.0, is %s for %s", cp.StabilityFee, cp.Denom)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if collateralParamsDebtLimit.IsAnyGT(p.GlobalDebtLimit) {
|
if collateralParamsDebtLimit.IsAnyGT(p.GlobalDebtLimit) {
|
||||||
return fmt.Errorf("collateral debt limit exceeds global debt limit:\n\tglobal debt limit: %s\n\tcollateral debt limits: %s",
|
return fmt.Errorf("collateral debt limit exceeds global debt limit:\n\tglobal debt limit: %s\n\tcollateral debt limits: %s",
|
||||||
p.GlobalDebtLimit, collateralParamsDebtLimit)
|
p.GlobalDebtLimit, collateralParamsDebtLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate global params
|
||||||
if p.GlobalDebtLimit.IsAnyNegative() {
|
if p.GlobalDebtLimit.IsAnyNegative() {
|
||||||
return fmt.Errorf("global debt limit should be positive for all debt tokens, is %s", p.GlobalDebtLimit)
|
return fmt.Errorf("global debt limit should be positive for all debt tokens, is %s", p.GlobalDebtLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !p.SurplusAuctionThreshold.IsPositive() {
|
if !p.SurplusAuctionThreshold.IsPositive() {
|
||||||
return fmt.Errorf("surplus auction threshold should be positive, is %s", p.SurplusAuctionThreshold)
|
return fmt.Errorf("surplus auction threshold should be positive, is %s", p.SurplusAuctionThreshold)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user