smart-order-router icon indicating copy to clipboard operation
smart-order-router copied to clipboard

AlphaRouter.route() function returns error: Could not find a USD/WETH pool

Open mystbrent opened this issue 2 years ago • 5 comments

  • I'm submitting a ... [ ] bug report [ ] feature request [ ] question about the decisions made in the repository [x] question about how to use this project

  • Summary

I am following the uniswap docs - https://docs.uniswap.org/sdk/guides/auto-router#calling-route

For context:

I am doing this on goerli network and have deployed my own test tokens and created a UNI V3 pool for them. https://app.uniswap.org/#/add/0x7bF09dC2d87920CCcbB74b1ca45B505CDb3C55b5/0x71E7B39224FA2d0Da821Cf4ef256EDF5a95f6e22?chain=goerli

When I call await alphaRouter.route() function I am getting this error: Could not find a USD/WETH pool for computing gas costs.

Basing from the error message, I did the following fix attempts:

  • I created a TokenA/WETH pool but it did not solve the error.
  • I created a TokenB/WETH pool but it did not solve the error.
  • I created a TokenA/USDC pool but it did not solve the error.
  • I created a TokenB/USDC pool but it did not solve the error.

I am using this USDC address on goerli - https://goerli.etherscan.io/address/0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C

I've tracked the code here - https://github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.ts#L256

But I cannot figure out how to fix the issue.

Please kindly advise how to resolve this :)

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

mystbrent avatar Sep 08 '22 14:09 mystbrent

Was checking similar issues and saw activity here perhaps you can help shed some light :) @snreynolds @zhongeric

mystbrent avatar Sep 12 '22 02:09 mystbrent

Your USDC address on goerli is incorrect. Try using 0x07865c6e87b9f70255377e024ace6630c1eaa37f (https://goerli.etherscan.io/address/0x07865c6e87b9f70255377e024ace6630c1eaa37f) ? There should also be a GOERLI_USDC token somewhere in the repo as well.

https://developers.circle.com/docs/usdc-on-testnet

zhongeric avatar Sep 12 '22 03:09 zhongeric

thanks for the response @zhongeric .

I've updated the code to use that USDC contract address.

I've also created A:USDC, B:USDC pools for my testing. e.g: B:USDC - https://goerli.etherscan.io/token/0x71e7b39224fa2d0da821cf4ef256edf5a95f6e22?a=0x96f2ec057afacadff0f2503520c3320c5aa44716

The error Could not find a USD/WETH pool for computing gas costs. persists despite my efforts.

Can I ask for your help in identifying the cause?

mystbrent avatar Sep 12 '22 06:09 mystbrent

Please confirm the chainId. You should set chainId = 1

okblue430 avatar Sep 28 '22 20:09 okblue430

You need to have a USD/WETH pool in order to get pricing information. If you added a new chain make sure to add a value to the USDC Map in the smart router (NOTE: this can be other stable coins)

RitzyDevBox avatar Sep 16 '23 20:09 RitzyDevBox