For the arithmetic operations that will never over/underflow, using the unchecked directive (Solidity v0.8 has default overflow/underflow checks) can save some gas from the unnecessary internal over/underflow checks.
reserve0 -= uint128(amount0fees); and reserve1 -= uint128(amount1fees); will never underlow, they can be put in a block with unchecked directive to save gas.
Handle
WatchPug
Vulnerability details
For the arithmetic operations that will never over/underflow, using the unchecked directive (Solidity v0.8 has default overflow/underflow checks) can save some gas from the unnecessary internal over/underflow checks.
For example:
ConcentratedLiquidityPool.sol#mint()
https://github.com/sushiswap/trident/blob/c405f3402a1ed336244053f8186742d2da5975e9/contracts/pool/concentrated/ConcentratedLiquidityPool.sol#L165-L171reserve0 -= uint128(amount0fees);
andreserve1 -= uint128(amount1fees);
will never underlow, they can be put in a block with unchecked directive to save gas.ConcentratedLiquidityPosition.sol#burn()
https://github.com/sushiswap/trident/blob/c405f3402a1ed336244053f8186742d2da5975e9/contracts/pool/concentrated/ConcentratedLiquidityPosition.sol#L67position.liquidity -= amount;
will never underlow.ConcentratedLiquidityPosition.sol#collect()
https://github.com/sushiswap/trident/blob/c405f3402a1ed336244053f8186742d2da5975e9/contracts/pool/concentrated/ConcentratedLiquidityPosition.sol#L108-L109
uint256 newBalance0 = amount0fees + balance0;
anduint256 newBalance1 = amount1fees + balance1;
will never overlow.ConcentratedLiquidityPool.sol#collectProtocolFee()
https://github.com/sushiswap/trident/blob/c405f3402a1ed336244053f8186742d2da5975e9/contracts/pool/concentrated/ConcentratedLiquidityPool.sol#L451
amount0 = token0ProtocolFee - 1;
andmount1 = token1ProtocolFee - 1;
will never underlow.