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,22 @@ const STAKING_POOLS_ENDPOINT = '/staking-pools';
2932
3033export const backendClient = {
3134 async getGasInfoAsync ( ) : Promise < GasInfo > {
32- const gasInfo : WebsiteBackendGasInfo = await fetchUtils . requestAsync (
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 gasInfo : WebsiteBackendGasInfo = await fetchUtils . requestAsync ( ZEROEX_GAS_API , gasApiPath ) ;
39+ const gasWaitTimes : WebsiteBackendGasWaitTimeInfo = await fetchUtils . requestAsync (
3340 utils . getBackendBaseUrl ( ) ,
3441 ETH_GAS_STATION_ENDPOINT ,
3542 ) ;
3643
3744 // Eth Gas Station result is gwei * 10
38- const gasPriceInGwei = new BigNumber ( gasInfo . fast / 10 ) ;
45+ const gasPriceInGwei = new BigNumber ( gasInfo . average / 10 ) ;
3946 // Time is in minutes
40- const estimatedTimeMs = gasInfo . fastWait * 60 * 1000 ; // Minutes to MS
47+ const estimatedTimeMs = gasWaitTimes . avgWait * 60 * 1000 ; // Minutes to MS
4148 return { gasPriceInWei : gasPriceInGwei . multipliedBy ( constants . GWEI_IN_WEI ) , estimatedTimeMs } ;
4249 } ,
50+
4351 async getJobInfosAsync ( ) : Promise < WebsiteBackendJobInfo [ ] > {
4452 const result = await fetchUtils . requestAsync ( utils . getBackendBaseUrl ( ) , JOBS_ENDPOINT ) ;
4553 return result ;
0 commit comments