getTotalAmountOut
The getTotalAmountOut
method calculates the total output amount expected from the route, including all split paths.
Signature
async getTotalAmountOut(): Promise<{
amountOut: bigint | BigNumber;
amountOutFormatted: string;
tokenIn: string;
tokenOut: string;
}>
TypeScript Types
// Import for viem/ethers v6 (uses bigint)
import type { AmountInfo } from 'symphony-sdk/types/viem';
// Import for ethersV5 (uses BigNumber)
import type { AmountInfo } from 'symphony-sdk/types/ethersV5';
import type { BigNumber } from 'ethers';
interface AmountInfo {
amountOut: bigint | BigNumber;
amountOutFormatted: string;
tokenIn: string;
tokenOut: string;
}
Returns
Returns a Promise that resolves to an object containing:
amountOut
- Total output amount in raw units (bigint for viem/ethers v6, BigNumber for ethersV5)amountOutFormatted
- Total output amount formatted with token decimals (string)tokenIn
- Token in address (string)tokenOut
- Token out address (string)
Example Usage
const symphony = new Symphony();
// Get an arbitrary route
const route = await symphony.getRoute(
"0x0", // SEI
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
"1.0"
);
// Get total output amount
const totalAmountOut = await route.getTotalAmountOut();
console.log(totalAmountOut.amountOut.toString()); // "999500" (0.9995 USDC in smallest units)
console.log(totalAmountOut.amountOutFormatted); // "0.9995" (USDC)
Error Handling
The method will throw an error if:
- The route is invalid or empty
- The route array structure is incorrect
- The input amounts are not properly initialized