1inch Plugin Swap Issue

Hey, I’m using the doSwap function from the boilerplate and keep getting a strange issue when the fromAmount is 10% rounded of the wallet balance.

  async function doSwap(params) {
    console.log(params);
    return await Moralis.Plugins.oneInch.swap({
      chain: params.chain, // The blockchain you want to use (eth/bsc/polygon)
      fromTokenAddress: params.fromToken.address, // The token you want to swap
      toTokenAddress: params.toToken.address, // The token you want to receive
      amount: Moralis.Units.Token(
        params.fromAmount,
        params.fromToken.decimals
      ).toString(),
      fromAddress: account, // Your wallet address
      slippage: 10,
    });
  }

Error: Something went wrong
"{\n “statusCode”: 500,\n “message”: “Not enough 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE. Amount: 68458313284481330. Balance: 684583132844813276.”\n}"

As you can see my balance is:
684583132844813276 and I try to swap
68458313284481330

When I use 68458313284481320 I will not get the error above.

Although the amount is only about 10% it should be able to swap, right? Any idea?

maybe you need to increase the slippage

No, I already tried this and it is working with not rounded digits though. I guess you can reproduce the issue with the given numbers.

what you mean with this?

you also have latest version of 1Inch plugin?

I mean it is working with 2 in the end and not 3. check here:
684583132844813276 balance
68458313284481330 not working
68458313284481320 working

Yes, the latest version. react-moralis: 1.1.0 and 1inch plugin shows: v0.0.30

but it works with 5 or 7 at the end?

i’ve been dealing with the same error, as well as others, see this post and history

it was fixed in latest version of 1Inch plugin