jamesbachini / DEX-Arbitrage

Example arbitrage trading bot
GNU General Public License v3.0
615 stars 350 forks source link

UNPREDICTABLE_GAS_LIMIT #1

Closed Shandizzle4real closed 2 years ago

Shandizzle4real commented 2 years ago

Hello, I'm trying to figure out why I keep having UNPREDICTABLE_GAS_LIMIT issues. I've tried implementing manual gas limits with no success. I've tried putting gas & gasLimit settings in the hardhat.config.js file, and I tried manually adding gas settings in, "const tx = await arb.connect(owner).dualDexTrade(router1, router2, baseToken, token2, amount)" line of trade.js..

Keep getting, "Error: cannot estimate gas; transaction may fail or may require manual gas limit"

Anyone's input is welcome.. Thank you.

jamesbachini commented 2 years ago

I had this when trying it on Fantom, not sure what causes it but adding a manual gas price and limit in the dualDexTrade function solved it. I left it commented out on that line

const tx = await arb.connect(owner).dualDexTrade(router1, router2, baseToken, token2, amount, { gasPrice: 1000000000003, gasLimit: 500000 });

There's also a little script called scripts/gas.js which will find the current competitive gas price for the network you are on. Also worth looking in a block explorer at what other arb bots are paying.