Submitted by Abdessamed, also found by 0x1982us, 0xRajkumar, and DOWSERS
/contracts/pool-manager/src/helpers.rs#L182-L185
The spread represents the difference between the expected trade amount and the actual trade amount received during a swap. It is calculated to verify that the slippage remains within the user-defined tolerance during the swap operation. The spread formula varies depending on the pool type:
The issue, as highlighted above, is the fact that the spread is calculated based on the return_amount without excluding the fees. As a result, the calculated spread_amount is higher than intended in which the slippage tolerance check in assert_max_spread may pass, when it should not.
The calculated spread_amount is higher than the actual slippage because it includes the swap fees.
Consider subtracting the fees from return_amount before calculating the spread_amount.
jvr0x (MANTRA) confirmed
