diff --git a/lib/new-admin/services/transactions.js b/lib/new-admin/services/transactions.js index 5155a7ad..42832859 100644 --- a/lib/new-admin/services/transactions.js +++ b/lib/new-admin/services/transactions.js @@ -169,8 +169,8 @@ function simplifiedBatch (data) { const getCryptoAmount = it => coinUtils.toUnit(BN(it.cryptoAtoms), it.cryptoCode) const getProfit = it => { - /* fiat - crypto*tickerPrice + fee */ - const calcCashInProfit = (fiat, crypto, tickerPrice, fee) => fiat.minus(crypto.times(tickerPrice)).plus(fee) + /* fiat - crypto*tickerPrice */ + const calcCashInProfit = (fiat, crypto, tickerPrice) => fiat.minus(crypto.times(tickerPrice)) /* crypto*tickerPrice - fiat */ const calcCashOutProfit = (fiat, crypto, tickerPrice) => crypto.times(tickerPrice).minus(fiat) @@ -180,7 +180,7 @@ const getProfit = it => { const isCashIn = it.txClass === 'cashIn' return isCashIn - ? calcCashInProfit(fiat, crypto, tickerPrice, BN(it.cashInFee)) + ? calcCashInProfit(fiat, crypto, tickerPrice) : calcCashOutProfit(fiat, crypto, tickerPrice) } diff --git a/new-lamassu-admin/src/pages/Transactions/DetailsCard.js b/new-lamassu-admin/src/pages/Transactions/DetailsCard.js index 57c1e166..1daaedaa 100644 --- a/new-lamassu-admin/src/pages/Transactions/DetailsCard.js +++ b/new-lamassu-admin/src/pages/Transactions/DetailsCard.js @@ -88,24 +88,6 @@ const CANCEL_CASH_IN_TRANSACTION = gql` const getCryptoAmount = tx => coinUtils.toUnit(new BigNumber(tx.cryptoAtoms), tx.cryptoCode).toNumber() -/* Port of getProfit() from lib/new-admin/services/transactions.js */ -const getCommission = tx => { - const calcCashInProfit = (fiat, crypto, tickerPrice, fee) => - fiat - crypto * tickerPrice + fee - const calcCashOutProfit = (fiat, crypto, tickerPrice) => - crypto * tickerPrice - fiat - - const fiat = Number.parseFloat(tx.fiat) - const crypto = getCryptoAmount(tx) - const tickerPrice = Number.parseFloat(tx.rawTickerPrice) - const isCashIn = tx.txClass === 'cashIn' - const cashInFee = isCashIn ? Number.parseFloat(tx.cashInFee) : 0 - - return isCashIn - ? calcCashInProfit(fiat, crypto, tickerPrice, cashInFee) - : calcCashOutProfit(fiat, crypto, tickerPrice) -} - const formatAddress = (cryptoCode = '', address = '') => coinUtils.formatCryptoAddress(cryptoCode, address).replace(/(.{5})/g, '$1 ') @@ -136,7 +118,7 @@ const DetailsRow = ({ it: tx, timezone }) => { } ) - const commission = BigNumber(getCommission(tx)) + const commission = BigNumber(tx.profit) .abs() .toFixed(2, 1) // ROUND_DOWN const commissionPercentage = diff --git a/new-lamassu-admin/src/pages/Transactions/Transactions.js b/new-lamassu-admin/src/pages/Transactions/Transactions.js index 8e459994..0380a116 100644 --- a/new-lamassu-admin/src/pages/Transactions/Transactions.js +++ b/new-lamassu-admin/src/pages/Transactions/Transactions.js @@ -121,6 +121,7 @@ const GET_TRANSACTIONS = gql` rawTickerPrice batchError walletScore + profit } } `