aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-30 07:53:18 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-30 07:53:18 +0800
commit274e4b3bcd1633e8fe78a33528d63b7567355f9e (patch)
tree3f5dbc8e7af9ef5d57c915a8cb51b91b2e045451 /packages/instant/src/util
parenta49fc27042f9797f7a035e5471e572b148679456 (diff)
downloaddexon-sol-tools-274e4b3bcd1633e8fe78a33528d63b7567355f9e.tar
dexon-sol-tools-274e4b3bcd1633e8fe78a33528d63b7567355f9e.tar.gz
dexon-sol-tools-274e4b3bcd1633e8fe78a33528d63b7567355f9e.tar.bz2
dexon-sol-tools-274e4b3bcd1633e8fe78a33528d63b7567355f9e.tar.lz
dexon-sol-tools-274e4b3bcd1633e8fe78a33528d63b7567355f9e.tar.xz
dexon-sol-tools-274e4b3bcd1633e8fe78a33528d63b7567355f9e.tar.zst
dexon-sol-tools-274e4b3bcd1633e8fe78a33528d63b7567355f9e.zip
Introduce constants for eth gas station and coinbase
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r--packages/instant/src/util/coinbase_api.ts5
-rw-r--r--packages/instant/src/util/gas_price_estimator.ts9
2 files changed, 7 insertions, 7 deletions
diff --git a/packages/instant/src/util/coinbase_api.ts b/packages/instant/src/util/coinbase_api.ts
index 080421f98..32401e423 100644
--- a/packages/instant/src/util/coinbase_api.ts
+++ b/packages/instant/src/util/coinbase_api.ts
@@ -1,9 +1,10 @@
import { BigNumber } from '@0x/utils';
-const baseEndpoint = 'https://api.coinbase.com/v2';
+import { COINBASE_API_BASE_URL } from '../constants';
+
export const coinbaseApi = {
getEthUsdPrice: async (): Promise<BigNumber> => {
- const res = await fetch(`${baseEndpoint}/prices/ETH-USD/buy`);
+ const res = await fetch(`${COINBASE_API_BASE_URL}/prices/ETH-USD/buy`);
const resJson = await res.json();
return new BigNumber(resJson.data.amount);
},
diff --git a/packages/instant/src/util/gas_price_estimator.ts b/packages/instant/src/util/gas_price_estimator.ts
index 9eccfe510..818bf6f92 100644
--- a/packages/instant/src/util/gas_price_estimator.ts
+++ b/packages/instant/src/util/gas_price_estimator.ts
@@ -1,8 +1,8 @@
import { BigNumber } from '@0x/utils';
-import { DEFAULT_GAS_PRICE } from '../constants';
+import { DEFAULT_GAS_PRICE, ETH_GAS_STATION_API_BASE_URL } from '../constants';
-interface GasStationResult {
+interface EthGasStationResult {
average: number;
fastestWait: number;
fastWait: number;
@@ -16,10 +16,9 @@ interface GasStationResult {
safeLow: number;
}
-const endpointUrl = 'https://ethgasstation.info/json/ethgasAPI.json';
const fetchFastAmountInWei = async () => {
- const res = await fetch(endpointUrl);
- const gasInfo = (await res.json()) as GasStationResult;
+ const res = await fetch(`${ETH_GAS_STATION_API_BASE_URL}/json/ethgasAPI.json`);
+ const gasInfo = (await res.json()) as EthGasStationResult;
const gasPriceInGwei = new BigNumber(gasInfo.fast / 10);
return gasPriceInGwei.mul(1000000000);
};