Instead of the using the bisection search algo, M-16 proposed a direct formula which would not miss the range of profitable arbitrage values which the previous algo was susceptible to missing.
Analysis
The provided formula, it's first derivative and hence the max value of bestArbAmountIn arrived at in the PRs are all correct and implemented in the code correctly, along with overflow protection.
Just for academic purposes, in case anyone is interested in validating the first derivative calculations, the step by step process of which were not described in detail in the issue report, then this link can be visited. The values match, as expected.
Lines of code
Vulnerability details
Summary
Instead of the using the bisection search algo, M-16 proposed a direct formula which would not miss the range of profitable arbitrage values which the previous algo was susceptible to missing.
Analysis
The provided formula, it's first derivative and hence the max value of
bestArbAmountIn
arrived at in the PRs are all correct and implemented in the code correctly, along with overflow protection. Just for academic purposes, in case anyone is interested in validating the first derivative calculations, the step by step process of which were not described in detail in the issue report, then this link can be visited. The values match, as expected.Conclusion
LGTM