getRouteDetails
The getRouteDetails method extracts and calculates detailed information about a swap route. It processes both single and multi-path routes and provides comprehensive details about the swap.
Signature
async getRouteDetails(): Promise<RouteDetails>TypeScript Types
// Import for viem/ethers v6
import type { RouteDetails } from 'symphony-sdk/types/viem';
 
// Import for ethersV5
import type { RouteDetails } from 'symphony-sdk/types/ethersV5';
import type { BigNumber } from 'ethers';
 
interface RouteDetails {
  totalOut: bigint | BigNumber;
  totalOutFormatted: string;
  pathPercentages: number[];
  pathCount: number;
  amountIn: bigint | BigNumber;
  amountInFormatted: string;
  swapTypes: number[];
  tokenIn: string;
  tokenOut: string;
  tokenInData: TokenData;
  tokenOutData: TokenData;
  route: RouteStep[][];
}Returns
Returns a Promise that resolves to an object containing:
- totalOut- Total output amount in raw units (bigint for viem/ethers v6, BigNumber for ethersV5)
- totalOutFormatted- Total output amount formatted with token decimals (string)
- pathPercentages- Percentage split between paths, e.g., [60, 40] for 60-40 split (number[])
- pathCount- Number of paths in the route (number)
- amountIn- Total input amount in raw units (bigint or BigNumber)
- amountInFormatted- Total input amount formatted with token decimals (string)
- swapTypes- Array of swap types for each step (number[])
- tokenIn- Input token address (string)
- tokenOut- Output token address (string)
- tokenInData- Input token metadata from Symphony (TokenData)
- tokenOutData- Output token metadata from Symphony (TokenData)
- route- Original route array (RouteStep[][])
Example Usage
const symphony = new Symphony();
 
// Get a route
const route = await symphony.getRoute(tokenIn, tokenOut, "1.0");
 
// Get detailed information about the route
const details = await route.getRouteDetails();
 
// Access route information
console.log(details.totalOutFormatted); // Expected output amount
console.log(details.pathPercentages); // Split between paths, e.g., [100] or [60, 40]
console.log(details.pathCount); // Number of paths
console.log(details.tokenInData.attributes.symbol); // Input token symbolNotes
- Provides comprehensive information about the route, including amounts, paths, and token details
- Handles both single-path and multi-path routes
- All amounts are provided in both raw and formatted units
- Token metadata includes decimals, symbols, and other attributes
- Path percentages show how the input amount is split across different paths
Error Handling
The method will throw an error if:
- The route is invalid or empty
- Token data is missing from Symphony
- Path structure is invalid

