lamassu-server/packages/server/lib/plugins/ticker/pazuz-ticker/pazuz-ticker.js
2025-05-12 10:52:54 +01:00

28 lines
649 B
JavaScript

const https = require('https')
const axios = require('axios').create({
// TODO: get rejectUnauthorized true to work
baseURL: `${process.env.TICKER_URL}/api/rates/`,
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
})
const BN = require('../../../bn')
function ticker (account, fiatCode, cryptoCode) {
return axios.get(`${cryptoCode}/${fiatCode}`)
.then(({ data }) => {
if (data.error) throw new Error(JSON.stringify(data.error))
return {
rates: {
ask: BN(data.ask),
bid: BN(data.bid),
signature: data.signature
}
}
})
}
module.exports = {
ticker
}