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 95 forks source link

Error for token dForce that works on uniswap app #15

Closed loki-sama closed 3 years ago

loki-sama commented 3 years ago

The following findBestRoute fails for token with address 0x431ad2ff6a9C365805eBaD47Ee021148d6f7DBe0, but works on uniswap app. The error is likely related to symbol and name of the contract being a bytes32 instead of string. https://etherscan.io/address/0x431ad2ff6a9C365805eBaD47Ee021148d6f7DBe0#readContract

Error: UniswapError: invalid from or to contract tokens

Example:

  const fromTokenContractAddress = ETH.MAINNET().contractAddress;
  const toTokenContractAddress = '0x431ad2ff6a9C365805eBaD47Ee021148d6f7DBe0'; 

  const ethereumAddress = '0xB1E6079212888f0bE0cf55874B2EB9d7a5e02cD9';

  const uniswapPair = new UniswapPair({
    fromTokenContractAddress,
    toTokenContractAddress,
    ethereumAddress,
    chainId: ChainId.MAINNET,
  });

  const uniswapPairFactory = await uniswapPair.createFactory();

  const trade = await uniswapPairFactory.findBestRoute(
    '0.00000000001',
    TradeDirection.input
  );
joshstevens19 commented 3 years ago

Hey! Thanks for raising will look for you and get a fix out! 👍

joshstevens19 commented 3 years ago

Sorry for the wait this is now fixed in 3.4.1 thanks let me know if you have any issues.