Submitted by rbserver
The following mintTokenizedPosition function eventually calls the _createLegInAMM function below.
https://github.com/code-423n4/2024-04-panoptic/blob/855f58414589e93fa62e34890118164e8ac7822f/contracts/SemiFungiblePositionManager.sol#L504-L527
The _createLegInAMM function increases the removed liquidity when minting a long position by executing unchecked { removedLiquidity += chunkLiquidity } in which the related code comment states that we can't remove more liquidity than we add in the first place, so this can't overflow. However, minting contracts of the short and long positions repeatedly can actually increase the removed liquidity to overflow uint128, which means that the unchecked block is unsafe. When such overflow occurs, the accounting for the removed liquidity and liquidity becomes incorrect; in this case, the overflowed removed liquidity becomes less than it should be, and burning such overflowed removed liquidity would increase the liquidity by an amount that is less than it should be.
https://github.com/code-423n4/2024-04-panoptic/blob/855f58414589e93fa62e34890118164e8ac7822f/contracts/SemiFungiblePositionManager.sol#L958-L1104
Please add the following test in test\foundry\core\SemiFungiblePositionManager.t.sol. This test will pass to demonstrate the described scenario.
SemiFungiblePositionManager.sol#L1029-L1034 can be updated to the following code:
Under/Overflow
dyedm1 (Panoptic) confirmed
For this audit, 43 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by DadeKuma received the top score from the judge.
The following wardens also submitted reports: 99Crits, favelanky, cheatc0d3, slvDev, bareli, Rolezn, hihen, Dup1337, Bauchibred, 0xStalin, ZanyBonzy, albahaca, radin100, Naresh, grearlake, rbserver, d3e4, zabihullahazadzoi, Aymen0909, John_Femi, lanrebayode77, KupiaSec, jasonxiale, satoshispeedrunner, CodeWasp, sammy, pfapostol, Rhaydden, blockchainbuttonmasher, jesjupyter, mining_mario, twcctop, 0xhacksmithh, K42, Topmark, lsaudit, lirezArAzAvi, crc32, codeslide, oualidpro, Sathish9098, and IllIllI.
