rewoking getCommissionPercentage function
This commit is contained in:
parent
03279c8d2c
commit
5815a606f2
3 changed files with 16 additions and 8 deletions
|
|
@ -11,7 +11,11 @@ module.exports = {redeemableTxs, toObj, toDb}
|
||||||
const mapValuesWithKey = _.mapValues.convert({cap: false})
|
const mapValuesWithKey = _.mapValues.convert({cap: false})
|
||||||
|
|
||||||
function convertBigNumFields (obj) {
|
function convertBigNumFields (obj) {
|
||||||
const convert = (value, key) => _.includes(key, ['cryptoAtoms', 'fiat', 'commissionPercentage'])
|
const convert = (value, key) => _.includes(key, [
|
||||||
|
'cryptoAtoms',
|
||||||
|
'fiat',
|
||||||
|
'commissionPercentage'
|
||||||
|
])
|
||||||
? value.toString()
|
? value.toString()
|
||||||
: value
|
: value
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,13 @@ const PONG_TTL = '1 week'
|
||||||
const tradesQueues = {}
|
const tradesQueues = {}
|
||||||
|
|
||||||
function plugins (settings, deviceId) {
|
function plugins (settings, deviceId) {
|
||||||
function getCommissionForTx (tx) {
|
function getCommissionPercentage (cryptoCode) {
|
||||||
const direction = _.get('direction', tx)
|
|
||||||
const cryptoCode = _.get('cryptoCode', tx)
|
|
||||||
const cryptoConfig = configManager.scoped(cryptoCode, deviceId, settings.config)
|
const cryptoConfig = configManager.scoped(cryptoCode, deviceId, settings.config)
|
||||||
|
|
||||||
if (direction === 'cashIn') return /* cashInCommission */ BN(cryptoConfig.cashInCommission).div(100)
|
return {
|
||||||
if (direction === 'cashOut') return /* cashOutCommission */ BN(cryptoConfig.cashOutCommission).div(100)
|
cashIn: BN(cryptoConfig.cashInCommission).div(100),
|
||||||
|
cashOut: BN(cryptoConfig.cashOutCommission).div(100)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildRates (tickers) {
|
function buildRates (tickers) {
|
||||||
|
|
@ -793,7 +793,7 @@ function plugins (settings, deviceId) {
|
||||||
sell,
|
sell,
|
||||||
notificationsEnabled,
|
notificationsEnabled,
|
||||||
notifyOperator,
|
notifyOperator,
|
||||||
getCommissionForTx
|
getCommissionPercentage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,15 @@ function post (tx, pi) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function massage (tx, pi) {
|
function massage (tx, pi) {
|
||||||
|
const direction = _.get('direction', tx)
|
||||||
|
const cryptoCode = _.get('cryptoCode', tx)
|
||||||
const isDateField = r => r === 'created' || _.endsWith('_time', r)
|
const isDateField = r => r === 'created' || _.endsWith('_time', r)
|
||||||
const transformDate = (v, k) => isDateField(k) ? new Date(v) : v
|
const transformDate = (v, k) => isDateField(k) ? new Date(v) : v
|
||||||
const mapValuesWithKey = _.mapValues.convert({'cap': false})
|
const mapValuesWithKey = _.mapValues.convert({'cap': false})
|
||||||
const transformDates = r => mapValuesWithKey(transformDate, r)
|
const transformDates = r => mapValuesWithKey(transformDate, r)
|
||||||
const logCommission = r => _.assign(r, {commissionPercentage: pi.getCommissionForTx(tx)})
|
const logCommission = r => _.assign(r, {
|
||||||
|
commissionPercentage: _.get(direction, pi.getCommissionPercentage(cryptoCode))
|
||||||
|
})
|
||||||
|
|
||||||
const mapBN = r => {
|
const mapBN = r => {
|
||||||
const update = r.direction === 'cashIn'
|
const update = r.direction === 'cashIn'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue