fix all clear notification
This commit is contained in:
parent
77f487c03c
commit
a4b35bab05
2 changed files with 16 additions and 11 deletions
|
|
@ -1,5 +1,5 @@
|
|||
const uuid = require('uuid')
|
||||
const R = require('ramda')
|
||||
const _ = require('lodash/fp')
|
||||
const BigNumber = require('bignumber.js')
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
const crypto = require('crypto')
|
||||
|
|
@ -206,7 +206,7 @@ function plugins (settings) {
|
|||
|
||||
return wallet.newAddress(settings, cryptoCode, info)
|
||||
.then(address => {
|
||||
const newTx = R.assoc('toAddress', address, tx)
|
||||
const newTx = _.set('toAddress', address, tx)
|
||||
|
||||
return dbm.addInitialIncoming(deviceId, newTx, address)
|
||||
.then(() => address)
|
||||
|
|
@ -323,7 +323,6 @@ function plugins (settings) {
|
|||
|
||||
const filtered = marketTradesQueues
|
||||
.filter(tradeEntry => {
|
||||
console.log('DEBUG33: %j, %s, %s, %s', tradeEntry, t1, tradeEntry.timestamp, TRADE_TTL)
|
||||
return t1 - tradeEntry.timestamp < TRADE_TTL
|
||||
})
|
||||
|
||||
|
|
@ -366,7 +365,7 @@ function plugins (settings) {
|
|||
return cryptoCodes.map(cryptoCode => ({fiatCode, cryptoCode}))
|
||||
})
|
||||
|
||||
const tradesPromises = R.uniq(R.flatten(lists))
|
||||
const tradesPromises = _.uniq(_.flatten(lists))
|
||||
.map(r => executeTradesForMarket(settings, r.fiatCode, r.cryptoCode))
|
||||
|
||||
return Promise.all(tradesPromises)
|
||||
|
|
@ -426,10 +425,11 @@ function plugins (settings) {
|
|||
})
|
||||
}
|
||||
|
||||
function checkBalance (settings, rec) {
|
||||
function checkBalance (rec) {
|
||||
const config = configManager.unscoped(settings.config)
|
||||
const lowBalanceThreshold = config.lowBalanceThreshold
|
||||
return lowBalanceThreshold && rec.fiatBalance < lowBalanceThreshold
|
||||
|
||||
return rec.fiatBalance.balance <= lowBalanceThreshold
|
||||
? {code: 'lowBalance', cryptoCode: rec.cryptoCode, fiatBalance: rec.fiatBalance, fiatCode: rec.fiatCode}
|
||||
: null
|
||||
}
|
||||
|
|
@ -442,12 +442,14 @@ function plugins (settings) {
|
|||
|
||||
return Promise.all(deviceBalancePromises)
|
||||
.then(arr => {
|
||||
const toMarket = r => r.fiatBalance + r.cryptoCode
|
||||
const min = R.minBy(r => r.fiatBalance)
|
||||
return R.values(R.reduceBy(min, Infinity, toMarket, R.flatten(arr)))
|
||||
const toMarket = r => [r.fiatCode, r.cryptoCode].join('')
|
||||
const min = _.minBy(r => r.fiatBalance)
|
||||
const byMarket = _.groupBy(toMarket, _.flatten(arr))
|
||||
const minByMarket = _.flatMap(min, byMarket)
|
||||
|
||||
return _.reject(_.isNil, _.map(checkBalance, minByMarket))
|
||||
})
|
||||
})
|
||||
.then(balances => R.reject(R.isNil, balances.map(balance => checkBalance)))
|
||||
}
|
||||
|
||||
function randomCode () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue