@@ -201,11 +201,11 @@ func (h *PriceOracleVoteExtHandler) getAllVolumeWeightedPrices() map[string]stri
201201 symbolPrices := types .GetPrices (h .lastPriceSyncTS )
202202 for symbol , prices := range symbolPrices {
203203 if len (prices ) > 0 {
204- sum := math .LegacyNewDec ( 0 )
204+ sum := math .LegacyZeroDec ( )
205205 for _ , p := range prices {
206206 sum = sum .Add (p )
207207 }
208- if avg := sum .QuoInt64 (int64 (len (prices ))); avg .GT (math .LegacyNewDec ( 0 )) {
208+ if avg := sum .QuoInt64 (int64 (len (prices ))); avg .GT (math .LegacyZeroDec ( )) {
209209 avgPrices [symbol ] = avg
210210 }
211211 }
@@ -215,7 +215,12 @@ func (h *PriceOracleVoteExtHandler) getAllVolumeWeightedPrices() map[string]stri
215215
216216 textPrices := make (map [string ]string )
217217 for symbol , price := range avgPrices {
218- textPrices [symbol ] = price .String ()
218+ if price .GT (math .LegacyZeroDec ()) {
219+ textPrices [symbol ] = price .String ()
220+ } else {
221+ h .logger .Error ("Invalid Source Price" , "symbol" , symbol , "price" , price )
222+ }
223+
219224 }
220225
221226 return textPrices
@@ -308,7 +313,9 @@ func (h *PriceOracleVoteExtHandler) PreBlocker(ctx sdk.Context, req *abci.Reques
308313 }
309314
310315 for symbol , price := range prices {
311- h .Keeper .SetPrice (ctx , symbol , price .String ())
316+ if price .GT (math .LegacyZeroDec ()) {
317+ h .Keeper .SetPrice (ctx , symbol , price .String ())
318+ }
312319 }
313320
314321 err = h .Keeper .SetBlockHeaders (ctx , headers )
0 commit comments