Skip to content

Commit

Permalink
fix(price-feeder): Parse multiple candles from OsmosisV2 response (#1615
Browse files Browse the repository at this point in the history
)

Parse an array of candle responses from osmosisV2 api
  • Loading branch information
zarazan authored Nov 22, 2022
1 parent c55960c commit ce38df3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions price-feeder/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 8 additions & 6 deletions price-feeder/oracle/provider/osmosisv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (p *OsmosisV2Provider) messageReceived(messageType int, bz []byte) {
messageErr error
tickerResp OsmosisV2Ticker
tickerErr error
candleResp OsmosisV2Candle
candleResp []OsmosisV2Candle
candleErr error
)

Expand Down Expand Up @@ -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().
Expand All @@ -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
}
Expand Down

0 comments on commit ce38df3

Please sign in to comment.