Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5036c65643 | ||
|
|
89a69519b2 | ||
|
|
3fce50efbb |
@@ -9,7 +9,6 @@ A library that has a collection of onchain and offchain gas price oracle URLs
|
||||
Current offchain list:
|
||||
|
||||
- https://ethgasstation.info/json/ethgasAPI.json
|
||||
- https://gas-oracle.zoltu.io/
|
||||
- https://www.etherchain.org/api/gasPriceOracle
|
||||
- https://gasprice.poa.network/
|
||||
- https://www.gasnow.org/api/v3/gas/price
|
||||
@@ -24,6 +23,12 @@ Current offchain list:
|
||||
|
||||
- https://bscgas.info/
|
||||
|
||||
### xDAI Chain
|
||||
|
||||
Current offchain list:
|
||||
|
||||
- https://www.xdaichain.com/for-developers/developer-resources/gas-price-oracle
|
||||
|
||||
### Polygon (Matic) Network
|
||||
|
||||
Current offchain list:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gas-price-oracle",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"description": "Gas Price Oracle library for Ethereum dApps.",
|
||||
"main": "lib/index.js",
|
||||
"homepage": "https://github.com/peppersec/gas-price-oracle",
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import { NetworkConfig } from '../types';
|
||||
|
||||
import mainnetOracles from './mainnet';
|
||||
import binanceOracles from './binance';
|
||||
import xdaiOracles from './xdai';
|
||||
import polygonOracles from './polygon';
|
||||
|
||||
export enum ChainId {
|
||||
MAINNET = 1,
|
||||
BINANCE = 56,
|
||||
XDAI = 100,
|
||||
POLYGON = 137,
|
||||
}
|
||||
|
||||
export const networks: NetworkConfig = {
|
||||
[ChainId.MAINNET]: mainnetOracles,
|
||||
[ChainId.BINANCE]: binanceOracles,
|
||||
[ChainId.XDAI]: xdaiOracles,
|
||||
[ChainId.POLYGON]: polygonOracles,
|
||||
};
|
||||
|
||||
@@ -11,17 +11,6 @@ const ethgasstation: OffChainOracle = {
|
||||
additionalDataProperty: null,
|
||||
};
|
||||
|
||||
const zoltu: OffChainOracle = {
|
||||
name: 'zoltu',
|
||||
url: 'https://gas-oracle.zoltu.io/',
|
||||
instantPropertyName: 'percentile_99',
|
||||
fastPropertyName: 'percentile_90',
|
||||
standardPropertyName: 'percentile_60',
|
||||
lowPropertyName: 'percentile_30',
|
||||
denominator: 1,
|
||||
additionalDataProperty: null,
|
||||
};
|
||||
|
||||
const etherchain: OffChainOracle = {
|
||||
name: 'etherchain',
|
||||
url: 'https://www.etherchain.org/api/gasPriceOracle',
|
||||
@@ -79,7 +68,6 @@ export const offChainOracles: OffChainOracles = {
|
||||
gasNow,
|
||||
poa,
|
||||
etherchain,
|
||||
zoltu,
|
||||
};
|
||||
|
||||
export const onChainOracles: OnChainOracles = {
|
||||
|
||||
23
src/config/xdai.ts
Normal file
23
src/config/xdai.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { OffChainOracle, OffChainOracles, OnChainOracles } from '../types';
|
||||
|
||||
const blockscout: OffChainOracle = {
|
||||
name: 'blockscout',
|
||||
url: 'https://blockscout.com/xdai/mainnet/api/v1/gas-price-oracle',
|
||||
instantPropertyName: 'fast',
|
||||
fastPropertyName: 'average',
|
||||
standardPropertyName: 'slow',
|
||||
lowPropertyName: 'slow',
|
||||
denominator: 1,
|
||||
additionalDataProperty: null,
|
||||
};
|
||||
|
||||
export const offChainOracles: OffChainOracles = {
|
||||
blockscout,
|
||||
};
|
||||
|
||||
export const onChainOracles: OnChainOracles = {};
|
||||
|
||||
export default {
|
||||
offChainOracles,
|
||||
onChainOracles,
|
||||
};
|
||||
10
src/index.ts
10
src/index.ts
@@ -34,9 +34,13 @@ export class GasPriceOracle {
|
||||
Object.assign(this.configuration, options);
|
||||
}
|
||||
|
||||
const { offChainOracles, onChainOracles } = networks[this.configuration.chainId];
|
||||
this.offChainOracles = { ...offChainOracles };
|
||||
this.onChainOracles = { ...onChainOracles };
|
||||
const network = networks[this.configuration.chainId];
|
||||
|
||||
if (network) {
|
||||
const { offChainOracles, onChainOracles } = network;
|
||||
this.offChainOracles = { ...offChainOracles };
|
||||
this.onChainOracles = { ...onChainOracles };
|
||||
}
|
||||
}
|
||||
|
||||
async askOracle(oracle: OffChainOracle): Promise<GasPrice> {
|
||||
|
||||
Reference in New Issue
Block a user