The Mantra DEX implementation has reduced the number of Newton-Raphson iterations from Curves original 256 to 32:
/contracts/pool-manager/src/helpers.rs#L15-17
This reduction affects two critical calculations:
While Newton-Raphson typically converges quadratically (error is squared each iteration), this approach assumes the initial guess is sufficiently close to the root
However, in DeFi pools:
Would be key to note that the original 256 iterations on Curve werent really arbitrary and were also set up for stablecoin pools:
/contracts/pool-templates/base/SwapTemplateBase.vy#L445-L508
This is because they ensured convergence even in extreme edge cases where:
QA, considering this can be argued as intended implementation; however, subtle issues could be incorrect price calculations and as such unfair trades and even failed arbitrage opportunities, as this is all cumulative.
Consider increasing the number of iterations in the Newton-Raphson approximation.
