simple-pancakeswap-sdk icon indicating copy to clipboard operation
simple-pancakeswap-sdk copied to clipboard

Getting error on some tokens when trying to find the best route.

Open inubaran opened this issue 4 years ago • 5 comments

      const pancakeswapPair = new PancakeswapPair({
        fromTokenContractAddress: '0x8519ea49c997f50ceffa444d240fb655e89248aa',
        toTokenContractAddress: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
        ethereumAddress: '0xB1E6079212888f0bE0cf55874B2EB9d7a5e02cD9',
      });
      const pancakeswapPairFactory = await pancakeswapPair.createFactory();      
      const bestRoute = await pancakeswapPairFactory.findBestRoute('10')
      console.log(bestRoute);

First off, thank for your work on this. Really helps me with what I'm doing.

I'm getting this error when I try to find the best route. It works on other tokens but not on this one or Safemoon for example:

Error: call revert exception (method="aggregate((address,bytes)[])", errorArgs=["Multicall aggregate: call failed"], errorName="Error", errorSignature="Error(string)", reason="Multicall aggregate: call failed", code=CALL_EXCEPTION, version=abi/5.4.0) at Logger.makeError (index.ts:213) at Logger.throwError (index.ts:225) at Interface.decodeFunctionResult (interface.ts:425) at Object. (index.ts:332) at Generator.next () at fulfilled (index.ts:2)

inubaran avatar Aug 23 '21 03:08 inubaran

Hey thanks for raising this will take a look at what's going on with this for you once i get some time.. will be in the next few days at most :+1: will at least try to get an answer in why it is doing it I think i probably know why already. Will keep you updated.

joshstevens19 avatar Aug 23 '21 15:08 joshstevens19

Thanks for your time looking into this. By the way, is it possible to check if the token has a liquidity prior to sending the trade? Similar to how PancakeSwap is doing it by telling you if the trade will have high price impact or if there's not enough liquidity.

inubaran avatar Aug 24 '21 00:08 inubaran

hi, I have the same problem, let us know thank you

fedy97 avatar Nov 09 '21 21:11 fedy97

I believe this bug occurs when getAllPossibleRoutes() returns too many routes. This causes the mutlicall to be too large, and it gets rejected by the EVM

// node_modules/simple-pancakeswap-sdk/dist/factories/router/pancakeswap-router.factory.js

Screen Shot 2022-06-06 at 1 16 30 PM Screen Shot 2022-06-06 at 1 12 40 PM Screen Shot 2022-06-06 at 1 19 10 PM

jcolecrypto avatar Jun 06 '22 17:06 jcolecrypto

Anyone found a workaround for this yet? It also fails when setting disableMultihop to true

Edit: oh wait, it seems like something else is going wrong. It fetches the pairs correctly. However, it can't seem to find any routes for BNB > USDC

tanevanwifferen avatar Feb 04 '23 22:02 tanevanwifferen