Skip to content

Commit c00b496

Browse files
committed
Use gasLimitNoBuffer on fee calculations
1 parent 44608df commit c00b496

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

shared/modules/gas.utils.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,12 @@ export function getMaximumGasTotalInHexWei({
5858
* @returns {string} The minimum total cost of transaction in hex wei string
5959
*/
6060
export function getMinimumGasTotalInHexWei({
61-
gasLimit = '0x0',
62-
gasLimitNoBuffer,
61+
gasLimitNoBuffer = '0x0',
6362
gasPrice,
6463
maxPriorityFeePerGas,
6564
maxFeePerGas,
6665
baseFeePerGas,
6766
} = {}) {
68-
const minimumGasLimit = gasLimitNoBuffer ?? gasLimit;
6967
const isEIP1559Estimate = Boolean(
7068
maxFeePerGas || maxPriorityFeePerGas || baseFeePerGas,
7169
);
@@ -94,7 +92,7 @@ export function getMinimumGasTotalInHexWei({
9492
}
9593
if (isEIP1559Estimate === false) {
9694
return getMaximumGasTotalInHexWei({
97-
gasLimit: minimumGasLimit,
95+
gasLimit: gasLimitNoBuffer,
9896
gasPrice,
9997
});
10098
}
@@ -104,11 +102,11 @@ export function getMinimumGasTotalInHexWei({
104102

105103
if (new Numeric(minimumFeePerGas, 16).greaterThan(maxFeePerGas, 16)) {
106104
return getMaximumGasTotalInHexWei({
107-
gasLimit: minimumGasLimit,
105+
gasLimit: gasLimitNoBuffer,
108106
maxFeePerGas,
109107
});
110108
}
111-
return new Numeric(minimumGasLimit, 16)
109+
return new Numeric(gasLimitNoBuffer, 16)
112110
.times(new Numeric(minimumFeePerGas, 16))
113111
.toPrefixedHexString();
114112
}

ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ export function useFeeCalculations(transactionMeta: TransactionMeta) {
115115
);
116116

117117
// Max fee
118-
const gasLimit = transactionMeta?.txParams?.gas || HEX_ZERO;
118+
const gasLimitNoBuffer = transactionMeta.gasLimitNoBuffer || HEX_ZERO;
119119
const gasPrice = transactionMeta?.txParams?.gasPrice || HEX_ZERO;
120120

121121
const maxFee = useMemo(() => {
122122
return multiplyHexes(
123123
supportsEIP1559 ? (decimalToHex(maxFeePerGas) as Hex) : (gasPrice as Hex),
124-
gasLimit as Hex,
124+
gasLimitNoBuffer as Hex,
125125
);
126-
}, [supportsEIP1559, maxFeePerGas, gasLimit, gasPrice]);
126+
}, [supportsEIP1559, maxFeePerGas, gasLimitNoBuffer, gasPrice]);
127127

128128
const {
129129
currentCurrencyFee: maxFeeFiat,
@@ -157,12 +157,9 @@ export function useFeeCalculations(transactionMeta: TransactionMeta) {
157157
minimumFeePerGas = decimalToHex(maxFeePerGas);
158158
}
159159

160-
// We want to pick gasLimitNoBuffer to show minimum network fee
161-
const minimumGasLimit = transactionMeta?.gasLimitNoBuffer || gasLimit;
162-
163160
const estimatedFee = multiplyHexes(
164161
supportsEIP1559 ? (minimumFeePerGas as Hex) : (gasPrice as Hex),
165-
minimumGasLimit as Hex,
162+
gasLimitNoBuffer as Hex,
166163
);
167164

168165
return getFeesFromHex(estimatedFee);

0 commit comments

Comments
 (0)