66 MailchimpSubscriberInfo ,
77 WebsiteBackendCFLMetricsData ,
88 WebsiteBackendGasInfo ,
9+ WebsiteBackendGasWaitTimeInfo ,
910 WebsiteBackendJobInfo ,
1011 WebsiteBackendPriceInfo ,
1112 WebsiteBackendRelayerInfo ,
@@ -17,6 +18,8 @@ import { constants } from 'ts/utils/constants';
1718import { fetchUtils } from 'ts/utils/fetch_utils' ;
1819import { utils } from 'ts/utils/utils' ;
1920
21+ const ZEROEX_GAS_API = 'https://gas.api.0x.org/' ;
22+
2023const ETH_GAS_STATION_ENDPOINT = '/eth_gas_station' ;
2124const JOBS_ENDPOINT = '/jobs' ;
2225const PRICES_ENDPOINT = '/prices' ;
@@ -29,17 +32,26 @@ const STAKING_POOLS_ENDPOINT = '/staking-pools';
2932
3033export const backendClient = {
3134 async getGasInfoAsync ( ) : Promise < GasInfo > {
32- const gasInfo : WebsiteBackendGasInfo = await fetchUtils . requestAsync (
33- utils . getBackendBaseUrl ( ) ,
34- ETH_GAS_STATION_ENDPOINT ,
35- ) ;
35+ // Median gas prices across 0x api gas oracles
36+ // Defaulting to average/standard gas. Using eth gas station for time estimates
37+ const gasApiPath = 'source/median?output=eth_gas_station' ;
38+ const gasInfoReq = fetchUtils . requestAsync ( ZEROEX_GAS_API , gasApiPath ) ;
39+ const gasWaitTimesReq = fetchUtils . requestAsync ( utils . getBackendBaseUrl ( ) , ETH_GAS_STATION_ENDPOINT ) ;
40+
41+ const res : [ WebsiteBackendGasInfo , WebsiteBackendGasWaitTimeInfo ] = await Promise . all ( [
42+ gasInfoReq ,
43+ gasWaitTimesReq ,
44+ ] ) ;
45+ const gasInfo = res [ 0 ] ;
46+ const gasWaitTimes = res [ 1 ] ;
3647
3748 // Eth Gas Station result is gwei * 10
38- const gasPriceInGwei = new BigNumber ( gasInfo . fast / 10 ) ;
49+ const gasPriceInGwei = new BigNumber ( gasInfo . average / 10 ) ;
3950 // Time is in minutes
40- const estimatedTimeMs = gasInfo . fastWait * 60 * 1000 ; // Minutes to MS
51+ const estimatedTimeMs = gasWaitTimes . avgWait * 60 * 1000 ; // Minutes to MS
4152 return { gasPriceInWei : gasPriceInGwei . multipliedBy ( constants . GWEI_IN_WEI ) , estimatedTimeMs } ;
4253 } ,
54+
4355 async getJobInfosAsync ( ) : Promise < WebsiteBackendJobInfo [ ] > {
4456 const result = await fetchUtils . requestAsync ( utils . getBackendBaseUrl ( ) , JOBS_ENDPOINT ) ;
4557 return result ;
0 commit comments