diff --git a/__tests__/hardhat-utils.js b/__tests__/hardhat-utils.js index 9f5055c7ae5..0ba150ed7e2 100644 --- a/__tests__/hardhat-utils.js +++ b/__tests__/hardhat-utils.js @@ -43,7 +43,11 @@ export const setupDAI = async () => { FIXTURE_WEB3_ADDRESS, '100000000000000000000' ); - const sent = await signer.sendTransaction(tx); + const sent = await signer.sendTransaction({ + ...tx, + maxFeePerGas: '0xe8990a4600', + maxPriorityFeePerGas: '0xe8990a4600' + }); await sent.wait(); diff --git a/src/services/ApiService/Gas/eip1559.test.ts b/src/services/ApiService/Gas/eip1559.test.ts index a33254fd88d..6862924e4e4 100644 --- a/src/services/ApiService/Gas/eip1559.test.ts +++ b/src/services/ApiService/Gas/eip1559.test.ts @@ -88,6 +88,20 @@ describe('estimateFees', () => { }); }); + it('uses 1.6 multiplier for base if above 40 gwei', async () => { + (mockProvider.getLatestBlock as jest.MockedFunction< + typeof mockProvider.getLatestBlock + >).mockResolvedValueOnce({ ...block, baseFeePerGas: BigNumber.from('0x11766ffa76') }); + (mockProvider.getFeeHistory as jest.MockedFunction< + typeof mockProvider.getFeeHistory + >).mockResolvedValueOnce(feeHistory); + return expect(estimateFees(mockProvider)).resolves.toStrictEqual({ + baseFee: bigify('75001494134'), + maxFeePerGas: bigify('120000000000'), + maxPriorityFeePerGas: bigify('3000000000') + }); + }); + it('uses 1.4 multiplier for base if above 100 gwei', async () => { (mockProvider.getLatestBlock as jest.MockedFunction< typeof mockProvider.getLatestBlock diff --git a/src/services/ApiService/Gas/eip1559.ts b/src/services/ApiService/Gas/eip1559.ts index d564dd9162c..7d1bad37800 100644 --- a/src/services/ApiService/Gas/eip1559.ts +++ b/src/services/ApiService/Gas/eip1559.ts @@ -21,7 +21,7 @@ export const FALLBACK_ESTIMATE = { const PRIORITY_FEE_INCREASE_BOUNDARY = 200; // % const roundToWholeGwei = (wei: BigNumber) => { - const gwei = bigify(fromWei(wei, 'gwei')); + const gwei = bigify(fromWei(wei.integerValue(), 'gwei')); const rounded = gwei.integerValue(BigNumber.ROUND_HALF_UP); return bigify(toWei(rounded.toString(10), getDecimalFromEtherUnit('gwei'))); };