Disclaimer

The Suave Aggregator SDK will only function properly in a browser-like environment. You can use a library like web3-mock to simulate this in Node.js.

Use the getRoutes function to fetch routes/quotes from the Sauve Aggregator API.

Here is a simple example of how to request routes to bridge 10 USDC on Arbitrum to the maximum amount of DAI on Polygon.

import { getRoutes, RouteResponse } from '@suave-money/sdk'

const routes: RouteResponse[] = await getRoutes({
  inputAmount: '10000000', // 10 USDC
  fromChainId: 42161, // Arbitrum
  fromToken: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // USDC on Arbitrum
  toChainId: 137, // Polygon
  toToken: '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063' // DAI on Polygon
})

Routes request parameters

Below are the parameters for the getRoutes function along with their descriptions:

fromChainId number required

The ID of the source chain.

Chain NameChain ID
Ethereum1
Optimism10
Polygon137
Arbitrum42161

fromTokenAddress string required

The contract address of the token on the source chain. Ensure this address corresponds to the specified fromChainId.

fromAmount string required

The amount to be transferred from the source chain, specified in the smallest unit of the token (e.g., wei for ETH).

fromAddress string optional

The address from which the tokens are being transferred.

toChainId number required

The ID of the destination chain

Chain NameChain ID
Ethereum1
Optimism10
Polygon137
Arbitrum42161

toTokenAddress string required

The contract address of the token on the destination chain. Ensure this address corresponds to the specified toChainId.