Skip to content

getSwapTypes

The getSwapTypes method extracts swap types from a route. Each swap type represents a specific type of token exchange operation in the route.

Signature

getSwapTypes(): number[][]

Returns

Returns an array of arrays containing swap type numbers. Each inner array represents a path, and each number represents a specific DEX:

  • 1 - Dragonswap V1
  • 2 - Yaka
  • 3 - Donkeswap
  • 4 - JellySwap
  • 5 - OkuTrade
  • 6 - Dragonswap V2
  • 7 - Sailorswap
  • 8 - Yei Finance

Example Usage

const symphony = new Symphony();
 
// Get an arbitrary route
const route = await symphony.getRoute(
  "0x0", // SEI
  "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
  "1.0"
);
 
// Get swap types for the route
const swapTypes = route.getSwapTypes();
 
// For a single path route through multiple DEXes
console.log(swapTypes); // [[2, 4, 1]] (YAKA -> JELLYSWAP -> DRAGONSWAP V1)
 
// For a multi-path route
console.log(swapTypes); // [[2, 4], [1, 4, 3]] means:
// Path 1: Yaka -> Jellyswap
// Path 2: Dragonswap V1 -> Jellyswap -> Donkeswap

Notes

  • Each number in the array represents a specific DEX in the swap path
  • For multi-path routes, each inner array represents a different path
  • The sequence of numbers shows the order of DEXes used in the swap

Error Handling

The method will return undefined if:

  • The route is invalid or empty
  • The route array structure is incorrect