From 9731e5fbebd729ea9f3cfbd0f66c4195a2f12359 Mon Sep 17 00:00:00 2001 From: Daniel <80175477+dan437@users.noreply.github.com> Date: Mon, 7 Feb 2022 11:58:31 +0100 Subject: [PATCH] Handle a negative gas fee (#13511) --- app/scripts/controllers/swaps.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/scripts/controllers/swaps.js b/app/scripts/controllers/swaps.js index 406743237..5e8fb6990 100644 --- a/app/scripts/controllers/swaps.js +++ b/app/scripts/controllers/swaps.js @@ -51,10 +51,12 @@ function calculateGasEstimateWithRefund( estimatedRefund, 10, ); + const isMaxGasMinusRefundNegative = maxGasMinusRefund.lt(0); - const gasEstimateWithRefund = maxGasMinusRefund.lt(estimatedGas, 16) - ? maxGasMinusRefund.toString(16) - : estimatedGas; + const gasEstimateWithRefund = + !isMaxGasMinusRefundNegative && maxGasMinusRefund.lt(estimatedGas, 16) + ? maxGasMinusRefund.toString(16) + : estimatedGas; return gasEstimateWithRefund; }