lamassu-server/lib/plugins/ticker/bitpay/bitpay.js
2017-12-20 13:16:44 +02:00

25 lines
521 B
JavaScript

const axios = require('axios')
const BN = require('../../../bn')
function ticker (account, fiatCode, cryptoCode) {
if (!_.includes(cryptoCode, ['BTC', 'BCH'])) {
return Promise.reject('Unsupported crypto: ' + cryptoCode)
}
return axios.get('https://bitpay.com/api/rates/' + cryptoCode '/' + fiatCode)
.then(r => {
const data = r.data
const price = BN(data.rate)
return {
rates: {
ask: price,
bid: price
}
}
})
}
module.exports = {
ticker,
name: 'BitPay'
}