paco0x / amm-arbitrageur

An arbitrage bot between Uniswap AMMs
Do What The F*ck You Want To Public License
1.93k stars 827 forks source link

any chance writing the math for the max borrow amount on balancer and curve? #55

Open stefangabos opened 2 years ago

stefangabos commented 2 years ago

i am willing to pay for it

yoongyy commented 2 years ago

Me too

paco0x commented 2 years ago

For Balancer or Curve, it's quite complicated to solve for the best solution. Suggest to trying calculate it off-chain by using tools such as scipy or you can use an off-chain binary searching for an optimized borrow amount.

For Uniswap V3, I only suggest using binary searching for an optimized borrow amount.

samlaf commented 2 years ago

@stefangabos @yoongyy how much? I have a formulation that I'm using in my bots, that I'm willing to sell, depending on price and use case. Also have optimal amounts for triangular arbitrages.

yoongyy commented 2 years ago

@stefangabos @yoongyy how much? I have a formulation that I'm using in my bots, that I'm willing to sell, depending on price and use case. Also have optimal amounts for triangular arbitrages.

The important part is not the formula, but Balancer/Curve is Vault, so it is not like normal pool like WBNB/BUSD in PancakeSwap. I need the script to calculate the borrow amount from Vault and selling amount on Dex or from Dex to Vault, off chain and on chain (if possible).

edochigini commented 2 years ago

@paco0x Would you mind explaining a bit further the way you would implement the binary search for the optimized borrow amount? I'm trying to code my flashswap contract from scratch bit I'm struggling with this part

samlaf commented 2 years ago

@mtyou pm me on twitter @samlafer