Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let newSwapQuote: MarketBuySwapQuote | undefined;
const slippagePercentage =
asset.metaData.assetProxyId === AssetProxyId.ERC20
? ERC20_SWAP_QUOTE_SLIPPAGE_PERCENTAGE
: ERC721_SWAP_QUOTE_SLIPPAGE_PERCENTAGE;
try {
const gasInfo = await gasPriceEstimator.getGasInfoAsync();
newSwapQuote = await swapQuoter.getMarketBuySwapQuoteForAssetDataAsync(
asset.assetData,
wethAssetData,
baseUnitValue,
{
slippagePercentage,
gasPrice: gasInfo.gasPriceInWei,
// Only use native orders
excludedSources: [ERC20BridgeSource.Eth2Dai, ERC20BridgeSource.Kyber, ERC20BridgeSource.Uniswap],
},
);
} catch (error) {
const errorMessage = assetUtils.swapQuoterErrorMessage(asset, error);
errorReporter.report(error);
analytics.trackQuoteError(error.message ? error.message : 'other', baseUnitValue, fetchOrigin);
if (options.dispatchErrors) {
dispatch(actions.setQuoteRequestStateFailure());
errorFlasher.flashNewErrorMessage(dispatch, errorMessage || 'Error fetching price, please try again');
}
return;
}
// We have a successful new swap quote
errorFlasher.clearError(dispatch);