diff --git a/packages/checkout/widgets-lib/src/widgets/add-funds/hooks/useRoutes.ts b/packages/checkout/widgets-lib/src/widgets/add-funds/hooks/useRoutes.ts index 899e255644..04e68b7a59 100644 --- a/packages/checkout/widgets-lib/src/widgets/add-funds/hooks/useRoutes.ts +++ b/packages/checkout/widgets-lib/src/widgets/add-funds/hooks/useRoutes.ts @@ -5,6 +5,7 @@ import { utils } from 'ethers'; import { useRef, useState } from 'react'; import { delay } from '../functions/delay'; import { AmountData, RouteData, Token } from '../types'; +import { retry } from '../../../lib/retry'; export const useRoutes = () => { const [routes, setRoutes] = useState(undefined); @@ -86,18 +87,24 @@ export const useRoutes = () => { parsedFromAmount, fromToken.decimals, ); - - return await squid.getRoute({ - fromChain: fromToken.chainId, - fromToken: fromToken.address, - fromAmount: formattedFromAmount.toString(), - toChain: toToken.chainId, - toToken: toToken.address, - fromAddress, - toAddress, - quoteOnly, - enableBoost: true, - }); + return await retry( + () => squid.getRoute({ + fromChain: fromToken.chainId, + fromToken: fromToken.address, + fromAmount: formattedFromAmount.toString(), + toChain: toToken.chainId, + toToken: toToken.address, + fromAddress, + toAddress, + quoteOnly, + enableBoost: true, + }), + { + retryIntervalMs: 1000, + retries: 5, + nonRetryable: (err: any) => err.response.status !== 429, + }, + ); } catch (error) { return undefined; }