ethers.io's way to calculate maxFeePerGas in getFeeData(), what's the idea behind it? #3601
-
Hi, what is the motivation behind the formula used to calculate maxFeePerGas in getFeeData() method of ethers.js? I see on this line that it simply multiplies the base fee by 2 and then adds the miner's tip (maxPriorityFeePerGas). Why multiply by 2? Isn't there a mechanism to predict the baseFee given in EiP-1559 ? baseFee cannot change itself by more than 12.5% or something like that. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
That is the recommends best practice. During times of congestion, it can increase by 12.5% per block. There is no guarantee you will be included in the next block, so the 2x factor gives some wiggle room. Its only goal is to ensure your tx is included in a “reasonable amount of time”. Since the actual fee charged will be protocol-defined by the block’s base fee, you won’t be overcharged. If there is no congestion, the 2x is moot, since you pay the base fee of that block you queried. If it is coming out of a period of congestion, you will pay less. There may be specific instances where you want finer grained control over the fee, which is why overrides are available as needed, but for the most part the priority it get a tx included. :) |
Beta Was this translation helpful? Give feedback.
That is the recommends best practice.
During times of congestion, it can increase by 12.5% per block. There is no guarantee you will be included in the next block, so the 2x factor gives some wiggle room.
Its only goal is to ensure your tx is included in a “reasonable amount of time”.
Since the actual fee charged will be protocol-defined by the block’s base fee, you won’t be overcharged. If there is no congestion, the 2x is moot, since you pay the base fee of that block you queried. If it is coming out of a period of congestion, you will pay less.
There may be specific instances where you want finer grained control over the fee, which is why overrides are available as needed, but for the …