Skip to content

Commit 8314236

Browse files
committedAug 16, 2022
Include current baseFee in feeData for easier custom fee calculation.

File tree

1 file changed

+4
-2
lines changed
  • packages/abstract-provider/src.ts

1 file changed

+4
-2
lines changed
 

‎packages/abstract-provider/src.ts/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export interface TransactionReceipt {
124124
};
125125

126126
export interface FeeData {
127+
lastBaseFeePerGas: null | BigNumber;
127128
maxFeePerGas: null | BigNumber;
128129
maxPriorityFeePerGas: null | BigNumber;
129130
gasPrice: null | BigNumber;
@@ -241,17 +242,18 @@ export abstract class Provider implements OnceBlockable {
241242
})
242243
});
243244

244-
let maxFeePerGas = null, maxPriorityFeePerGas = null;
245+
let lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null;
245246

246247
if (block && block.baseFeePerGas) {
247248
// We may want to compute this more accurately in the future,
248249
// using the formula "check if the base fee is correct".
249250
// See: https://eips.ethereum.org/EIPS/eip-1559
251+
lastBaseFeePerGas = block.baseFeePerGas;
250252
maxPriorityFeePerGas = BigNumber.from("1500000000");
251253
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
252254
}
253255

254-
return { maxFeePerGas, maxPriorityFeePerGas, gasPrice };
256+
return { lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas, gasPrice };
255257
}
256258

257259
// Account

0 commit comments

Comments
 (0)
Please sign in to comment.