Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting JSBI error while trying to swap 2 token in uinswap using v3-sdk #658

Open
Shivamycodee opened this issue Jul 13, 2023 · 0 comments

Comments

@Shivamycodee
Copy link

Hi, I am trying to perform a swap on uniswap using v3-sdk by following the code:

https://github.com/Uniswap/examples/blob/bbee4b974768ff1668ac56e27d1fe840060bb61b/v3-sdk/trading/src/libs/trading.ts

but while creating an uncheckedTrade and passing the amountOut:

const amountOut = await getOutputQuote(swapRoute);
const amountIn = fromReadableAmount("0.1", 18).toString();
console.log("amountIn : ",typeof amountIn,amountIn);

const uncheckedTrade = Trade.createUncheckedTrade({
route: swapRoute,
inputAmount: CurrencyAmount.fromRawAmount(
WMATIC,
amountIn
),
outputAmount: CurrencyAmount.fromRawAmount(
WETH,
JSBI.BigInt(amountOut) // here....
),
tradeType: TradeType.EXACT_INPUT,
});

I'm getting an error:

Error: Convert JSBI instances to native numbers using toNumber
but when i pass the amountOut directly in string format, the unckeced trade get successfully created but then i get an error in trade execution :

throw new Error('Could not parse fraction');   
^ Error: Could not parse fraction  

I'm trying to solve this issue for long time and tried other methods but didn't worked.
It would be great if anybody can help...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant