Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85ca7000bc | ||
|
|
d65b3dfe6c | ||
|
|
be905f2b71 |
12
README.md
12
README.md
@@ -34,18 +34,6 @@ Current offchain list:
|
||||
|
||||
- https://gasstation-mainnet.matic.network/
|
||||
|
||||
### Arbitrum One
|
||||
|
||||
Current offchain list:
|
||||
|
||||
- https://ztake.org/
|
||||
|
||||
### Avalanche Mainnet
|
||||
|
||||
Current offchain list:
|
||||
|
||||
- https://ztake.org/
|
||||
|
||||
## Installation
|
||||
|
||||
`npm i gas-price-oracle`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gas-price-oracle",
|
||||
"version": "0.4.4",
|
||||
"version": "0.4.7",
|
||||
"description": "Gas Price Oracle library for Ethereum dApps.",
|
||||
"main": "lib/index.js",
|
||||
"homepage": "https://github.com/peppersec/gas-price-oracle",
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import { OffChainOracle, OffChainOracles, OnChainOracles } from '../types';
|
||||
|
||||
const ztake: OffChainOracle = {
|
||||
name: 'ztake',
|
||||
url: 'https://blockchains.ztake.org/api/h6WnmwNqw9CAJHzej5W4gD6LZ9n7v8EK/gasprice/arb/',
|
||||
instantPropertyName: 'percentile_90',
|
||||
fastPropertyName: 'percentile_80',
|
||||
standardPropertyName: 'percentile_60',
|
||||
lowPropertyName: 'percentile_30',
|
||||
denominator: 1,
|
||||
additionalDataProperty: null,
|
||||
};
|
||||
|
||||
export const offChainOracles: OffChainOracles = {
|
||||
ztake,
|
||||
};
|
||||
|
||||
export const onChainOracles: OnChainOracles = {};
|
||||
|
||||
export default {
|
||||
offChainOracles,
|
||||
onChainOracles,
|
||||
};
|
||||
@@ -1,23 +0,0 @@
|
||||
import { OffChainOracle, OffChainOracles, OnChainOracles } from '../types';
|
||||
|
||||
const ztake: OffChainOracle = {
|
||||
name: 'ztake',
|
||||
url: 'https://blockchains.ztake.org/api/h6WnmwNqw9CAJHzej5W4gD6LZ9n7v8EK/gasprice/avax/',
|
||||
instantPropertyName: 'percentile_90',
|
||||
fastPropertyName: 'percentile_80',
|
||||
standardPropertyName: 'percentile_60',
|
||||
lowPropertyName: 'percentile_30',
|
||||
denominator: 1,
|
||||
additionalDataProperty: null,
|
||||
};
|
||||
|
||||
export const offChainOracles: OffChainOracles = {
|
||||
ztake,
|
||||
};
|
||||
|
||||
export const onChainOracles: OnChainOracles = {};
|
||||
|
||||
export default {
|
||||
offChainOracles,
|
||||
onChainOracles,
|
||||
};
|
||||
@@ -4,16 +4,12 @@ import mainnetOracles from './mainnet';
|
||||
import bscOracles from './bsc';
|
||||
import xdaiOracles from './xdai';
|
||||
import polygonOracles from './polygon';
|
||||
import arbitrumOracles from './arbitrum';
|
||||
import avalancheOracles from './avalanche';
|
||||
|
||||
export enum ChainId {
|
||||
MAINNET = 1,
|
||||
BSC = 56,
|
||||
XDAI = 100,
|
||||
POLYGON = 137,
|
||||
ARBITRUM = 42161,
|
||||
AVALANCHE = 43114,
|
||||
}
|
||||
|
||||
export const NETWORKS: NetworkConfig = {
|
||||
@@ -21,6 +17,4 @@ export const NETWORKS: NetworkConfig = {
|
||||
[ChainId.BSC]: bscOracles,
|
||||
[ChainId.XDAI]: xdaiOracles,
|
||||
[ChainId.POLYGON]: polygonOracles,
|
||||
[ChainId.ARBITRUM]: arbitrumOracles,
|
||||
[ChainId.AVALANCHE]: avalancheOracles,
|
||||
};
|
||||
|
||||
@@ -18,31 +18,31 @@ const etherchain: OffChainOracle = {
|
||||
fastPropertyName: 'fast',
|
||||
standardPropertyName: 'standard',
|
||||
lowPropertyName: 'slow',
|
||||
denominator: 1,
|
||||
denominator: 1e9,
|
||||
additionalDataProperty: 'data',
|
||||
};
|
||||
|
||||
const blockscout: OffChainOracle = {
|
||||
name: 'blockscout',
|
||||
url: 'https://blockscout.com/eth/mainnet/api/v1/gas-price-oracle',
|
||||
instantPropertyName: 'fast',
|
||||
fastPropertyName: 'average',
|
||||
standardPropertyName: 'slow',
|
||||
lowPropertyName: 'slow',
|
||||
denominator: 1,
|
||||
additionalDataProperty: null,
|
||||
};
|
||||
// const blockscout: OffChainOracle = {
|
||||
// name: 'blockscout',
|
||||
// url: 'https://blockscout.com/eth/mainnet/api/v1/gas-price-oracle',
|
||||
// instantPropertyName: 'fast',
|
||||
// fastPropertyName: 'average',
|
||||
// standardPropertyName: 'slow',
|
||||
// lowPropertyName: 'slow',
|
||||
// denominator: 1,
|
||||
// additionalDataProperty: null,
|
||||
// };
|
||||
|
||||
const anyblock: OffChainOracle = {
|
||||
name: 'anyblock',
|
||||
url: 'https://api.anyblock.tools/ethereum/latest-minimum-gasprice',
|
||||
instantPropertyName: 'instant',
|
||||
fastPropertyName: 'fast',
|
||||
standardPropertyName: 'standard',
|
||||
lowPropertyName: 'slow',
|
||||
denominator: 1,
|
||||
additionalDataProperty: null,
|
||||
};
|
||||
// const anyblock: OffChainOracle = {
|
||||
// name: 'anyblock',
|
||||
// url: 'https://api.anyblock.tools/ethereum/latest-minimum-gasprice',
|
||||
// instantPropertyName: 'instant',
|
||||
// fastPropertyName: 'fast',
|
||||
// standardPropertyName: 'standard',
|
||||
// lowPropertyName: 'slow',
|
||||
// denominator: 1,
|
||||
// additionalDataProperty: null,
|
||||
// };
|
||||
|
||||
const chainlink: OnChainOracle = {
|
||||
name: 'chainlink',
|
||||
@@ -53,8 +53,8 @@ const chainlink: OnChainOracle = {
|
||||
|
||||
export const offChainOracles: OffChainOracles = {
|
||||
ethgasstation,
|
||||
anyblock,
|
||||
blockscout,
|
||||
// anyblock,
|
||||
// blockscout,
|
||||
etherchain,
|
||||
};
|
||||
|
||||
|
||||
@@ -285,12 +285,7 @@ describe('normalize result values', function () {
|
||||
|
||||
it('rpc fallback should be normalized', async function () {
|
||||
const { GasPriceOracle } = require('../src/index');
|
||||
oracle = new GasPriceOracle({ chainId: ChainId.ARBITRUM, defaultRpc: 'https://arb1.arbitrum.io/rpc' });
|
||||
|
||||
const { onChainOracles, offChainOracles } = oracle;
|
||||
|
||||
Object.keys(onChainOracles).forEach(chainOracle => oracle.removeOnChainOracle(chainOracle));
|
||||
Object.keys(offChainOracles).forEach(chainOracle => oracle.removeOffChainOracle(chainOracle));
|
||||
oracle = new GasPriceOracle({ chainId: 42161, defaultRpc: 'https://arb1.arbitrum.io/rpc' });
|
||||
|
||||
const gas = await oracle.gasPrices();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user