Skip to content

Commit e47b812

Browse files
committed
chore: if new quote value is zero return original quote value
1 parent e606fe5 commit e47b812

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

types/v1/price.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func (p Price) Sub(v Price) Price {
223223

224224
// UpdateQuoteValue applies a pricing function to compute a new quote value from the base.
225225
func (p Price) UpdateQuoteValue(ctx sdk.Context, fn QuotePriceFunc) (Price, error) {
226-
// If BaseValue is zero, return the original Price without modification
226+
// If BaseValue is zero, return the original Price
227227
if p.BaseValue.IsZero() {
228228
return p, nil
229229
}
@@ -237,6 +237,11 @@ func (p Price) UpdateQuoteValue(ctx sdk.Context, fn QuotePriceFunc) (Price, erro
237237
return Price{}, err
238238
}
239239

240+
// If newQuote is zero, return the original Price
241+
if newQuote.IsZero() {
242+
return p, nil
243+
}
244+
240245
// Return a new Price instance with the updated QuoteValue
241246
return Price{
242247
Denom: p.Denom,

0 commit comments

Comments
 (0)