Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getSwapQuoter: (supportedProvider: SupportedProvider, orderSource: OrderSource, network: Network): SwapQuoter => {
const swapQuoterOpts: Partial = {
chainId: network,
};
const swapQuoter = _.isString(orderSource)
? SwapQuoter.getSwapQuoterForStandardRelayerAPIUrl(supportedProvider, orderSource, swapQuoterOpts)
: SwapQuoter.getSwapQuoterForProvidedOrders(supportedProvider, orderSource, swapQuoterOpts);
return swapQuoter;
},
getSwapQuoteConsumer: (supportedProvider: SupportedProvider, network: Network): SwapQuoteConsumer => {
assert.isHexString('takerAssetData', takerAssetData);
assert.isValidOrderSource('orderSource', orderSource);
assert.isNumber('chainId', chainId);
let provider = supportedProvider;
if (provider !== undefined) {
provider = providerUtils.standardizeOrThrow(provider);
}
const bestProvider: ZeroExProvider = provider || providerFactory.getFallbackNoSigningProvider(chainId);
const swapQuoterOptions = { chainId };
const swapQuoter = _.isString(orderSource)
? SwapQuoter.getSwapQuoterForStandardRelayerAPIUrl(bestProvider, orderSource, swapQuoterOptions)
: SwapQuoter.getSwapQuoterForProvidedOrders(bestProvider, orderSource, swapQuoterOptions);
const wethAssetData = await swapQuoter.getEtherTokenAssetDataOrThrowAsync();
const liquidity = await swapQuoter.getLiquidityForMakerTakerAssetDataPairAsync(wethAssetData, takerAssetData);
return liquidity.makerAssetAvailableInBaseUnits.gt(new BigNumber(0));
};