Uniswap / v3-sdk

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

JSBI misbehaving with v3 sdk utils #100

Open rachit95arora opened 2 years ago

rachit95arora commented 2 years ago

Trying to use the sdk swapMath utils (computeSwapStep) and keep running into this error:

TypeError: _.__digit is not a function
    at Function.__leftShiftByAbsolute (/home/rachita/Projects/crypto/swap_arbitrage/node_modules/jsbi/lib/jsbi.ts:1661:21)
    at Function.leftShift (/home/rachita/Projects/crypto/swap_arbitrage/node_modules/jsbi/lib/jsbi.ts:293:17)
    at Function.getAmount0Delta (/home/rachita/Projects/crypto/swap_arbitrage/node_modules/@uniswap/v3-sdk/src/utils/sqrtPriceMath.ts:30:29)
    at Function.computeSwapStep (/home/rachita/Projects/crypto/swap_arbitrage/node_modules/@uniswap/v3-sdk/src/utils/swapMath.ts:38:25)

Running using npx ts-node if relevant

marktoda commented 2 years ago

Hey @rachit95arora - thanks for reporting this! I've marked it down and the team will take a look

marktoda commented 2 years ago

I wasn't able to directly reproduce this, but it seems to be a mismatch in JSBI versions. Perhaps your package.json is targeting a different version than ours? In any case I've submitted a PR including JSBI in the package.json here which should help yours use the correct version: https://github.com/Uniswap/v3-sdk/pull/132