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?