Skip to content

Commit

Permalink
Handle high precision bitpay response numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelTaranto authored and joshmh committed Jun 7, 2019
1 parent 0060d7f commit db87373
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/ticker/bitpay/bitpay.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function ticker (account, fiatCode, cryptoCode) {
return axios.get('https://bitpay.com/api/rates/' + cryptoCode + '/' + fiatCode)
.then(r => {
const data = r.data
const price = BN(data.rate)
const price = BN(data.rate.toString())
return {
rates: {
ask: price,
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/ticker/bitstamp/bitstamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.SUPPORTED_MODULES = ['ticker']
function findCurrency (fxRates, fiatCode) {
const rates = _.find(_.matchesProperty('code', fiatCode), fxRates)
if (!rates || !rates.rate) throw new Error(`Unsupported currency: ${fiatCode}`)
return BN(rates.rate)
return BN(rates.rate.toString())
}

exports.ticker = function ticker (account, fiatCode, cryptoCode) {
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/ticker/itbit/itbit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.SUPPORTED_MODULES = ['ticker']
function findCurrency (fxRates, fiatCode) {
const rates = _.find(_.matchesProperty('code', fiatCode), fxRates)
if (!rates || !rates.rate) throw new Error(`Unsupported currency: ${fiatCode}`)
return BN(rates.rate)
return BN(rates.rate.toString())
}

exports.ticker = function ticker (account, fiatCode, cryptoCode) {
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/ticker/kraken/kraken.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const PAIRS = common.PAIRS
function findCurrency (fxRates, fiatCode) {
const rates = _.find(_.matchesProperty('code', fiatCode), fxRates)
if (!rates || !rates.rate) throw new Error(`Unsupported currency: ${fiatCode}`)
return BN(rates.rate)
return BN(rates.rate.toString())
}

exports.ticker = function ticker (account, fiatCode, cryptoCode) {
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/ticker/quadrigacx/quadrigacx.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.SUPPORTED_MODULES = ['ticker']
function findCurrency (fxRates, fiatCode) {
const rates = _.find(_.matchesProperty('code', fiatCode), fxRates)
if (!rates || !rates.rate) throw new Error(`Unsupported currency: ${fiatCode}`)
return BN(rates.rate)
return BN(rates.rate.toString())
}

exports.ticker = function ticker (account, fiatCode, cryptoCode) {
Expand Down

0 comments on commit db87373

Please sign in to comment.