front-running-bot icon indicating copy to clipboard operation
front-running-bot copied to clipboard

Error: invalid BigNumber string

Open p3140 opened this issue 2 years ago • 1 comments

Hello again, the bot is returning this error after calculating gas price in the function "calculate_gas_price". It seems that buy & sell functions requires BigNumber as input, but gas price is formated as string.

reason: 'invalid BigNumber string', code: 'INVALID_ARGUMENT', argument: 'value', value: '5.000000001'

If i leave the calculate_gas_price function as following, it is able to run but i am getting strange results like failed txs and buys not in the right time (it executes after the original tx instead of before).

function calculate_gas_price(action, amount){ if (action==="buy"){ return amount.add(1); }else{ return amount.sub(1); } }

p3140 avatar Apr 16 '22 00:04 p3140

Hi, I m facing the same issue. Anyway, fixing gas price does not solve the BigNumber issue.

You can change to this: if (action==="buy"){ return amount.add(1000000000); }else{ return amount.sub(1000000000);

I repeat, error persists

alxtrade avatar Jun 19 '22 17:06 alxtrade

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()) } }

dariobuzz avatar Nov 30 '22 10:11 dariobuzz