Skip to content

Define a custom network which is not supported

Compare
Choose a tag to compare
@joshstevens19 joshstevens19 released this 25 Oct 18:55
· 28 commits to master since this release
75c2bcf

Ability to define a custom network, allowing support for any EVM network uniswap fork.. example:

// Generate Uniswap pair
const pair = new UniswapPair({
  fromTokenContractAddress: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
  toTokenContractAddress: desiredTokenAddress,
  ethereumAddress: this.wallet.address,
  providerUrl: this.rpc,
  chainId: 137,
  settings: new UniswapPairSettings({
    slippage: this.slippage, // Slippage config
    deadlineMinutes: 5, // 5m max execution deadline
    disableMultihops: false, // Allow multihops
    uniswapVersions: [UniswapVersion.v2], // Only V2
    cloneUniswapContractDetails: {
      v2Override: {
        routerAddress: "0x1b02da8cb0d097eb8d57a175b88c7d8b47997506",
        factoryAddress: "0xc35dadb65012ec5796536bd9864ed8773abc74c4",
        pairAddress: "0xc35dadb65012ec5796536bd9864ed8773abc74c4"
      }
      // v3Override exists here as well!
    },
    customNetwork: {
      nameNetwork: "polygon",
      multicallContractAddress:
        "0x275617327c958bD06b5D6b871E7f491D76113dd8",
      nativeCurrency: {
        name: "Matic Token",
        symbol: "MATIC"
      },
      nativeWrappedTokenInfo: {
        chainId: 137,
        contractAddress: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
        decimals: 18,
        symbol: "WMATIC",
        name: "Wrapped Matic"
      },
      // can define your base tokens here if any!
      baseTokens: {
        usdt: {
          chainId: 137,
          contractAddress: 'CONTRACT_ADDRESS',
          decimals: 18,
          symbol: 'USDT',
          name: 'Tether USD',
        };
       // dai...
       // comp...
       // usdc...
       // wbtc...
      };
    }
  })
});

Also thanks for the eth donations for this feature allowing it to be fast tracked - you can thank @vm06007 for that!