1

Is it possible to use uniswap sdk with arbitrum, polygon, avalanche and other networks where uniswap contract is running or should I use ethers directly? Second question is it possible to interact with uniswap contract on not evm based networks like Binance Smart Chain? I try to adopt this example with Arbitrum One chain id but got error.

export async function getPriceInUsd() {
    const chainId = 42161 // ChainId.MAINNET
    const stableAddress = '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1' //'0x6B175474E89094C44Da98b954EedeAC495271d0F'
    const DAI = new Token(chainId, stableAddress, 18)
    const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId])
    const route = new Route([pair], WETH[DAI.chainId])
    return route.midPrice.toSignificant(6)
};

Error: unsupported getDefaultProvider network (operation="getDefaultProvider", network={"name":"arbitrum","chainId":42161,"ensAddress":null,"_defaultProvider":null}, code=NETWORK_ERROR, version=providers/5.7.2)

TylerH
  • 20,799
  • 66
  • 75
  • 101
RomanKovalev
  • 852
  • 3
  • 10
  • 29
  • SDK works with SupportedChainId's by default so Polygon and where ever uni is deployed will naturally work, for other chains you will need to deploy the contracts, maybe also a graph, and updated the Addresses, and support chainid in a modified version of the sdk – johnny 5 May 18 '23 at 12:00

0 Answers0