front-running-bot
front-running-bot copied to clipboard
Error: invalid BigNumber string
Hi, great project, could you let me know how to fix this?
H:\abr\front-running-bot\node_modules@ethersproject\logger\lib\index.js:233 var error = new Error(message); ^
Error: invalid BigNumber string (argument="value", value="5.000000001", code=INVALID_ARGUMENT, version=bignumber/5.6.0) at Logger.throwError (H:\abr\front-running-bot\node_modules@ethersproject\logger\lib\index.js:242:20) at Logger.throwArgumentError (H:\abr\front-running-bot\node_modules@ethersproject\logger\lib\index.js:245:21) at Function.BigNumber.from (H:\abr\front-running-bot\node_modules@ethersproject\bignumber\lib\bignumber.js:201:27) at H:\abr\front-running-bot\node_modules@ethersproject\contracts\lib\index.js:215:61 at step (H:\abr\front-running-bot\node_modules@ethersproject\contracts\lib\index.js:48:23) at Object.next (H:\abr\front-running-bot\node_modules@ethersproject\contracts\lib\index.js:29:53) at fulfilled (H:\abr\front-running-bot\node_modules@ethersproject\contracts\lib\index.js:20:58) at processTicksAndRejections (node:internal/process/task_queues:96:5) { reason: 'invalid BigNumber string', code: 'INVALID_ARGUMENT', argument: 'value', value: '5.000000001'
similar issue here too
C:\Users\mc_ph\FrontRunningBot\node_modules@ethersproject\logger\lib\index.js:233 var error = new Error(message); ^
Error: invalid BigNumber string (argument="value", value="5.000000001", code=INVALID_ARGUMENT, version=bignumber/5.6.0) at Logger.makeError (C:\Users\mc_ph\FrontRunningBot\node_modules@ethersproject\logger\lib\index.js:233:21) at Logger.throwError (C:\Users\mc_ph\FrontRunningBot\node_modules@ethersproject\logger\lib\index.js:242:20) at Logger.throwArgumentError (C:\Users\mc_ph\FrontRunningBot\node_modules@ethersproject\logger\lib\index.js:245:21) at BigNumber.from (C:\Users\mc_ph\FrontRunningBot\node_modules@ethersproject\bignumber\lib\bignumber.js:201:27) at C:\Users\mc_ph\FrontRunningBot\node_modules@ethersproject\contracts\lib\index.js:215:61 at step (C:\Users\mc_ph\FrontRunningBot\node_modules@ethersproject\contracts\lib\index.js:48:23) at Object.next (C:\Users\mc_ph\FrontRunningBot\node_modules@ethersproject\contracts\lib\index.js:29:53) at fulfilled (C:\Users\mc_ph\FrontRunningBot\node_modules@ethersproject\contracts\lib\index.js:20:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { reason: 'invalid BigNumber string', code: 'INVALID_ARGUMENT', argument: 'value', value: '5.000000001' }
And me λ yarn start yarn run v1.22.18 $ node bot.js Listening on port 3888 value : 69.715398683401458951 gasPrice : 0.000000005 gasLimit : 0.00000000000016256 from 0x57B4eBf67440465F9d4A16c7aAC26650b08B84BA tokenAddress 0x55d398326f99059fF775485246999027B3197955 going to buy F:_Frontrunner_BSC\node_modules@ethersproject\logger\lib\index.js:233 var error = new Error(message); ^
Error: invalid BigNumber string (argument="value", value="5.000000001", code=INVALID_ARGUMENT, version=bignumber/5.6.2) at Logger.makeError (F:_Frontrunner_BSC\node_modules@ethersproject\logger\lib\index.js:233:21) at Logger.throwError (F:_Frontrunner_BSC\node_modules@ethersproject\logger\lib\index.js:242:20) at Logger.throwArgumentError (F:_Frontrunner_BSC\node_modules@ethersproject\logger\lib\index.js:245:21) at BigNumber.from (F:_Frontrunner_BSC\node_modules@ethersproject\bignumber\lib\bignumber.js:199:27) at F:_Frontrunner_BSC\node_modules@ethersproject\contracts\lib\index.js:215:61 at step (F:_Frontrunner_BSC\node_modules@ethersproject\contracts\lib\index.js:48:23) at Object.next (F:_Frontrunner_BSC\node_modules@ethersproject\contracts\lib\index.js:29:53) at fulfilled (F:_Frontrunner_BSC\node_modules@ethersproject\contracts\lib\index.js:20:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { reason: 'invalid BigNumber string', code: 'INVALID_ARGUMENT', argument: 'value', value: '5.000000001' }
Node.js v18.2.0 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Change to this, so it will add 1 gwei correctly:
if (action==="buy"){ return amount.add(1000000000); }else{ return amount.sub(1000000000);
any way the issue will persist, unable to fix it yet
I don't understand why, within buyToken() and swapExactETHForTokensSupportingFeeOnTransferTokens you have value, gasLimit and gasPrice?
(Date.now() + 1000 * 60 * 10), { 'value': amountIn, 'gasLimit': gasLimit, 'gasPrice': gasPrice, }
Also, why is the timestamp so long?
Removing everything between and including the braces removes this error: Uncaught Error Error: invalid BigNumber string (argument="value", value="5.000000001", code=INVALID_ARGUMENT, version=bignumber/5.5.0)
I fixed with bigNumber
function calculate_gas_price(action, amount){ console.log("amount",amount); if (action==="buy"){ const data=ethers.utils.formatUnits(amount.add(1000000000), 'wei') return ethers.BigNumber.from(data.toString())
}else{
const data=ethers.utils.formatUnits(amount.sub(1000000000), 'wei') return ethers.BigNumber.from(data.toString()) } }
I fixed with bigNumber
function calculate_gas_price(action, amount){ console.log("amount",amount); if (action==="buy"){ const data=ethers.utils.formatUnits(amount.add(1000000000), 'wei') return ethers.BigNumber.from(data.toString())
}else{
const data=ethers.utils.formatUnits(amount.sub(1000000000), 'wei') return ethers.BigNumber.from(data.toString()) } }
It work for you ? so i need to change 1 gwei by your number ?