Refactored some exchange code

This commit is contained in:
José Oliveira 2021-01-21 11:08:20 +00:00 committed by Josh Harvey
parent 54a231ab60
commit 134eaaa518
20 changed files with 141 additions and 643 deletions

View file

@ -13,16 +13,16 @@ const FIAT = {
kraken: ['USD', 'EUR']
}
module.exports = { verifyCurrencies }
function verifyCurrencies (exchangeName, fiatCode, cryptoCode) {
if (!_.includes(cryptoCode, CRYPTO[exchangeName])) {
throw new Error('Unsupported crypto: ' + cryptoCode)
}
if (!(exchangeName === 'coinbase')) { // coinbase is only used for ticker and it's expected to support most of the fiat
if (exchangeName !== 'coinbase') {
if (!_.includes(fiatCode, FIAT[exchangeName])) {
throw new Error('Unsupported fiat: ' + fiatCode)
}
}
return cryptoCode + '/' + fiatCode
}
module.exports = { verifyCurrencies, CRYPTO, FIAT }