/** * Gets the best route from the API * @param amount: Amount to swap, formatted * @param tokenInAddress: Token to swap from * @param tokenOutAddress: Token to swap to * @param chainName: Chain name where the transaction will take place * @param options: Optional parameters such as slippage and excluded protocols * @returns Promise<RouteResponse> * @throws Error if the API returns an error */async getBestRoute( amount: BigNumber, tokenInAddress: string, tokenOutAddress: string, chainName: string, options?: Partial<RouteOverrides>): Promise<RouteResponse>;
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.
supportPairs : This function returns a list of supported AMMs, along with the AMM IDs.
RouteResponse
typeRouteResponse= { success:true; inputToken:Token; inputAmount:string; outputToken:Token; outputAmount:string; estimatedGasUsed:string; route:Route[]; time:number; swapType?:string; // Specific to EVM};
Example usage
import { Router as FibrousRouter } from"fibrous-router-sdk";import { BigNumber } from"@ethersproject/bignumber";import { parseUnits } from"ethers";constrouter=newFibrousRouter();consttokenInAddress= tokens["usdt"].address;consttokenOutAddress= tokens["usdc"].address;consttokenInDecimals= tokens["usdt"].decimals;constinputAmount=BigNumber.from(parseUnits("5", tokenInDecimals)); // for 5 USDTconstroute=awaitrouter.getBestRoute( inputAmount,// amount tokenInAddress,// token input tokenOutAddress,// token output"scroll"// chain name (Starknet or Scroll));