chore: remove deprecated forex
This commit is contained in:
parent
297a3d76fb
commit
a84c82de92
1 changed files with 1 additions and 13 deletions
14
lib/forex.js
14
lib/forex.js
|
|
@ -7,8 +7,7 @@ const MAX_ROTATIONS = 5
|
||||||
const getFiatRates = () => axios.get('https://bitpay.com/api/rates').then(response => response.data)
|
const getFiatRates = () => axios.get('https://bitpay.com/api/rates').then(response => response.data)
|
||||||
|
|
||||||
const API_QUEUE = [
|
const API_QUEUE = [
|
||||||
{ api: getBitPayFxRate, name: 'bitpay', fiatCodeProperty: 'code', rateProperty: 'rate' },
|
{ api: getBitPayFxRate, name: 'bitpay', fiatCodeProperty: 'code', rateProperty: 'rate' }
|
||||||
{ api: getCoinCapFxRate, name: 'coincap', fiatCodeProperty: 'symbol', rateProperty: 'rateUsd' }
|
|
||||||
]
|
]
|
||||||
|
|
||||||
function getBitPayFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, rateProperty) {
|
function getBitPayFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, rateProperty) {
|
||||||
|
|
@ -23,17 +22,6 @@ function getBitPayFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, ratePro
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCoinCapFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, rateProperty) {
|
|
||||||
return axios.get('https://api.coincap.io/v2/rates')
|
|
||||||
.then(response => {
|
|
||||||
const fxRates = response.data.data
|
|
||||||
const fxRate = new BN(1).div(findCurrencyRates(fxRates, fiatCode, fiatCodeProperty, rateProperty))
|
|
||||||
return {
|
|
||||||
fxRate
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function findCurrencyRates (fxRates, fiatCode, fiatCodeProperty, rateProperty) {
|
function findCurrencyRates (fxRates, fiatCode, fiatCodeProperty, rateProperty) {
|
||||||
const rates = _.find(_.matchesProperty(fiatCodeProperty, fiatCode), fxRates)
|
const rates = _.find(_.matchesProperty(fiatCodeProperty, fiatCode), fxRates)
|
||||||
if (!rates || !rates[rateProperty]) throw new Error(`Unsupported currency: ${fiatCode}`)
|
if (!rates || !rates[rateProperty]) throw new Error(`Unsupported currency: ${fiatCode}`)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue