Uniswap / v3-sdk

🛠 An SDK for building applications on top of Uniswap V3
MIT License
547 stars 424 forks source link

Got an Unhandled Rejection (Error): Convert JSBI instances to native numbers using `toNumber`. #94

Open DannyFung97 opened 2 years ago

DannyFung97 commented 2 years ago

I recently updated my npm packages, with the v3-sdk going from ^3.5.1-optimism-regensis to ^3.7.1. Because of this JSBI started to act weird. At first I was getting an error saying Argument of type 'JSBI' is not assignable to parameter of type 'BigintIsh', even though BigintIsh should contain JSBI, I changed those to strings and that seemed to have solved the problem at first. But then later when I'm trying to get the midPrice for a v3 swap route, I'm getting an error saying "Convert JSBI instances to native numbers using toNumber". This never happened before with my past package. It might have something to do with the JSBI package. I tried updating to what the uniswap interface is using and back, but nothing is working. I created the route object using one token that is the native network's token and the other is any token, and I'm passing only one pool into the route.

noahgenesis commented 2 years ago

The problem is the version of JSBI, it requires 3.2.4 across all repos. Most likely you have a different diversion in one of the repos

hexlivelive commented 2 years ago

I am getting the same issue. "devDependencies": { "@uniswap/sdk-core": "^3.0.1", "@uniswap/v3-sdk": "^3.8.2", "typescript": "^4.6.2" }, "dependencies": { "@uniswap/sdk": "^3.0.3", "ethers": "^5.6.1", "jsbi": "^4.2.0", "ts-node": "^10.7.0" }

snowkidind commented 2 years ago

In my project I have other packages that require higher versions of this, solana's jupiter stuff in particular.

marktoda commented 2 years ago

Thanks for reporting - we'll take a look at this

marktoda commented 2 years ago

I've added JSBI to the package.json for more visibility on the version that we use here: https://github.com/Uniswap/v3-sdk/pull/132. I think it's worth considering updating to a more recent version of JSBI (they are on major 4 now) so I've added a new task to track the upgrade https://github.com/Uniswap/v3-sdk/issues/133

snowkidind commented 2 years ago

seeing as you are already including @ethersproject/address, why not just use @ethersproject/bignumber I've been doing decimal math using js-big-decimal which has been working well for my purposes.