Quickswap/Uniswap integration help

I am trying to integrate Quickswap/Uniswap into my smart contract and would like to make use of the “swapTokensForExactTokens” function as in: https://uniswap.org/docs/v2/smart-contracts/router02/

There is a path variable which is an array of addresses as to how the tokens will be exchanged prior to the final conversion. However, from my understanding, Uniswap auto-generates the path and passes it to the function. All tutorials that I have found so far have the developer hardcoding the path. Can you give me some insight as to how to auto-generate the path as Uniswap does for pairs that don’t exist.

Thank you!

Hey @Rishi

If I remeber correctly, path is an array with 2 token adresses.
["0xa1afffe3f4d611d252010e3eaf6f4d77088b0cd7", "0xdcb01cc464238396e213a6fdd933e36796eaff9f"]. It will automaticly check is there a path or no.

If there isn’t a path, you can create it.

function createPair(address tokenA, address tokenB) external returns (address pair);
2 Likes