Fees need to be calculated before send the transaction to avoid 'Not enough amount to return loan', 'INSUFFICIENT_OUTPUT_AMOUNT' errors... It would be nice if you can implement something like this:
Get Quote
Calculate each swap fees and add to it loan fees and ADD the slippery % (the one set in config.ts)
Check the difference of % or calculate amount and check amount diff.
If difference % or amnt is +n (this should be a const in config.ts to include/edit MATIC fees as needed) so send transaction BUT if difference % or amnt -n or = 0 so do not send the transaction
Actually when you swap 3 times in one transactions it can be 0.05x3 = 0.15 % fees on top of the flashloans fees 0.09%... Total 0.24% and.... slippery can add it on top again if the bot takes to long time to get the quote :) Eg: 0.24 + 6 = 6.24%
'const diffAmount' should be here MORE than 1000 + 6.24% or 62.4 USD to return to loan BUT we don't know how many swaps will be done before getting the quote so this const doesn't really help for now (but interesting to get it there).
Everything need to be done in milliseconds.
To avoid "high slippery" Im testing some auto rotation proxies services directly in the CallUrl... (I'm not a dev so I try easy way first) in order to increase transactions speed. I'll continue my tests...
With all of this we may have much less opportunities but at least we will be able to get a profit from them when their is big prices movements and to make it works.
Fees need to be calculated before send the transaction to avoid 'Not enough amount to return loan', 'INSUFFICIENT_OUTPUT_AMOUNT' errors... It would be nice if you can implement something like this:
Actually when you swap 3 times in one transactions it can be 0.05x3 = 0.15 % fees on top of the flashloans fees 0.09%... Total 0.24% and.... slippery can add it on top again if the bot takes to long time to get the quote :) Eg: 0.24 + 6 = 6.24%
'const diffAmount' should be here MORE than 1000 + 6.24% or 62.4 USD to return to loan BUT we don't know how many swaps will be done before getting the quote so this const doesn't really help for now (but interesting to get it there).
Everything need to be done in milliseconds.
To avoid "high slippery" Im testing some auto rotation proxies services directly in the CallUrl... (I'm not a dev so I try easy way first) in order to increase transactions speed. I'll continue my tests...
With all of this we may have much less opportunities but at least we will be able to get a profit from them when their is big prices movements and to make it works.
https://polygonscan.com/address/0x3b89c1a54a2db96826b1319ae393b52a86938e60