Skip to content

Commit

Permalink
feat(price-feeder): add ftx (#1299)
Browse files Browse the repository at this point in the history
## Description

Adds FTX as a provider

closes: #1276 

---

### Author Checklist

_All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues._

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] added appropriate labels to the PR
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/umee-network/umee/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

_All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items._

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
adamewozniak authored Aug 30, 2022
1 parent 6e3294c commit cdb582c
Show file tree
Hide file tree
Showing 11 changed files with 470 additions and 13 deletions.
1 change: 1 addition & 0 deletions price-feeder/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [#1175](https://github.com/umee-network/umee/pull/1175) Add ProviderName type to facilitate the reading of maps.
- [#1215](https://github.com/umee-network/umee/pull/1215) Moved ProviderName to Name in provider package.
- [#1274](https://github.com/umee-network/umee/pull/1274) Add option to set config by env variables.
- [#1299](https://github.com/umee-network/umee/pull/1299) Add FTX as a provider.

## [v0.2.5](https://github.com/umee-network/umee/releases/tag/price-feeder%2Fv0.2.5) - 2022-07-28

Expand Down
1 change: 1 addition & 0 deletions price-feeder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The list of current supported providers:

- [Binance](https://www.binance.com/en)
- [Coinbase](https://www.coinbase.com/)
- [FTX](https://ftx.com/)
- [Gate](https://www.gate.io/)
- [Huobi](https://www.huobi.com/en-us/)
- [Kraken](https://www.kraken.com/en-us/)
Expand Down
1 change: 1 addition & 0 deletions price-feeder/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (
provider.ProviderHuobi: {},
provider.ProviderGate: {},
provider.ProviderCoinbase: {},
provider.ProviderFTX: {},
provider.ProviderMock: {},
}

Expand Down
4 changes: 3 additions & 1 deletion price-feeder/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ func GetComputedPrices(
providerPairs map[provider.Name][]types.CurrencyPair,
deviations map[string]sdk.Dec,
) (prices map[string]sdk.Dec, err error) {

// convert any non-USD denominated candles into USD
convertedCandles, err := convertCandlesToUSD(
logger,
Expand Down Expand Up @@ -467,6 +466,9 @@ func NewProvider(
case provider.ProviderGate:
return provider.NewGateProvider(ctx, logger, endpoint, providerPairs...)

case provider.ProviderFTX:
return provider.NewFTXProvider(ctx, logger, endpoint, providerPairs...), nil

case provider.ProviderMock:
return provider.NewMockProvider(), nil
}
Expand Down
4 changes: 2 additions & 2 deletions price-feeder/oracle/provider/coinbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
coinbasePingCheck = time.Second * 28 // should be < 30
coinbaseRestHost = "https://api.exchange.coinbase.com"
coinbaseRestPath = "/products"
timeLayout = "2006-01-02T15:04:05.000000Z"
coinbaseTimeFmt = "2006-01-02T15:04:05.000000Z"
unixMinute = 60000
)

Expand Down Expand Up @@ -408,7 +408,7 @@ func (p *CoinbaseProvider) messageReceived(messageType int, bz []byte) {

// timeToUnix converts a Time in format "2006-01-02T15:04:05.000000Z" to unix
func (tr CoinbaseTradeResponse) timeToUnix() int64 {
t, err := time.Parse(timeLayout, tr.Time)
t, err := time.Parse(coinbaseTimeFmt, tr.Time)
if err != nil {
return 0
}
Expand Down
Loading

0 comments on commit cdb582c

Please sign in to comment.