Skip to content

Commit

Permalink
Merge pull request #1241 from RafaelTaranto/backport/fixedfee-for-cas…
Browse files Browse the repository at this point in the history
…hout

LAM-222 backport: fixedfee for cashout
  • Loading branch information
RafaelTaranto authored Nov 29, 2024
2 parents ae0404b + c5254ae commit d1ddf9f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/brain.js
Original file line number Diff line number Diff line change
Expand Up @@ -3745,6 +3745,7 @@ Brain.prototype._chooseFiat = function _chooseFiat () {
const updateRec = {
direction: 'cashOut',
fiatCode: this.fiatCode,
cashOutFee: coin.cashOutFee,
commissionPercentage: BN(coin.cashOutCommission).div(100),
rawTickerPrice: BN(coin.rates.bid)
}
Expand Down
4 changes: 3 additions & 1 deletion lib/trader.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ query($configVersion: Int, $currentHash: String) {
cryptoCodeDisplay
display
minimumTx
cashInFee
cashInCommission
cashInFee
cashOutCommission
cashOutFee
cryptoNetwork
cryptoUnits
batchable
Expand Down Expand Up @@ -366,6 +367,7 @@ function massage (rawTx) {

return _.assign(tx, {
cryptoAtoms: BN(tx.cryptoAtoms),
cashOutFee: BN(tx.cashOutFee),
commissionPercentage: BN(tx.commissionPercentage),
fiat: BN(tx.fiat)
})
Expand Down
8 changes: 7 additions & 1 deletion lib/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ function mergeTx (oldTx, updateTx) {
const bills = _.unionBy(_.get('id'), oldTx.bills, updateTx.bills)
const cryptoCode = oldTx.cryptoCode
const mergedTx = _.defaults(oldTx, updateTx)
const fee = BN(
mergedTx.cashInFee ? mergedTx.cashInFee :
mergedTx.cashOutFee ? mergedTx.cashOutFee :
0
)

const cashInNewFields = () => ({
bills,
Expand All @@ -34,7 +39,8 @@ function mergeTx (oldTx, updateTx) {

const cashOutNewFields = () => ({
fiat: oldTx.fiat.add(updateTx.fiat || 0),
cryptoAtoms: truncateCrypto(toCrypto(mergedTx, oldTx.fiat.add(updateTx.fiat || 0)), cryptoCode)
cryptoAtoms: truncateCrypto(toCrypto(mergedTx, oldTx.fiat.add(updateTx.fiat || 0).add(fee)), cryptoCode),
cashOutFee: fee
})

var newFields
Expand Down
5 changes: 4 additions & 1 deletion ui/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ function processData (data) {
if (data.cassettes) buildCassetteButtons(data.cassettes, NUMBER_OF_BUTTONS)
if (data.readingBills) readingBills(data.readingBills)
if (data.cryptoCode) translateCoin(data.cryptoCode)
if (data.tx && data.tx.cashInFee) setFixedFee(data.tx.cashInFee)
if (data.tx) {
if (data.tx.cashInFee) setFixedFee(data.tx.cashInFee)
else if (data.tx.cashOutFee) setFixedFee(data.tx.cashOutFee)
}
if (data.terms) setTermsScreen(data.terms)
if (data.dispenseBatch) dispenseBatch(data.dispenseBatch)
if (data.direction) setDirection(data.direction)
Expand Down

0 comments on commit d1ddf9f

Please sign in to comment.