diff --git a/README.md b/README.md index b299349..6b96a3e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/config.ts b/src/config.ts index ea2c39d..2c3d7c4 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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, diff --git a/src/index.ts b/src/index.ts index 85d4e4a..398dacc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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`); } diff --git a/src/types.ts b/src/types.ts index 080b918..b3442f3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -6,6 +6,7 @@ export type OffChainOracle = { standardPropertyName: string; lowPropertyName: string; denominator: number; + additionalDataProperty: string | null; }; export type OnChainOracle = {