getTotalAmountOut
The getTotalAmountOut
method calculates the total input amount required for the route, including all split paths.
Signature
getTotalAmountOut(): object
Returns
Returns an object containing:
amountOut
- Total output amount in raw units (bigint)amountOutFormatted
- Total output amount formatted with token decimals (string)tokenIn
- Token in address (string)tokenOut
- Token out address (string)
Returns an object containing tokenIn, tokenOut, amountOut, amountOutFormatted.
Example Usage
const symphony = new Symphony();
// Get an arbitrary route
const route = await symphony.getRoute(
"0x0", // SEI
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
"1.0"
);
// Get total input amount
const totalAmountIn = route.getTotalAmountOut();
console.log(totalAmountOut.amountIn.toString()); // "1000000000000000000"
// or Ethers BigNumber representation for Ethers V5 library (1 SEI in wei)
console.log(totalAmountOut.amountInFormatted.toString()); // "1" (1 SEI)
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