Fix: make percentage chart work properly
Fix: code review Fix: rework components according to PR requested changes Fix: fix repeated code buildRatesNoCommission Also renames id to deviceId in transactions quer Fix: pr requested changes Chore: move inline styles to classes Chore: remove comment Fix: bad equality !process.env.NODE_ENV === 'production'
This commit is contained in:
parent
5572fb0eb1
commit
ae7eaca10c
43 changed files with 818 additions and 1578 deletions
|
|
@ -35,7 +35,8 @@ const PONG_TTL = '1 week'
|
|||
const tradesQueues = {}
|
||||
|
||||
function plugins (settings, deviceId) {
|
||||
function buildRatesNoCommission (tickers) {
|
||||
|
||||
function internalBuildRates (tickers, withCommission = true) {
|
||||
const localeConfig = configManager.getLocale(deviceId, settings.config)
|
||||
const cryptoCodes = localeConfig.cryptoCurrencies
|
||||
|
||||
|
|
@ -43,30 +44,7 @@ function plugins (settings, deviceId) {
|
|||
|
||||
cryptoCodes.forEach((cryptoCode, i) => {
|
||||
const rateRec = tickers[i]
|
||||
|
||||
if (!rateRec) return
|
||||
|
||||
if (Date.now() - rateRec.timestamp > STALE_TICKER)
|
||||
return logger.warn('Stale rate for ' + cryptoCode)
|
||||
const rate = rateRec.rates
|
||||
rates[cryptoCode] = {
|
||||
cashIn: rate.ask.round(5),
|
||||
cashOut: rate.bid.round(5)
|
||||
}
|
||||
})
|
||||
|
||||
return rates
|
||||
}
|
||||
|
||||
function buildRates (tickers) {
|
||||
const localeConfig = configManager.getLocale(deviceId, settings.config)
|
||||
const cryptoCodes = localeConfig.cryptoCurrencies
|
||||
|
||||
const rates = {}
|
||||
|
||||
cryptoCodes.forEach((cryptoCode, i) => {
|
||||
const commissions = configManager.getCommissions(cryptoCode, deviceId, settings.config)
|
||||
const rateRec = tickers[i]
|
||||
|
||||
if (!rateRec) return
|
||||
|
||||
|
|
@ -78,15 +56,26 @@ function plugins (settings, deviceId) {
|
|||
|
||||
if (Date.now() - rateRec.timestamp > STALE_TICKER) return logger.warn('Stale rate for ' + cryptoCode)
|
||||
const rate = rateRec.rates
|
||||
rates[cryptoCode] = {
|
||||
|
||||
withCommission ? rates[cryptoCode] = {
|
||||
cashIn: rate.ask.mul(cashInCommission).round(5),
|
||||
cashOut: cashOutCommission && rate.bid.div(cashOutCommission).round(5)
|
||||
} : rates[cryptoCode] = {
|
||||
cashIn: rate.ask.round(5),
|
||||
cashOut: rate.bid.round(5)
|
||||
}
|
||||
})
|
||||
|
||||
return rates
|
||||
}
|
||||
|
||||
function buildRatesNoCommission (tickers) {
|
||||
return internalBuildRates(tickers, false)
|
||||
}
|
||||
|
||||
function buildRates (tickers) {
|
||||
return internalBuildRates(tickers, true)
|
||||
}
|
||||
|
||||
function getNotificationConfig () {
|
||||
return configManager.getGlobalNotifications(settings.config)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue