chore: remove deprecated forex

This commit is contained in:
Rafael Taranto 2025-05-06 10:00:29 +01:00
parent 297a3d76fb
commit a84c82de92

View file

@ -7,8 +7,7 @@ const MAX_ROTATIONS = 5
const getFiatRates = () => axios.get('https://bitpay.com/api/rates').then(response => response.data)
const API_QUEUE = [
{ api: getBitPayFxRate, name: 'bitpay', fiatCodeProperty: 'code', rateProperty: 'rate' },
{ api: getCoinCapFxRate, name: 'coincap', fiatCodeProperty: 'symbol', rateProperty: 'rateUsd' }
{ api: getBitPayFxRate, name: 'bitpay', fiatCodeProperty: 'code', rateProperty: 'rate' }
]
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) {
const rates = _.find(_.matchesProperty(fiatCodeProperty, fiatCode), fxRates)
if (!rates || !rates[rateProperty]) throw new Error(`Unsupported currency: ${fiatCode}`)