Skip to content

getTotalAmountIn

The getTotalAmountIn method calculates the total input amount required for the route, including all split paths.

Signature

getTotalAmountIn(): object

Returns

Returns an object containing:

  • amountIn - Total output amount in raw units (bigint)
  • amountInFormatted - Total output amount formatted with token decimals (string)
  • tokenIn - Token in address (string)
  • tokenOut - Token out address (string)

Returns an object containing tokenIn, tokenOut, amountIn, amountInFormatted.

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.getTotalAmountIn();
console.log(totalAmountIn.amountIn.toString()); // "1000000000000000000" (1 SEI in wei)
// or Ethers BigNumber representation for Ethers V5 library (1 SEI in wei)
console.log(totalAmountIn.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