Request Routes & Quotes
Prior to executing a swap or a bridge, you need to request the best route from our API
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.
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 Name | Chain ID |
---|---|
Ethereum | 1 |
Optimism | 10 |
Polygon | 137 |
Arbitrum | 42161 |
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 Name | Chain ID |
---|---|
Ethereum | 1 |
Optimism | 10 |
Polygon | 137 |
Arbitrum | 42161 |
toTokenAddress string
required
The contract address of the token on the destination chain. Ensure this address corresponds to the specified toChainId.