-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: minimum fee of 0.1 gwei on optimism
- Loading branch information
Showing
3 changed files
with
99 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import chains from '@/config/chains' | ||
import type { EstimatedGasPrice } from '@/hooks/useGasPrice' | ||
import { BigNumber } from 'ethers' | ||
|
||
const OPTIMISM_MINIMUM_BASE_FEE_WEI = BigNumber.from(100000000) | ||
|
||
export const adjustGasEstimationForChain = (gas: EstimatedGasPrice, chainId: string | undefined) => { | ||
if (chainId === chains.oeth) { | ||
// On Optimism we lower bound the base fee to 0.1 gwei because the base fee can spike quite fast | ||
return { | ||
...gas, | ||
maxFeePerGas: gas.maxFeePerGas?.lt(OPTIMISM_MINIMUM_BASE_FEE_WEI) | ||
? OPTIMISM_MINIMUM_BASE_FEE_WEI | ||
: gas.maxFeePerGas, | ||
} | ||
} | ||
|
||
return gas | ||
} |