From 8314236143a300ae81c1dcc27a7a36640df22061 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Tue, 16 Aug 2022 16:02:04 -0400 Subject: [PATCH] Include current baseFee in feeData for easier custom fee calculation. --- packages/abstract-provider/src.ts/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/abstract-provider/src.ts/index.ts b/packages/abstract-provider/src.ts/index.ts index 6e2472fdb0..d56958a6a5 100644 --- a/packages/abstract-provider/src.ts/index.ts +++ b/packages/abstract-provider/src.ts/index.ts @@ -124,6 +124,7 @@ export interface TransactionReceipt { }; export interface FeeData { + lastBaseFeePerGas: null | BigNumber; maxFeePerGas: null | BigNumber; maxPriorityFeePerGas: null | BigNumber; gasPrice: null | BigNumber; @@ -241,17 +242,18 @@ export abstract class Provider implements OnceBlockable { }) }); - let maxFeePerGas = null, maxPriorityFeePerGas = null; + let lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null; if (block && block.baseFeePerGas) { // We may want to compute this more accurately in the future, // using the formula "check if the base fee is correct". // See: https://eips.ethereum.org/EIPS/eip-1559 + lastBaseFeePerGas = block.baseFeePerGas; maxPriorityFeePerGas = BigNumber.from("1500000000"); maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas); } - return { maxFeePerGas, maxPriorityFeePerGas, gasPrice }; + return { lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas, gasPrice }; } // Account