3 Commits

Author SHA1 Message Date
Danil Kovtonyuk
89a69519b2 fix: test 2021-08-17 17:14:50 +10:00
Danil Kovtonyuk
3fce50efbb fix: constructor 2021-08-17 17:04:01 +10:00
Danil Kovtonyuk
9b0c229ace add polygon 2021-06-15 13:26:02 +03:00
6 changed files with 51 additions and 15 deletions

View File

@@ -24,6 +24,12 @@ Current offchain list:
- https://bscgas.info/
### Polygon (Matic) Network
Current offchain list:
- https://gasstation-mainnet.matic.network/
## Installation
`npm i gas-price-oracle`

View File

@@ -1,6 +1,6 @@
{
"name": "gas-price-oracle",
"version": "0.3.2",
"version": "0.3.4",
"description": "Gas Price Oracle library for Ethereum dApps.",
"main": "lib/index.js",
"homepage": "https://github.com/peppersec/gas-price-oracle",

View File

@@ -1,13 +1,16 @@
import { NetworkConfig } from '../types';
import mainnetOracles from './mainnet';
import binanceOracles from './binance';
import polygonOracles from './polygon';
export enum ChainId {
MAINNET = 1,
BINANCE = 56,
POLYGON = 137,
}
export const networks: NetworkConfig = {
[ChainId.MAINNET]: mainnetOracles,
[ChainId.BINANCE]: binanceOracles,
[ChainId.POLYGON]: polygonOracles,
};

View File

@@ -11,16 +11,16 @@ 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 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',
@@ -79,7 +79,7 @@ export const offChainOracles: OffChainOracles = {
gasNow,
poa,
etherchain,
zoltu,
// zoltu,
};
export const onChainOracles: OnChainOracles = {

23
src/config/polygon.ts Normal file
View File

@@ -0,0 +1,23 @@
import { OffChainOracle, OffChainOracles, OnChainOracles } from '../types';
const maticGasStation: OffChainOracle = {
name: 'maticGasStation',
url: 'https://gasstation-mainnet.matic.network',
instantPropertyName: 'fastest',
fastPropertyName: 'fast',
standardPropertyName: 'standard',
lowPropertyName: 'safeLow',
denominator: 1,
additionalDataProperty: null,
};
export const offChainOracles: OffChainOracles = {
maticGasStation,
};
export const onChainOracles: OnChainOracles = {};
export default {
offChainOracles,
onChainOracles,
};

View File

@@ -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> {