Uniswap / v3-sdk

🛠 An SDK for building applications on top of Uniswap V3
MIT License
553 stars 428 forks source link

How to get the Route to fill the 'path' parameter ? #126

Closed lidd77 closed 2 years ago

lidd77 commented 2 years ago

hey, when I call the next function :

function swapExactTokensForTokens(
  uint amountIn,
  uint amountOutMin,
  address[] calldata path,
  address to,
  uint deadline
) external returns (uint[] memory amounts);

I need to find the full path data . As we know , there will have more than two pairs for address[] path , so how to get the right and full path result ?

marktoda commented 2 years ago

Hi @lidd77 - swapExactTokensForTokens is a UniswapV2Router function name, you'd want to use the v2-sdk SDK to integrate with v2. As to finding the path, that'll be up to you to find a route that you want to use. You could use something like the SmartOrderRouter, or create your own routing logic.