steem2sol failed because of floating arithmetic precision error

in sol •  6 months ago 

There are two swaps this morning, one succeeds and the other failed.

I added the Priority Fee a few days ago, so that shouldn't be a problem anymore. When I looked into the log, I was surprised to find out that:

Error transferring SOL: RangeError: The number 1034197046.9999999 cannot be converted to a BigInt because it is not an integer

So one paramerter to feed into the transfer SOL api is lamports, the smallest unit and it was like:

amountSOL * solanaWeb3.LAMPORTS PER SOL

The amountSOL is 1.0341970473037272 which multiples 1000000000 somehow becomes 1034197046.9999999 However, I check the console in Chrome, the multiplication answer is different: 1034197047.3037271

Anyway, I just have to truncate the decima values and this should fix the problem.

Thank you for using the Swap tool!

Steem to the Moon🚀!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!