Open Brenzee opened 9 months ago
I very often get this error even when I try to force it to only look for "V3" by specifying protocols: [ "V3" ]
.
This line is probably the issue for me: https://github.com/Uniswap/smart-order-router/blob/7d166a0e6bd209807cf6f4a4fc33161f90468985/src/routers/alpha-router/alpha-router.ts#L970
I think I fixed it for my use-case like this:
const swapRoute = await alphaRouter.route(
swapInTokenAmount,
swapOutToken,
TradeType.EXACT_INPUT,
swapOptions,
{
v2PoolSelection: undefined, // Hacky way to make sure Uniswap doesn't use V2 pools.
protocols: ["V3" as any], // Uniswap type issue, and this is not respected anyway, but added for completeness sake.
}
);
and:
const alphaRouter = new AlphaRouter({
chainId: config.chainId,
provider: new ethers.providers.JsonRpcProvider(config.rpcUrl),
v2Supported: [] // Remove V2 routes
});
Nope, still getting the error sometimes.
Direct link to the problematic code in router SDK: https://github.com/Uniswap/sdks/blob/b2148e66482d72d0948895ad90b7dbd481616000/sdks/router-sdk/src/entities/trade.ts#L133
@Brenzee I don't quite get the explanation about the versions as the latest @uniswap/smart-order-router
is referencing the following packages in the published package.json
:
"@uniswap/default-token-list": "^11.13.0",
"@uniswap/permit2-sdk": "^1.3.0",
"@uniswap/router-sdk": "^1.10.0",
"@uniswap/sdk-core": "^5.3.0",
"@uniswap/swap-router-contracts": "^1.3.1",
"@uniswap/token-lists": "^1.0.0-beta.31",
"@uniswap/universal-router": "^1.6.0",
"@uniswap/universal-router-sdk": "^2.2.4",
"@uniswap/v2-sdk": "^4.3.2",
"@uniswap/v3-sdk": "^3.13.0",
"@uniswap/v4-sdk": "^1.0.0",
These packages seem to be the latest and don't align with your description.
I'm submitting a ... [X] bug report [ ] feature request [ ] question about the decisions made in the repository [ ] question about how to use this project
Summary
When
route
is called with configit always fails with error
This error comes from the
@uniswap/router-sdk
This makes the
smart-order-router
unusable for any V2 swaps unless a specific@uniswap/router-sdk
version is forced.I am pretty confident this happens because
smart-order-router
uses"@uniswap/v2-sdk": "^3.2.3"
, but therouter-sdk
uses"@uniswap/v2-sdk": "^4.0.1"
When I force
@uniswap/router-sdk
to be version1.7.1
, it works fine. I suggest either support the@uniswap/v2-sdk
versioni 4 or use a specific@uniswap/router-sdk
version, that does not use@uniswap/v2-sdk
version 4.