Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Next Next commit
allowing to specify percentage-based factors (like 1.125 for 112.5%)
  • Loading branch information
I744506 committed Oct 16, 2024
commit 00fd0b176ddd54a4e1bfc473ed9612d595614187
5 changes: 3 additions & 2 deletions packages/web3-eth/src/web3_eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
* ```
*/
public async calculateFeeData(
baseFeePerGasFactor = BigInt(2),
baseFeePerGasFactor: number = 2,
alternativeMaxPriorityFeePerGas = ethUnitMap.Gwei,
): Promise<FeeData> {
const block = await this.getBlock<{ number: FMT_NUMBER.BIGINT; bytes: FMT_BYTES.HEX }>(
Expand Down Expand Up @@ -348,7 +348,8 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
// and we multiply the `baseFeePerGas` by `baseFeePerGasFactor`, to allow
// trying to include the transaction in the next few blocks even if the
// baseFeePerGas is increasing fast
maxFeePerGas = baseFeePerGas * baseFeePerGasFactor + maxPriorityFeePerGas;
const baseFeeMultiplier = BigInt(Math.floor(baseFeePerGasFactor * 1000)) / BigInt(1000);
maxFeePerGas = baseFeePerGas * baseFeeMultiplier + maxPriorityFeePerGas;
}

return { gasPrice, maxFeePerGas, maxPriorityFeePerGas, baseFeePerGas };
Expand Down