Uniswap / sdks

prototype SDK monorepo
51 stars 71 forks source link

router-sdk: "Unexpected pool type in route when constructing trade object" is sometimes being thrown when using `@uniswap/smart-order-router` on Celo #77

Closed kasparkallas closed 2 months ago

kasparkallas commented 2 months ago

I seemingly randomly get this error with the smart-order-router SDK on Celo. I'm suspecting a weird type mismatch.

Related issue: https://github.com/Uniswap/smart-order-router/issues/477

Part of the problem is the error message not being descriptive enough. It could print out what the wrong pool type is, to give me some idea where the problem could be at. It could also print out the version of the package used.

Reference to the relevant code: https://github.com/Uniswap/sdks/blob/b2148e66482d72d0948895ad90b7dbd481616000/sdks/router-sdk/src/entities/trade.ts#L133

Example of tokens that sometimes throw:

Network: Celo
InToken: 0x471EcE3750Da237f93B8E339c536989b8978a438
OutToken: 0x66803fb87abd4aac3cbb3fad7c3aa01f6f3fb207

Example of usage:

  const router = new AlphaRouter({
    chainId: celo.chainId,
    provider: new ethers.providers.JsonRpcProvider(config.rpcUrl)
  });

  const swapOptions: SwapOptionsSwapRouter02 = {
    type: SwapType.SWAP_ROUTER_02,
    recipient: config.recipient,
    slippageTolerance: new Percent(50, 10_000),
    deadline: Math.floor(Date.now() / 1000 + 1200)
  }

  const swapRoute = await router.route(
    swapInTokenAmount,
    swapOutToken,
    TradeType.EXACT_INPUT, 
    swapOptions,
  );
kasparkallas commented 2 months ago

My issue was related to Bun bundling.