Submitted by DadeKuma
A possible wrong amount of the amount already swapped in/out of the input/output asset of a swap due to an unintended under/overflow.
In Rust release mode, the - and + operations will not revert when an underflow/overflow occurs.
As such, the amount can under/overflow in the while loop:
https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/seawater/src/pool.rs#L439
The issue is that these are not meant to under/overflow as seen in the original Uniswap logic, as they use SafeMath:
https://github.com/Uniswap/v3-core/blob/d8b1c635c275d2a9450bd6a78f3fa2484fef73eb/contracts/UniswapV3Pool.sol#L673-L679
Uniswap tests that state.amountSpecifiedRemaining > step.amountIn + step.feeAmount and thats why the operation is safe to use unchecked, but this is not the case with the second one, which must be checked:
https://github.com/Uniswap/v3-core/blob/0.8/contracts/UniswapV3Pool.sol#L681-L685
Consider using checked_sub instead of - (and checked_add instead of +):
Uniswap
af-afk (Superposition) confirmed 
0xsomeone (judge) commented:
