From ce38df3bdeb44baa562ecf4cfe4dd0f080b8ccab Mon Sep 17 00:00:00 2001 From: Kyle Zarazan Date: Tue, 22 Nov 2022 12:07:55 -0700 Subject: [PATCH] fix(price-feeder): Parse multiple candles from OsmosisV2 response (#1615) Parse an array of candle responses from osmosisV2 api --- price-feeder/CHANGELOG.md | 4 ++++ price-feeder/oracle/provider/osmosisv2.go | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/price-feeder/CHANGELOG.md b/price-feeder/CHANGELOG.md index 405f99335f..9a4ce742cb 100644 --- a/price-feeder/CHANGELOG.md +++ b/price-feeder/CHANGELOG.md @@ -46,6 +46,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Bugs + +- [1615](https://github.com/umee-network/umee/pull/1615) Parse multiple candles from OsmosisV2 response + ### Improvements - [1602](https://github.com/umee-network/umee/pull/1602) Remove FTX provider. diff --git a/price-feeder/oracle/provider/osmosisv2.go b/price-feeder/oracle/provider/osmosisv2.go index 32e5b2a4b0..c0fef89a04 100644 --- a/price-feeder/oracle/provider/osmosisv2.go +++ b/price-feeder/oracle/provider/osmosisv2.go @@ -200,7 +200,7 @@ func (p *OsmosisV2Provider) messageReceived(messageType int, bz []byte) { messageErr error tickerResp OsmosisV2Ticker tickerErr error - candleResp OsmosisV2Candle + candleResp []OsmosisV2Candle candleErr error ) @@ -242,7 +242,7 @@ func (p *OsmosisV2Provider) messageReceived(messageType int, bz []byte) { if len(v) == 0 { continue } - candleString, _ := json.Marshal(v[len(v)-1].(map[string]interface{})) + candleString, _ := json.Marshal(v) candleErr = json.Unmarshal(candleString, &candleResp) if candleErr != nil { p.logger.Error(). @@ -251,10 +251,12 @@ func (p *OsmosisV2Provider) messageReceived(messageType int, bz []byte) { Msg("Error on receive message") continue } - p.setCandlePair( - osmosisV2Pair, - candleResp, - ) + for _, singleCandle := range candleResp { + p.setCandlePair( + osmosisV2Pair, + singleCandle, + ) + } telemetryWebsocketMessage(ProviderOsmosisV2, MessageTypeCandle) continue }