diff --git a/price-feeder/oracle/oracle.go b/price-feeder/oracle/oracle.go index f58217ab74..1b09744399 100644 --- a/price-feeder/oracle/oracle.go +++ b/price-feeder/oracle/oracle.go @@ -234,25 +234,6 @@ func (o *Oracle) SetPrices(ctx context.Context, acceptList oracletypes.DenomList o.logger.Debug().Err(err).Msg("failed to get ticker prices from provider") } - reportedRates := make(map[string]struct{}) - for _, providers := range providerPrices { - for base := range providers { - if _, ok := reportedRates[base]; !ok { - reportedRates[base] = struct{}{} - } - } - } - - // warn the user of any missing prices - if len(reportedRates) != len(requiredRates) { - return fmt.Errorf("unable to get prices for all exchange rates") - } - for base := range requiredRates { - if _, ok := reportedRates[base]; !ok { - return fmt.Errorf("reported rates were not equal to required rates") - } - } - filteredCandles, err := o.filterCandleDeviations(providerCandles) if err != nil { return err @@ -277,8 +258,46 @@ func (o *Oracle) SetPrices(ctx context.Context, acceptList oracletypes.DenomList return err } + // warn the user of any missing prices + reportedPrices := make(map[string]struct{}) + for _, providers := range filteredProviderPrices { + for base := range providers { + if _, ok := reportedPrices[base]; !ok { + reportedPrices[base] = struct{}{} + } + } + } + + if len(reportedPrices) != len(requiredRates) { + return fmt.Errorf("unable to get prices for all exchange prices") + } + for base := range requiredRates { + if _, ok := reportedPrices[base]; !ok { + return fmt.Errorf("reported prices were not equal to required rates") + } + } + o.prices = vwapPrices } else { + // warn the user of any missing candles + reportedCandles := make(map[string]struct{}) + for _, providers := range filteredCandles { + for base := range providers { + if _, ok := reportedCandles[base]; !ok { + reportedCandles[base] = struct{}{} + } + } + } + + if len(reportedCandles) != len(requiredRates) { + return fmt.Errorf("unable to get prices for all exchange candles") + } + for base := range requiredRates { + if _, ok := reportedCandles[base]; !ok { + return fmt.Errorf("reported candles were not equal to required rates") + } + } + o.prices = tvwapPrices }