joshstevens19 / simple-pancakeswap-sdk

MIT License
37 stars 35 forks source link

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

Open inubaran opened 3 years ago

inubaran commented 3 years ago
      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=CALLEXCEPTION, 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)

joshstevens19 commented 3 years ago

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.

inubaran commented 3 years ago

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.

fedy97 commented 2 years ago

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

jcolecrypto commented 2 years ago

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
tanevanwifferen commented 1 year ago

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