diff --git a/packages/params/src/gas-price-oracles/oracles/ancient8.ts b/packages/params/src/gas-price-oracles/oracles/ancient8.ts new file mode 100644 index 00000000..05f5b650 --- /dev/null +++ b/packages/params/src/gas-price-oracles/oracles/ancient8.ts @@ -0,0 +1,55 @@ +import { fetchJson, hexValue } from "ethers/lib/utils"; +import { BigNumber } from "ethers"; +import { parseGwei } from "./utils"; +import { IGetGasFeeResult, IOracle } from "./interfaces"; + +export const getAncient8GasFee: IOracle = + async (): Promise => { + const { gas_prices }: Ancient8Response = await fetchJson({ + url: "https://scan.ancient8.gg/api/v2/stats", + headers: { + "updated-gas-oracle": "true", + }, + }); + const maxPriorityFeePerGas = hexValue( + BigNumber.from(gas_prices.fast.priority_fee_wei) + ); + const maxFeePerGas = parseGwei(gas_prices.fast.priority_fee); + return { + maxPriorityFeePerGas: maxPriorityFeePerGas, + gasPrice: maxFeePerGas, + maxFeePerGas: maxFeePerGas, + }; + }; + +type Ancient8Response = { + gas_prices: { + average: { + base_fee: number; + fiat_price: string; + price: number; + priority_fee: number; + priority_fee_wei: string; + time: number; + wei: string; + }; + fast: { + base_fee: number; + fiat_price: string; + price: number; + priority_fee: number; + priority_fee_wei: string; + time: number; + wei: string; + }; + slow: { + base_fee: number; + fiat_price: string; + price: number; + priority_fee: number; + priority_fee_wei: string; + time: number; + wei: string; + }; + }; +}; diff --git a/packages/params/src/gas-price-oracles/oracles/index.ts b/packages/params/src/gas-price-oracles/oracles/index.ts index 17641f91..46a0b0f9 100644 --- a/packages/params/src/gas-price-oracles/oracles/index.ts +++ b/packages/params/src/gas-price-oracles/oracles/index.ts @@ -8,6 +8,7 @@ import { getOptimismGasFee } from "./optimism"; import { IOracle } from "./interfaces"; import { getMantleGasFee } from "./mantle"; import { getBaseGasFee } from "./base"; +import { getAncient8GasFee } from "./ancient8"; export const oracles: { [chainId: number]: IOracle | undefined; @@ -19,4 +20,5 @@ export const oracles: { 5000: getMantleGasFee, 5001: getMantleGasFee, 8453: getBaseGasFee, + 888888888: getAncient8GasFee, };