diff --git a/lib/plugins/exchange/ccxt.js b/lib/plugins/exchange/ccxt.js index 85e353cf..63b57fa9 100644 --- a/lib/plugins/exchange/ccxt.js +++ b/lib/plugins/exchange/ccxt.js @@ -58,13 +58,16 @@ function calculatePrice (side, amount, orderBook) { function _getMarkets (exchangeName, availableCryptos) { try { const exchange = new ccxt[exchangeName]() - const currencyCodes = _.map(it => it.code, currencies) + const cryptosToQuoteAgainst = ['USDT'] + const currencyCodes = _.concat(_.map(it => it.code, currencies), cryptosToQuoteAgainst) return exchange.fetchMarkets() .then(_.filter(it => (it.type === 'spot' || it.spot))) .then(res => _.reduce((acc, value) => { if (_.includes(value.base, availableCryptos) && _.includes(value.quote, currencyCodes)) { + if (value.quote === value.base) return acc + if (_.isNil(acc[value.quote])) { return { ...acc, [value.quote]: [value.base] } } diff --git a/new-lamassu-admin/src/pages/Services/schemas/helper.js b/new-lamassu-admin/src/pages/Services/schemas/helper.js index a82c2821..7d71e79f 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/helper.js +++ b/new-lamassu-admin/src/pages/Services/schemas/helper.js @@ -27,15 +27,20 @@ const leadingZerosTest = (value, context) => { const buildCurrencyOptions = markets => { return R.map(it => { const unavailableCryptos = R.difference(ALL_CRYPTOS, markets[it]) - const unavailableMarkets = R.join( - ', ', - R.map(ite => `${ite}/${it}`, unavailableCryptos) - ) + const unavailableCryptosFiltered = R.difference(unavailableCryptos, [it]) // As the markets can have stablecoins to trade against other crypto, filter them out, as there can't be pairs such as USDT/USDT - const warningLevel = R.isEmpty(unavailableCryptos) + const unavailableMarketsStr = + R.length(unavailableCryptosFiltered) > 1 + ? `${R.join( + ', ', + R.slice(0, -1, unavailableCryptosFiltered) + )} and ${R.last(unavailableCryptosFiltered)}` + : unavailableCryptosFiltered[0] + + const warningLevel = R.isEmpty(unavailableCryptosFiltered) ? WARNING_LEVELS.CLEAN - : !R.isEmpty(unavailableCryptos) && - R.length(unavailableCryptos) < R.length(ALL_CRYPTOS) + : !R.isEmpty(unavailableCryptosFiltered) && + R.length(unavailableCryptosFiltered) < R.length(ALL_CRYPTOS) ? WARNING_LEVELS.PARTIAL : WARNING_LEVELS.IMPORTANT @@ -43,8 +48,8 @@ const buildCurrencyOptions = markets => { code: R.toUpper(it), display: R.toUpper(it), warning: warningLevel, - warningMessage: !R.isEmpty(unavailableMarkets) - ? `No market pairs available for ${unavailableMarkets}` + warningMessage: !R.isEmpty(unavailableCryptosFiltered) + ? `No market pairs available for ${unavailableMarketsStr}` : `All market pairs are available` } }, R.keys(markets))