getBestRoute
function finds the optimal trading route for a token swap through Fibrous’s liquidity pools.
Function Signature
Parameters
Parameter | Type | Description |
---|---|---|
amount | BigNumber | Amount to swap, formatted according to token decimals |
tokenInAddress | string | Token address to swap from |
tokenOutAddress | string | Token address to swap to |
chainName | string | Chain name where the transaction will take place (will be deprecated in the future, use chainId instead) |
options | RouteOverrides | Optional parameters for route customization |
chainId | number | Chain ID (may be used instead of chainName for backward compatibility) |
RouteOverrides Type
- excludeProtocols: This is where you list the IDs of the AMMs you don’t want to include. For example, if there are certain AMMs you prefer not to use due to high fees or other reasons, you simply put their unique IDs in this list.
- Use supportPairs to get a list of supported AMMs and their IDs.