bitpay / bitcore

A full stack for bitcoin and blockchain-based applications
https://bitcore.io/
MIT License
4.85k stars 2.09k forks source link

Add BCH fiat rate provider #2180

Open monsterbitar opened 5 years ago

monsterbitar commented 5 years ago

In https://github.com/bitpay/bitcore/blob/master/packages/bitcore-wallet-service/src/lib/fiatrateproviders/bitpay.ts a provider for the bitpay fiat exchange rate for their default cryptocurrency is provided.

This lets users get the BTC rate at a later time through BWS, but there is no way to get BCH rates right now.

I assume the proper solution is to copy that file, and amend the name and url to match the BCH version and let the BWC request that specific provider, for example:

Provider named BitPayBCH using the https://bitpay.com/api/rates/BCH url.

imaginaryusername commented 5 years ago

While a workaround exists doing two conversions from BCH -> BTC -> fiat, it complicates implementation and may introduce unforseen latency/slippage; better provide the rates for BCH directly as a first-class citizen.

We have a quick fix that allows calling bitpayBCH as a provider, can submit as PR if maintainers are interested.