Merge pull request #1768 from RafaelTaranto/backport/binance-default-market

LAM-767 fix: binance ticker default market fiat
This commit is contained in:
Rafael Taranto 2024-11-29 13:50:36 +00:00 committed by GitHub
commit 812d246a10
3 changed files with 10 additions and 5 deletions

View file

@ -23,7 +23,8 @@ const ALL = {
bitpay: bitpay, bitpay: bitpay,
coinbase: { coinbase: {
CRYPTO: [BTC, ETH, LTC, DASH, ZEC, BCH, USDT, USDT_TRON, TRX, LN], CRYPTO: [BTC, ETH, LTC, DASH, ZEC, BCH, USDT, USDT_TRON, TRX, LN],
FIAT: 'ALL_CURRENCIES' FIAT: 'ALL_CURRENCIES',
DEFAULT_FIAT_MARKET: 'EUR'
}, },
binance: binance, binance: binance,
bitfinex: bitfinex bitfinex: bitfinex
@ -48,4 +49,8 @@ function isConfigValid (config, fields) {
return _.every(it => it || it === 0)(values) return _.every(it => it || it === 0)(values)
} }
module.exports = { buildMarket, ALL, verifyFiatSupport, isConfigValid } function defaultFiatMarket (serviceName) {
return ALL[serviceName].DEFAULT_FIAT_MARKET
}
module.exports = { buildMarket, ALL, verifyFiatSupport, isConfigValid, defaultFiatMarket }

View file

@ -6,7 +6,7 @@ const { ORDER_TYPES } = require('./consts')
const ORDER_TYPE = ORDER_TYPES.MARKET const ORDER_TYPE = ORDER_TYPES.MARKET
const { BTC, BCH, XMR, ETH, LTC, ZEC, LN } = COINS const { BTC, BCH, XMR, ETH, LTC, ZEC, LN } = COINS
const CRYPTO = [BTC, ETH, LTC, ZEC, BCH, XMR, LN] const CRYPTO = [BTC, ETH, LTC, ZEC, BCH, XMR, LN]
const FIAT = ['USD', 'EUR'] const FIAT = ['EUR']
const DEFAULT_FIAT_MARKET = 'EUR' const DEFAULT_FIAT_MARKET = 'EUR'
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey', 'currencyMarket'] const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey', 'currencyMarket']

View file

@ -1,7 +1,7 @@
const ccxt = require('ccxt') const ccxt = require('ccxt')
const BN = require('../../bn') const BN = require('../../bn')
const { buildMarket, verifyFiatSupport } = require('../common/ccxt') const { buildMarket, verifyFiatSupport, defaultFiatMarket } = require('../common/ccxt')
const { getRate } = require('../../../lib/forex') const { getRate } = require('../../../lib/forex')
const RETRIES = 2 const RETRIES = 2
@ -33,7 +33,7 @@ function ticker (fiatCode, cryptoCode, tickerName) {
return getRate(RETRIES, fiatCode) return getRate(RETRIES, fiatCode)
.then(({ fxRate }) => { .then(({ fxRate }) => {
try { try {
return getCurrencyRates(ticker, 'USD', cryptoCode) return getCurrencyRates(ticker, defaultFiatMarket(tickerName), cryptoCode)
.then(res => ({ .then(res => ({
rates: { rates: {
ask: res.rates.ask.times(fxRate), ask: res.rates.ask.times(fxRate),