refactor: replace trade uuid variable name

This commit is contained in:
José Oliveira 2021-07-08 15:28:51 +01:00 committed by Josh Harvey
parent 9b4bae4097
commit ca0f068bcf
2 changed files with 4 additions and 4 deletions

View file

@ -14,14 +14,14 @@ function trade (side, account, tradeEntry, exchangeName) {
const exchangeConfig = ALL[exchangeName]
if (!exchangeConfig) throw Error('Exchange configuration not found')
const { CUSTOM_KEY, loadOptions, loadConfig = _.noop, REQUIRED_CONFIG_FIELDS, ORDER_TYPE, AMOUNT_PRECISION } = exchangeConfig
const { USER_REF, loadOptions, loadConfig = _.noop, REQUIRED_CONFIG_FIELDS, ORDER_TYPE, AMOUNT_PRECISION } = exchangeConfig
if (!isConfigValid(account, REQUIRED_CONFIG_FIELDS)) throw Error('Invalid config')
const symbol = buildMarket(fiatCode, cryptoCode, exchangeName)
const precision = _.defaultTo(DEFAULT_AMOUNT_PRECISION, AMOUNT_PRECISION)
const amount = toUnit(cryptoAtoms, cryptoCode).toFixed(precision)
const accountOptions = _.isFunction(loadOptions) ? loadOptions(account) : {}
const withCustomKey = CUSTOM_KEY ? { [CUSTOM_KEY]: tradeId } : {}
const withCustomKey = USER_REF ? { [USER_REF]: tradeId } : {}
const options = _.assign(accountOptions, withCustomKey)
const exchange = new ccxt[exchangeName](loadConfig(account))

View file

@ -9,7 +9,7 @@ const CRYPTO = [BTC, ETH, LTC, DASH, ZEC, BCH, USDT]
const FIAT = ['USD', 'EUR']
const AMOUNT_PRECISION = 6
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
const CUSTOM_KEY = 'userref'
const USER_REF = 'userref'
const loadConfig = (account) => {
const mapper = {
@ -21,4 +21,4 @@ const loadConfig = (account) => {
const loadOptions = () => ({ expiretm: '+60' })
module.exports = { CUSTOM_KEY, loadOptions, loadConfig, REQUIRED_CONFIG_FIELDS, CRYPTO, FIAT, ORDER_TYPE, AMOUNT_PRECISION }
module.exports = { USER_REF, loadOptions, loadConfig, REQUIRED_CONFIG_FIELDS, CRYPTO, FIAT, ORDER_TYPE, AMOUNT_PRECISION }