Submitted by DadeKuma
/contracts/pool-manager/src/helpers.rs#L751
A StableSwap pool calculates the price using Newtons method to approximate the D value. This calculation might not converge in unbalanced pools, resulting in a wrong price, and in this case, it shouldnt be possible to swap.
However, this scenario is not prevented as the transaction will not revert even when the function does not converge.
The computation of D converges when the result is either 1 or 0; otherwise, it diverges. In the latter case, the pool is considered nonfunctional, as the StableSwap math will not work as intended.
In case a pool diverges, it shouldnt be possible to swap, but only to withdraw liquidity. This is implemented correctly in the original Curve implementation.
But in Mantra this is not the case, as the result is returned even if the computation did not converge:
/contracts/pool-manager/src/helpers.rs#L751
Consider the following fix:
Abdessamed (warden) commented:
DadeKuma (warden) commented:
jvr0x (MANTRA) confirmed and commented:
DadeKuma (warden) commented:
jvr0x (MANTRA) commented: 
