-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa4757c
commit 436d621
Showing
2 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IGetGasFeeResult> => { | ||
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; | ||
}; | ||
}; | ||
}; |
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