joshstevens19 / simple-uniswap-sdk

Uniswap SDK which handles the routes automatically for you, changes in trade quotes reactive subscriptions, exposure to formatted easy to understand information, bringing back the best trade quotes automatically, generating transactions for you and much more.
MIT License
188 stars 93 forks source link

Base Network support #58

Open alicercedigital opened 3 months ago

alicercedigital commented 3 months ago

How can we use the base network with this package?

I have defined customNetwork and cloneUniswapContractDetails, but when I try to use them, I get the message:

Can not find chain name for 8453. This lib only supports mainnet(1), ropsten(4), kovan(42), rinkeby(4) and görli(5)

This is my config:

 const uniswapPair = new UniswapPair({
  fromTokenContractAddress: "0x4200000000000000000000000000000000000006",
  toTokenContractAddress: "0x347F500323D51E9350285Daf299ddB529009e6AE",
  ethereumAddress: selectedAddress,
  ethereumProvider: metaMaskProvider,
  chainId: 8453,
  settings: new UniswapPairSettings({
   cloneUniswapContractDetails: {
    v2Override: {
     factoryAddress: "0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6",
     routerAddress: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD",
     pairAddress: "0x0Aa352230c5C05Fa912DAC0B538551f79121e29B",
    },
    v3Override: {
     factoryAddress: "0x33128a8fC17869897dcE68Ed026d694621f6FDfD",
     routerAddress: "0x2626664c2603336E57B271c5C0b26F421741e481",
     quoterAddress: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",
    },
   },
   customNetwork: {
    nameNetwork: "Base Mainnet",
    multicallContractAddress: "0x275617327c958bD06b5D6b871E7f491D76113dd8",
    nativeCurrency: {
     name: "Ether",
     symbol: "ETH",
    },
    nativeWrappedTokenInfo: {
     chainId: 8453,
     contractAddress: "0x4200000000000000000000000000000000000006",
     decimals: 18,
     symbol: "WETH",
     name: "Wrapped ETH",
    },
   },
   slippage: 0.0005,
   deadlineMinutes: 10,
   uniswapVersions: [UniswapVersion.v2, UniswapVersion.v3],
  }),
 });

Has anyone used this package with Base network? If so, could you kindly provide the configuration you used? That would greatly help us; we have been struggling with the Uniswap SDK for almost a month now. We just want to use code to trade, and this package is our last hope. =/

alicercedigital commented 3 months ago

I have created a fork of this package and made changes to the following files: (https://github.com/alicercedigital/simple-uniswap-sdk)

uniswap-pair.ts Added the chainId to the createFactory() check

chain-id.ts Added the base chainId to the ChainNames and ChainId enum

tokens.factory.public.ts Added providerContext.customNetwork to the TokensFactoryPublic constructor

eth.ts and wth.ts Added the WETH address of the base network

ethers-provider.ts Added the RPC base mainet of Infura

Now we are receiving the error: unsupported network (argument="network", value={"chainId":8453,"name":"unknown"}, code=INVALID_ARGUMENT, version=providers/5.7.2)

This error is being thrown when we initialize new UniswapPair() Does anyone know which contract is throwing this error?

woodychanjm commented 3 months ago

same problem here