Created
June 16, 2022 06:27
-
-
Save snowkidind/8a36f64ba1e14d56b136de3e787407f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using const { AlphaRouter } = require('@uniswap/smart-order-router') | |
when calling | |
const wei = ethers.utils.parseUnits('100', 6) | |
const inputAmount = CurrencyAmount.fromRawAmount(USDC, jsbi.BigInt(wei)) // Note inputAmount contains its own JSBI's created by uniswap code which appear to be the source of the error | |
const route = await router.route( | |
inputAmount, | |
UNI, | |
TradeType.EXACT_INPUT, | |
{ | |
recipient: address, | |
slippageTolerance: new Percent(25,100), | |
deadline: Math.floor(Date.now() / 1000 + 1800) | |
} | |
) | |
Error: Could not parse fraction | |
at Function.tryParseFraction (/home/sdk/pm/node_modules/@uniswap/sdk-core/dist/sdk-core.cjs.development.js:67:11) | |
at Percent.lessThan (/home/sdk/pm/node_modules/@uniswap/sdk-core/dist/sdk-core.cjs.development.js:98:32) | |
at Trade.maximumAmountIn (/home/sdk/pm/node_modules/@uniswap/v2-sdk/dist/v2-sdk.cjs.development.js:619:25) | |
at Function.encodeV2Swap (/home/sdk/pm/node_modules/@uniswap/router-sdk/dist/router-sdk.cjs.development.js:1479:38) | |
at Function.encodeSwaps (/home/sdk/pm/node_modules/@uniswap/router-sdk/dist/router-sdk.cjs.development.js:1630:35) | |
at Function.swapCallParameters (/home/sdk/pm/node_modules/@uniswap/router-sdk/dist/router-sdk.cjs.development.js:1669:44) | |
at Object.buildSwapMethodParameters (/home/sdk/pm/node_modules/@uniswap/smart-order-router/build/main/util/methodParameters.js:73:36) | |
at AlphaRouter.route (/home/sdk/pm/node_modules/@uniswap/smart-order-router/build/main/routers/alpha-router/alpha-router.js:354:51) | |
at processTicksAndRejections (internal/process/task_queues.js:95:5) | |
at async main (/home/sdk/pm/test/uniswap/alpha.js:36:17) | |
Using const jsbi = require('jsbi') // 3.2.5 | |
Also if I update JSBI to the latest codebase (4.3.0) I get this: | |
Error: Convert JSBI instances to native numbers using toNumber. | |
OK I solved this: Apparently I had some version conflicts in my dependencies, I uninstalled all @uniswap stuff and reinstalled it fixed the issue. I want to say this was caused by the jsbi package but it wasnt that, probably some package lock stuff happening between other uni packages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment