zack53 / Crypto-Arbitrage-Price-Bot

21 stars 8 forks source link

UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT #42

Closed gsngsn123 closed 2 years ago

gsngsn123 commented 2 years ago

hi i deployed contract on polygon and ran the bot with low amount difference for testing like 0.01

but the error is UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT

zack53 commented 2 years ago

@gsngsn123 I calculated a minimum output amount for the trade. You can set the minimum divider by sending an updated number to the function setMinimumProfitDividor. The default amount is 40000, which is a minimum of .25%. I get .25% by dividing 100/40000. You can look on line 136 of the AaveFlashLoanV3.sol file and you will see (amountIn/minimumProfitDividor). I calculate a minimum divider in hopes of getting a better trade.

You can either call the setMinimumProfitDividor and increase the number divided to decrease the profit minimum, or you can take out the amoutOutMin calculation I am doing and redeploy the code. The next piece though is that the Aave Flash Loan will revert if there isn't enough to pay back the premium.

I am still working on better ways to make this profitable. Below are four ideas that would help increase profitability: