diff --git a/ui/app/pages/swaps/swaps.util.js b/ui/app/pages/swaps/swaps.util.js index 679e51929..fb6173101 100644 --- a/ui/app/pages/swaps/swaps.util.js +++ b/ui/app/pages/swaps/swaps.util.js @@ -366,10 +366,16 @@ export function quotesToRenderableData (quotes, gasPrice, conversionRate, curren export function getSwapsTokensReceivedFromTxMeta (tokenSymbol, txMeta, tokenAddress, accountAddress, tokenDecimals) { if (tokenSymbol === 'ETH') { - if (!txMeta?.postTxBalance || !txMeta?.preTxBalance) { + if (!txMeta || !txMeta.postTxBalance || !txMeta.preTxBalance) { return null } - const ethReceived = subtractCurrencies(txMeta.postTxBalance, txMeta.preTxBalance, { + const gasCost = calcGasTotal(txMeta.txParams.gas, txMeta.txParams.gasPrice) + const preTxBalanceLessGasCost = subtractCurrencies(txMeta.preTxBalance, gasCost, { + aBase: 16, + bBase: 16, + toNumericBase: 'hex', + }) + const ethReceived = subtractCurrencies(txMeta.postTxBalance, preTxBalanceLessGasCost, { aBase: 16, bBase: 16, fromDenomination: 'WEI',