Is it possible to use uniswap sdk with other than mainnet networks

409 views Asked by At

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)

0

There are 0 answers