lamassu-server/lib/plugins/ticker/bitpay/bitpay.js
2017-04-15 20:33:54 +03:00

25 lines
485 B
JavaScript

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