Squid Dev Documentation
Ask or search…

Get a route

We recommend getting a new route or quote every 20 seconds to refresh prices.
// Set up parameters for swapping tokens and depositing into Radiant lending pool
const params = {
fromAddress: signer.address,
fromChain: arbitrumId,
fromToken: usdcArbitrumAddress,
fromAmount: amount,
toChain: polygonId,
toToken: nativeToken,
toAddress: signer.address,
slippage: 1,
slippageConfig: {
autoMode: 1,
quoteOnly: false,
// Get the swap route using Squid SDK
const { route, requestId } = await squid!.getRoute(params);
You can then explore the route response. This includes all the information on your quote route.estimate and all the data needed to generate a transaction route.transactionRequest.
const getRoute = async (params: any) => {
try {
const result = await axios.post(
headers: {
"x-integrator-id": integratorId,
"Content-Type": "application/json",
const requestId = result.headers["x-request-id"];
return { data: result.data, requestId: requestId };
} catch (error) {
// Log the error response if it's available.
if (error.response) {
console.error("API error:", error.response.data);
console.error("Error with parameters:", params);
throw error;
// Get the swap route using Squid API
const routeResult = await getRoute(params);
const route = routeResult.data.route;
const requestId = routeResult.requestId;
console.log("Calculated route:", route);
console.log("requestId:", requestId);
All Squid widgets will get a route when the user can entered all the necessary parameters.
Widgets refresh quotes every 20 seconds.