Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
fix: specify ethgasstation url (#273)
Browse files Browse the repository at this point in the history
* fix: specify ethgasstation url

* fix: update ALL usages of protocol fee utils
  • Loading branch information
dekz authored Jul 1, 2020
1 parent 6d0874f commit 16eabc0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
},
"dependencies": {
"@0x/assert": "^3.0.4",
"@0x/asset-swapper": "0xProject/gitpkg-registry#0x-asset-swapper-v4.5.0-a7cc1637d",
"@0x/asset-swapper": "0xProject/gitpkg-registry#0x-asset-swapper-v4.5.0-9a8139ce9",
"@0x/connect": "^6.0.4",
"@0x/contract-addresses": "0xProject/gitpkg-registry#0x-contract-addresses-v4.9.0-f14b6f2ba",
"@0x/contract-wrappers": "0xProject/gitpkg-registry#0x-contract-wrappers-v13.6.3-f14b6f2ba",
Expand Down
6 changes: 6 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as _ from 'lodash';
import * as validateUUID from 'uuid-validate';

import {
DEFAULT_ETH_GAS_STATION_API_URL,
DEFAULT_EXPECTED_MINED_SEC,
DEFAULT_FALLBACK_SLIPPAGE_PERCENTAGE,
DEFAULT_LOCAL_POSTGRES_URI,
Expand Down Expand Up @@ -231,6 +232,11 @@ export const PROMETHEUS_PORT: number = _.isEmpty(process.env.PROMETHEUS_PORT)
? 8080
: assertEnvVarType('PROMETHEUS_PORT', process.env.PROMETHEUS_PORT, EnvVarType.Port);

// Eth Gas Station URL
export const ETH_GAS_STATION_API_URL: string = _.isEmpty(process.env.ETH_GAS_STATION_API_URL)
? DEFAULT_ETH_GAS_STATION_API_URL
: assertEnvVarType('ETH_GAS_STATION_API_URL', process.env.ETH_GAS_STATION_API_URL, EnvVarType.Url);

// Max number of entities per page
export const MAX_PER_PAGE = 1000;
// Default ERC20 token precision
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const SRA_DOCS_URL = 'https://0x.org/docs/api#sra';
export const META_TRANSACTION_DOCS_URL = 'https://0x.org/docs/api#meta_transaction';

// Meta Transactions
export const ETH_GAS_STATION_API_URL = 'https://ethgasstation.api.0x.org/api/ethgasAPI.json';
export const DEFAULT_ETH_GAS_STATION_API_URL = 'https://ethgasstation.api.0x.org/api/ethgasAPI.json';
export const UNSTICKING_TRANSACTION_GAS_MULTIPLIER = 1.1;
export const ETH_TRANSFER_GAS_LIMIT = 21000;
export const TX_HASH_RESPONSE_WAIT_TIME_MS = ONE_SECOND_MS * 100;
Expand Down
2 changes: 2 additions & 0 deletions src/services/meta_transaction_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Connection, Repository } from 'typeorm';
import {
ASSET_SWAPPER_MARKET_ORDERS_OPTS,
CHAIN_ID,
ETH_GAS_STATION_API_URL,
LIQUIDITY_POOL_REGISTRY_ADDRESS,
META_TXN_RELAY_EXPECTED_MINED_SEC,
META_TXN_SUBMIT_WHITELISTED_API_KEYS,
Expand Down Expand Up @@ -77,6 +78,7 @@ export class MetaTransactionService {
warningLogger: logger.warn.bind(logger),
infoLogger: logger.info.bind(logger),
},
ethGasStationUrl: ETH_GAS_STATION_API_URL,
permittedOrderFeeTypes: new Set([OrderPrunerPermittedFeeTypes.NoFees]),
};
this._swapQuoter = new SwapQuoter(this._provider, orderbook, swapQuoterOpts);
Expand Down
7 changes: 6 additions & 1 deletion src/services/swap_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as _ from 'lodash';
import {
ASSET_SWAPPER_MARKET_ORDERS_OPTS,
CHAIN_ID,
ETH_GAS_STATION_API_URL,
LIQUIDITY_POOL_REGISTRY_ADDRESS,
RFQT_API_KEY_WHITELIST,
RFQT_MAKER_ASSET_OFFERINGS,
Expand Down Expand Up @@ -70,6 +71,7 @@ export class SwapService {
warningLogger: logger.warn.bind(logger),
infoLogger: logger.info.bind(logger),
},
ethGasStationUrl: ETH_GAS_STATION_API_URL,
permittedOrderFeeTypes: new Set([OrderPrunerPermittedFeeTypes.NoFees]),
};
this._swapQuoter = new SwapQuoter(this._provider, orderbook, swapQuoterOpts);
Expand All @@ -82,7 +84,10 @@ export class SwapService {
getTokenMetadataIfExists('GST2', CHAIN_ID).tokenAddress,
this._provider,
);
this._protocolFeeUtils = new ProtocolFeeUtils(PROTOCOL_FEE_UTILS_POLLING_INTERVAL_IN_MS);
this._protocolFeeUtils = new ProtocolFeeUtils(
PROTOCOL_FEE_UTILS_POLLING_INTERVAL_IN_MS,
swapQuoterOpts.ethGasStationUrl,
);
this._forwarderAddress = contractAddresses.forwarder;
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/gas_station_utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BigNumber } from '@0x/utils';

import { ETH_GAS_STATION_API_URL, ONE_SECOND_MS } from '../constants';
import { ETH_GAS_STATION_API_URL } from '../config';
import { ONE_SECOND_MS } from '../constants';

let previousGasInfo;
let lastAccessed;
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
lodash "^4.17.11"
valid-url "^1.0.9"

"@0x/asset-swapper@0xProject/gitpkg-registry#0x-asset-swapper-v4.5.0-a7cc1637d":
"@0x/asset-swapper@0xProject/gitpkg-registry#0x-asset-swapper-v4.5.0-9a8139ce9":
version "4.5.0"
resolved "https://codeload.github.com/0xProject/gitpkg-registry/tar.gz/97a225f11b94e621c7b005c8143a3bba36204522"
resolved "https://codeload.github.com/0xProject/gitpkg-registry/tar.gz/1dc56a8c840edf07e470daeda76d4c4a90502bd7"
dependencies:
"@0x/assert" "^3.0.8"
"@0x/contract-addresses" "^4.10.0"
Expand Down

0 comments on commit 16eabc0

Please sign in to comment.