poly-flashloan-bot icon indicating copy to clipboard operation
poly-flashloan-bot copied to clipboard

Fees calculation before send the transaction

Open ezera23 opened this issue 3 years ago • 2 comments

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:

  1. Get Quote
  2. Calculate each swap fees and add to it loan fees and ADD the slippery % (the one set in config.ts)
  3. Check the difference of % or calculate amount and check amount diff.
  4. 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.

https://polygonscan.com/address/0x3b89c1a54a2db96826b1319ae393b52a86938e60

ezera23 avatar Jan 14 '22 11:01 ezera23

i have similar output here https://polygonscan.com/address/0xb8fc2dc56022492292243994e0e20d0d38bdfa68

lhalpin333 avatar Feb 04 '22 19:02 lhalpin333