Change !GTE to LT (#512)

This commit is contained in:
Denali Marsh 2020-05-15 15:43:52 -07:00 committed by GitHub
parent c28bc03248
commit 00508b61fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,7 +15,7 @@ func (k Keeper) IncrementCurrentAssetSupply(ctx sdk.Context, coin sdk.Coin) erro
} }
// Resulting current supply must be under asset's limit // Resulting current supply must be under asset's limit
if !supply.SupplyLimit.IsGTE(supply.CurrentSupply.Add(coin)) { if supply.SupplyLimit.IsLT(supply.CurrentSupply.Add(coin)) {
return sdkerrors.Wrapf(types.ErrExceedsSupplyLimit, "increase %s, asset supply %s, limit %s", coin, supply.CurrentSupply, supply.SupplyLimit) return sdkerrors.Wrapf(types.ErrExceedsSupplyLimit, "increase %s, asset supply %s, limit %s", coin, supply.CurrentSupply, supply.SupplyLimit)
} }
@ -51,7 +51,7 @@ func (k Keeper) IncrementIncomingAssetSupply(ctx sdk.Context, coin sdk.Coin) err
// Result of (current + incoming + amount) must be under asset's limit // Result of (current + incoming + amount) must be under asset's limit
totalSupply := supply.CurrentSupply.Add(supply.IncomingSupply) totalSupply := supply.CurrentSupply.Add(supply.IncomingSupply)
if !supply.SupplyLimit.IsGTE(totalSupply.Add(coin)) { if supply.SupplyLimit.IsLT(totalSupply.Add(coin)) {
return sdkerrors.Wrapf(types.ErrExceedsSupplyLimit, "increase %s, asset supply %s, limit %s", coin, totalSupply, supply.SupplyLimit) return sdkerrors.Wrapf(types.ErrExceedsSupplyLimit, "increase %s, asset supply %s, limit %s", coin, totalSupply, supply.SupplyLimit)
} }
@ -86,7 +86,7 @@ func (k Keeper) IncrementOutgoingAssetSupply(ctx sdk.Context, coin sdk.Coin) err
} }
// Result of (outgoing + amount) must be less than current supply // Result of (outgoing + amount) must be less than current supply
if !supply.CurrentSupply.IsGTE(supply.OutgoingSupply.Add(coin)) { if supply.CurrentSupply.IsLT(supply.OutgoingSupply.Add(coin)) {
return sdkerrors.Wrapf(types.ErrExceedsAvailableSupply, "swap amount %s, available supply %s", coin, return sdkerrors.Wrapf(types.ErrExceedsAvailableSupply, "swap amount %s, available supply %s", coin,
supply.CurrentSupply.Amount.Sub(supply.OutgoingSupply.Amount)) supply.CurrentSupply.Amount.Sub(supply.OutgoingSupply.Amount))
} }