Define optimal AMM swap amount

Job ID: 36194811

Budget: $30 – $250 USD

I need some help on the math part of a personal project on how to calculate the optimal amount for a triangular arbitrage.