Open Amxx opened 2 years ago
Hey @Amxx - apologies for the long delay on this! Hopefully you've figured out this issue by now, but I'll see if I can help in case not :)
The exactOutput
boolean switches between whether path is listed in forward or reverse order (since exactOutput swaps are executed in reverse). The thing that stands out to me that may be causing your issue is this line in your contract:
IERC20 assetIn = IERC20(path.toAddress(23));
In exactInput
swaps the input asset is assumed to be the first token of the first pool in the route (i.e. see https://github.com/Uniswap/v3-periphery/blob/2880364dcde105b903d4bf1bea94105b14cbbd35/contracts/SwapRouter.sol#L96 and https://github.com/Uniswap/v3-periphery/blob/2880364dcde105b903d4bf1bea94105b14cbbd35/contracts/libraries/Path.sol#L51). So I would guess that if you used offset 0 as tokenIn it would solve the issue.
Let me know if helpful or any other way we can help!
Hello,
Lets start by the contract I'm writing. It is supposed to swap arbitrary user token to the one my system uses, before actually doing stuff.
My issue is in building the
path
So far I've been doing
the resulting trade is
USDC.address | fee | USDT.address
... hence thepath.toAddress(23)
in the contract. → but that fails withSTF
.So what I did is changing
encodeRouteToPath(trade.routes[0])
toencodeRouteToPath(trade.routes[0], true)
andpath.toAddress(23)
topath.toAddress(0)
→ this works!So I'm confused, because the true params is supposed to be for
exactOutput
... and I'm usingexactInput
. I'm afraid this might break with longer paths ...Am I doing things wrong, or is the docs mistaken?