gasnow gas price orace

This commit is contained in:
Alexey 2020-10-19 16:08:19 +03:00
parent 092d863bd2
commit a2a4e67845
4 changed files with 21 additions and 2 deletions

@ -8,10 +8,11 @@ Current offchain list:
- https://gas-oracle.zoltu.io/
- https://www.etherchain.org/api/gasPriceOracle
- https://gasprice.poa.network/
- https://www.gasnow.org/api/v3/gas/price
Current onchain list:
- [chainlink](https://etherscan.io/address/0xA417221ef64b1549575C977764E651c9FAB50141)
- [chainlink](https://etherscan.io/address/0x169e633a2d1e6c10dd91238ba11c4a708dfef37c#readContract)
## Installation

@ -8,6 +8,7 @@ const ethgasstation: OffChainOracle = {
standardPropertyName: 'average',
lowPropertyName: 'safeLow',
denominator: 10,
additionalDataProperty: null,
};
const zoltu: OffChainOracle = {
@ -18,6 +19,7 @@ const zoltu: OffChainOracle = {
standardPropertyName: 'percentile_60',
lowPropertyName: 'percentile_30',
denominator: 1,
additionalDataProperty: null,
};
const etherchain: OffChainOracle = {
@ -28,6 +30,7 @@ const etherchain: OffChainOracle = {
standardPropertyName: 'standard',
lowPropertyName: 'safeLow',
denominator: 1,
additionalDataProperty: null,
};
const poa: OffChainOracle = {
@ -38,6 +41,18 @@ const poa: OffChainOracle = {
standardPropertyName: 'standard',
lowPropertyName: 'slow',
denominator: 1,
additionalDataProperty: null,
};
const gasNow: OffChainOracle = {
name: 'gasNow',
url: 'https://www.gasnow.org/api/v3/gas/price?utm_source=gas-price-oracle',
instantPropertyName: 'rapid',
fastPropertyName: 'fast',
standardPropertyName: 'standard',
lowPropertyName: 'slow',
denominator: 1e9,
additionalDataProperty: 'data',
};
const chainlink: OnChainOracle = {
@ -49,6 +64,7 @@ const chainlink: OnChainOracle = {
export const offChainOracles: { [key: string]: OffChainOracle } = {
ethgasstation,
gasNow,
poa,
etherchain,
zoltu,

@ -27,10 +27,11 @@ export class GasPriceOracle {
standardPropertyName,
lowPropertyName,
denominator,
additionalDataProperty,
} = oracle;
const response = await axios.get(url, { timeout: this.configuration.timeout });
if (response.status === 200) {
const gas = response.data;
const gas = additionalDataProperty ? response.data[additionalDataProperty] : response.data;
if (Number(gas[fastPropertyName]) === 0) {
throw new Error(`${name} oracle provides corrupted values`);
}

@ -6,6 +6,7 @@ export type OffChainOracle = {
standardPropertyName: string;
lowPropertyName: string;
denominator: number;
additionalDataProperty: string | null;
};
export type OnChainOracle = {