-
Ethers Version5.5.3 Search Termsarbitrum, maxFeePerGas, maxPriorityFeePerGas Describe the ProblemI'm trying to make a simple swap on arbitrum between 2 tokens, and for that I detect automatically the maxFeePerGas and maxPriorityFeePerGas values to use in the transaction thanks to the ethers's function At the time of this writing, arbitrum maxFeePer gas is 0.1, but the ethers function return a value of 2.5. This increase the cost of the transaction by 100. Code Snippetconst ethers = require('ethers');
const test = async () => {
let provider = new ethers.providers.JsonRpcProvider("https://arb1.arbitrum.io/rpc");
let feeData = await provider.getFeeData();
console.log(ethers.utils.formatUnits(feeData.maxFeePerGas, "wei")); // 2.7 instead of 0.2
console.log(ethers.utils.formatUnits(feeData.maxPriorityFeePerGas, "wei")); // 2.5 instead of 0
}
test().then().catch(e => console.log(e)); Contract ABINo response ErrorsNo response EnvironmentAltcoin - Please specify (e.g. Polygon) Environment (Other)Arbitrum |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
It seems that this is due to these lines, since maxPriorityFeePerGas is equal to 0 on Arbitrum and some others blockchains supporting eip-1559 : ethers.js/packages/abstract-provider/src.ts/index.ts Lines 249 to 250 in 0578a88 Anyone have an idea to improve that ? |
Beta Was this translation helpful? Give feedback.
-
You can either subclass your provider (overriding the getFeeData to adjust for your desired priorityFee) or pass in an overriding value on each call. There is no automatic way to get this, so the value is tuned for Ethereum. In v6, each Network has the opportunity to select their own default value via a NetworkPlugin. Make sense? :) |
Beta Was this translation helpful? Give feedback.
-
Hey did you manage to calculate fees for arbitrum? I'm trying by multiplying |
Beta Was this translation helpful? Give feedback.
You can either subclass your provider (overriding the getFeeData to adjust for your desired priorityFee) or pass in an overriding value on each call.
There is no automatic way to get this, so the value is tuned for Ethereum.
In v6, each Network has the opportunity to select their own default value via a NetworkPlugin.
Make sense? :)