Have a code where gas price data provided via gasstation api. Now it works on polygon. Wanted to start this on Arbitrum and Optimism, but can't find any api with gas price. As i understand, the gas on Arbitrum and Optimism has 2 parts, l1 and l2. If anyone knows how to solve this, please help
import got from "got"
import { BigNumber, ethers } from "ethers";
import { CurrencyAmount } from "@uniswap/sdk-core";
import { Pool } from "@uniswap/v3-sdk";
import { WETH_ADDRESS } from "./constants";
interface GasPriceData {
fast:{
maxPriorityFee: number;
maxFee: number;
}
}
export async function getmaxFeePerGas(): Promise<BigNumber> {
const gasPriceData: GasPriceData = await got("https://gasstation-mainnet.matic.network/v2").json();
return ethers.utils.parseUnits(gasPriceData.fast.maxFee.toFixed(9).toString(), 9);
}
export async function getmaxPriorityFee(): Promise<BigNumber> {
const gasPriceData: GasPriceData = await got("https://gasstation-mainnet.matic.network/v2").json();
return ethers.utils.parseUnits(gasPriceData.fast.maxPriorityFee.toFixed(9).toString(), 9);
}