Skip to content

Instantly share code, notes, and snippets.

@Alireza-Razavi
Created November 27, 2023 21:17
Show Gist options
  • Save Alireza-Razavi/a8d4a4612557063642ac53e661b52dd1 to your computer and use it in GitHub Desktop.
Save Alireza-Razavi/a8d4a4612557063642ac53e661b52dd1 to your computer and use it in GitHub Desktop.
{"comment":"Audit report for **2023-11-panoptic** generated by *ubl4nk_bot*.","footnote":"Thanks for reading this report :)","findings":[{"severity":"Medium","title":"Usage of `slot0` is extremely easy to manipulate","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n711: (, newTick, , , , , ) = univ3pool.slot0();\n\n775: (uint160 sqrtPriceX96, , , , , , ) = _univ3pool.slot0();\n```","loc":["[711](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L711)","[775](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L775)"]}]},{"severity":"Low","title":"Missing zero address check in functions with address parameters","description":"Adding a zero address check for each address type parameter can prevent errors.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit missing zero check for `token0`\n/// @audit missing zero check for `token1`\n351: function initializeAMMPool(address token0, address token1, uint24 fee) external {\n // compute the address of the Uniswap v3 pool for the given token0, token1, and fee tier\n\n/// @audit missing zero check for `from`\n/// @audit missing zero check for `to`\n545: address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts\n ) internal override {\n for (uint256 i = 0; i < ids.length; ) {\n\n/// @audit missing zero check for `from`\n/// @audit missing zero check for `to`\n564: address from,\n address to,\n uint256 id,\n uint256 amount\n ) internal override {\n registerTokenTransfer(from, to, id, amount);\n\n/// @audit missing zero check for `from`\n/// @audit missing zero check for `to`\n578: function registerTokenTransfer(address from, address to, uint256 id, uint256 amount) internal {\n // Extract univ3pool from the poolId map to Uniswap Pool\n\n/// @audit missing zero check for `univ3pool`\n744: IUniswapV3Pool univ3pool,\n int256 itmAmounts\n ) internal returns (int256 totalSwapped) {\n // Initialize variables\n bool zeroForOne; // The direction of the swap, true for token0 to token1, false for token1 to token0\n\n/// @audit missing zero check for `univ3pool`\n849: IUniswapV3Pool univ3pool,\n uint256 tokenId,\n uint128 positionSize,\n bool isBurn\n ) internal returns (int256 totalMoved, int256 totalCollected, int256 itmAmounts) {\n // upper bound on amount of tokens contained across all legs of the position at any given tick\n\n/// @audit missing zero check for `univ3pool`\n1094: IUniswapV3Pool univ3pool,\n uint128 liquidity,\n uint256 liquidityChunk\n ) private view returns (int256 feesBase) {\n // now collect fee growth within the liquidity chunk in `liquidityChunk`\n\n/// @audit missing zero check for `univ3pool`\n1130: uint256 liquidityChunk,\n IUniswapV3Pool univ3pool\n ) internal returns (int256 movedAmounts) {\n // build callback data\n bytes memory mintdata = abi.encode(\n\n/// @audit missing zero check for `univ3pool`\n1170: uint256 liquidityChunk,\n IUniswapV3Pool univ3pool\n ) internal returns (int256 movedAmounts) {\n // burn that option's liquidity in the Uniswap Pool.\n\n/// @audit missing zero check for `univ3pool`\n1201: uint256 liquidityChunk,\n IUniswapV3Pool univ3pool,\n uint256 currentLiquidity,\n bytes32 positionKey,\n int256 movedInLeg,\n uint256 isLong\n ) internal returns (int256 collectedOut) {\n uint128 startingLiquidity = currentLiquidity.rightSlot();\n\n/// @audit missing zero check for `univ3pool`\n/// @audit missing zero check for `owner`\n1344: address univ3pool,\n address owner,\n uint256 tokenType,\n int24 tickLower,\n int24 tickUpper\n ) external view returns (uint256 accountLiquidities) {\n /// Extract the account liquidity for a given uniswap pool, owner, token type, and ticks\n\n/// @audit missing zero check for `owner`\n1372: address univ3pool,\n address owner,\n uint256 tokenType,\n int24 tickLower,\n int24 tickUpper,\n int24 atTick,\n uint256 isLong\n ) external view returns (uint128 premiumToken0, uint128 premiumToken1) {\n bytes32 positionKey = keccak256(\n\n/// @audit missing zero check for `univ3pool`\n/// @audit missing zero check for `owner`\n1438: address univ3pool,\n address owner,\n uint256 tokenType,\n int24 tickLower,\n int24 tickUpper\n ) external view returns (int128 feesBase0, int128 feesBase1) {\n // Get accumulated fees for token0 (rightSlot) and token1 (leftSlot)\n\n/// @audit missing zero check for `univ3pool`\n1468: function getPoolId(address univ3pool) external view returns (uint64 poolId) {\n poolId = uint64(s_AddrToPoolIdData[univ3pool]);\n```","loc":["[351](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L351)","[545](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L545)","[564](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L564)","[578](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L578)","[744](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L744)","[849](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L849)","[1094](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1094)","[1130](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1130)","[1170](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1170)","[1201](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1201)","[1344](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1344)","[1372](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1372)","[1438](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1438)","[1468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1468)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n/// @audit missing zero check for `sender`\n/// @audit missing zero check for `factory`\n28: function validateCallback(\n address sender,\n address factory,\n PoolFeatures memory features\n ) internal pure {\n```","loc":["[28](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L28)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n/// @audit missing zero check for `univ3pool`\n54: function calculateAMMSwapFeesLiquidityChunk(\n IUniswapV3Pool univ3pool,\n int24 currentTick,\n uint128 startingLiquidity,\n uint256 liquidityChunk\n ) public view returns (int256 feesEachToken) {\n\n/// @audit missing zero check for `univ3pool`\n89: function _getAMMSwapFeesPerLiquidityCollected(\n IUniswapV3Pool univ3pool,\n int24 currentTick,\n int24 tickLower,\n int24 tickUpper\n ) internal view returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {\n```","loc":["[54](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L54)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L89)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n/// @audit missing zero check for `token0`\n/// @audit missing zero check for `token1`\n48: function getFinalPoolId(\n uint64 basePoolId,\n address token0,\n address token1,\n uint24 fee\n ) internal pure returns (uint64) {\n```","loc":["[48](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L48)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n/// @audit missing zero check for `token`\n/// @audit missing zero check for `from`\n/// @audit missing zero check for `to`\n16: function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L16)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit missing zero check for `operator`\n77: function setApprovalForAll(address operator, bool approved) public {\n\n/// @audit missing zero check for `from`\n90: function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public {\n\n/// @audit missing zero check for `from`\n128: function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) public virtual {\n\n/// @audit missing zero check for `from`\n236: function _burn(address from, uint256 id, uint256 amount) internal {\n\n/// @audit missing zero check for `from`\n/// @audit missing zero check for `to`\n252: function afterTokenTransfer(\n\n/// @audit missing zero check for `from`\n/// @audit missing zero check for `to`\n265: function afterTokenTransfer(\n```","loc":["[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L77)","[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L90)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L128)","[236](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L236)","[252](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L252)","[265](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L265)"]}]},{"severity":"Low","title":"Division by zero not prevented","description":"The divisions below take an input parameter that has no zero-value checks, which can cause the functions reverting if zero is passed.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n/// @audit `tickSpacing`\n385: int24 minTick = (Constants.MIN_V3POOL_TICK / tickSpacing) * tickSpacing;\n\n/// @audit `tickSpacing`\n386: int24 maxTick = (Constants.MAX_V3POOL_TICK / tickSpacing) * tickSpacing;\n```","loc":["[385](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L385)","[386](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L386)"]}]},{"severity":"Low","title":"Constructor / initialization function lacks parameter validation","description":"Constructors and initialization functions play a critical role in contracts by setting important initial states when the contract is first deployed before the system starts. The parameters passed to the constructor and initialization functions directly affect the behavior of the contract / protocol. If incorrect parameters are provided, the system may fail to run, behave abnormally, be unstable, or lack security. Therefore, it's crucial to carefully check each parameter in the constructor and initialization functions. If an exception is found, the transaction should be rolled back.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `_factory` not validated\n342: constructor(IUniswapV3Factory _factory) {\n```","loc":["[342](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L342)"]}]},{"severity":"Low","title":"Loss of precision in divisions","description":"Division by large numbers may result in the result being zero, due to solidity not supporting fractions. Consider requiring a minimum amount for the numerator to ensure that it is always larger than the denominator.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n229: s_accountPremiumOwed += feeGrowthX128 * R * (1 + ν*R/N) / R\n\n272: = ∆feeGrowthX128 * t * (T - R + ν*R^2/T) / N \n\n273: = ∆feeGrowthX128 * t * (N + ν*R^2/T) / N\n```","loc":["[229](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L229)","[272](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L272)","[273](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L273)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n363: return self.isLong(0) + self.isLong(1) + self.isLong(2) + self.isLong(3);\n\n385: int24 minTick = (Constants.MIN_V3POOL_TICK / tickSpacing) * tickSpacing;\n\n386: int24 maxTick = (Constants.MAX_V3POOL_TICK / tickSpacing) * tickSpacing;\n```","loc":["[363](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L363)","[385](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L385)","[386](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L386)"]}]},{"severity":"Low","title":"Missing checks for state variable assignments","description":"There are some missing checks in these functions, and this could lead to unexpected scenarios. Consider always adding a sanity check for state variables.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `_factory`\n346: /// @notice Initialize a Uniswap v3 pool in the SemifungiblePositionManager contract\n```","loc":["[346](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L346)"]}]},{"severity":"Low","title":"Missing zero address check in constructor","description":"Constructors often take address parameters to initialize important components of a contract, such as owner or linked contracts. However, without a checking, there's a risk that an address parameter could be mistakenly set to the zero address (0x0). This could be due to an error or oversight during contract deployment. A zero address in a crucial role can cause serious issues, as it cannot perform actions like a normal address, and any funds sent to it will be irretrievable. It's therefore crucial to include a zero address check in constructors to prevent such potential problems. If a zero address is detected, the constructor should revert the transaction.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit missing zero check for `_factory`\n342: constructor(IUniswapV3Factory _factory) {\n FACTORY = _factory;\n }\n \n /// @notice Initialize a Uniswap v3 pool in the SemifungiblePositionManager contract\n```","loc":["[342](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L342)"]}]},{"severity":"Low","title":"Consider some checks for `address(0)` when setting address state variables","description":"Check for zero-address to avoid the risk of setting `address(0)` for state variables after an update.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `_factory`\n346: /// @notice Initialize a Uniswap v3 pool in the SemifungiblePositionManager contract\n```","loc":["[346](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L346)"]}]},{"severity":"Low","title":"Multiplication on the result of a division","description":"Dividing an integer by another integer will often result in loss of precision. When the result is multiplied by another number, the loss of precision is magnified, often to material magnitudes. `(X / Z) * Y` should be re-written as `(X * Y) / Z`","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n385: int24 minTick = (Constants.MIN_V3POOL_TICK / tickSpacing) * tickSpacing;\n\n386: int24 maxTick = (Constants.MAX_V3POOL_TICK / tickSpacing) * tickSpacing;\n```","loc":["[385](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L385)","[386](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L386)"]}]},{"severity":"Low","title":"Solidity version 0.8.20 or above may not work on other chains due to PUSH0","description":"Solidity version 0.8.20 or above uses the new [Shanghai EVM](https://blog.soliditylang.org/2023/05/10/solidity-0.8.20-release-announcement/#important-note) which introduces the PUSH0 opcode. This op code may not yet be implemented on all evm-chains or Layer2s, so deployment on these chains will fail. Consider using an earlier solidity version.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L2)"]}]},{"severity":"Low","title":"Tokens may be minted to `address(0)`","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n214: function _mint(address to, uint256 id, uint256 amount) internal {\n // balance will never overflow\n unchecked {\n balanceOf[to][id] += amount;\n }\n \n emit TransferSingle(msg.sender, address(0), to, id, amount);\n \n if (to.code.length != 0) {\n if (\n ERC1155Holder(to).onERC1155Received(msg.sender, address(0), id, amount, \"\") !=\n ERC1155Holder.onERC1155Received.selector\n ) {\n revert UnsafeRecipient();\n }\n }\n }\n```","loc":["[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L214)"]}]},{"severity":"Low","title":"Unsafe downcast","description":"When a type is downcast to a smaller type, the higher order bits are truncated, effectively applying a modulo to the original value. Without any other checks, this wrapping will lead to unexpected behavior and bugs.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit uint256 -> uint128\n590: univ3pool.tickSpacing()\n\n/// @audit int256 -> int128\n1120: .toRightSlot(int128(int256(Math.mulDiv128(feeGrowthInside0LastX128, liquidity))))\n\n/// @audit int256 -> int128\n1121: .toLeftSlot(int128(int256(Math.mulDiv128(feeGrowthInside1LastX128, liquidity))));\n\n/// @audit int256 -> int128\n1160: int128(int256(amount1))\n\n/// @audit int256 -> int128\n1162: }\n\n/// @audit int256 -> int128\n1187: -int128(int256(amount1))\n\n/// @audit int256 -> int128\n1189: }\n\n/// @audit uint256 -> uint64\n1470: }\n```","loc":["[590](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L590)","[1120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1120)","[1121](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1121)","[1160](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1160)","[1162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1162)","[1187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1187)","[1189](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1189)","[1470](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1470)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n/// @audit uint256 -> uint160\n37: uint160(\n```","loc":["[37](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L37)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n/// @audit int256 -> int128\n76: .toRightSlot(int128(int256(Math.mulDiv128(ammFeesPerLiqToken0X128, startingLiquidity))))\n\n/// @audit int256 -> int128\n77: .toLeftSlot(int128(int256(Math.mulDiv128(ammFeesPerLiqToken1X128, startingLiquidity))));\n```","loc":["[76](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L76)","[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L77)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n/// @audit uint256 -> uint160\n89: sqrtPriceX96 = uint160((sqrtR >> 32) + (sqrtR % (1 << 32) == 0 ? 0 : 1));\n\n/// @audit uint256 -> uint128\n173: if ((downcastedInt = uint128(toDowncast)) != toDowncast) revert Errors.CastingError();\n```","loc":["[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L89)","[173](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L173)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n/// @audit uint160 -> uint64\n39: return uint64(uint160(univ3pool) >> 96);\n\n/// @audit uint256 -> uint64\n57: (uint64(uint256(keccak256(abi.encodePacked(token0, token1, fee)))) >> 32);\n```","loc":["[39](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L39)","[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L57)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n/// @audit uint256 -> uint128\n26: return uint128(self);\n\n/// @audit int256 -> int128\n33: return int128(self);\n\n/// @audit uint256 -> uint128\n90: return uint128(self >> 128);\n\n/// @audit int256 -> int128\n97: return int128(self >> 128);\n\n/// @audit uint256 -> uint128\n151: if (z < x || (uint128(z) < uint128(x))) revert Errors.UnderOverFlow();\n\n/// @audit uint256 -> uint128\n151: if (z < x || (uint128(z) < uint128(x))) revert Errors.UnderOverFlow();\n\n/// @audit int256 -> int128\n162: int128 left128 = int128(left256);\n\n/// @audit int256 -> int128\n165: int128 right128 = int128(right256);\n\n/// @audit int256 -> int128\n180: int128 left128 = int128(left256);\n\n/// @audit int256 -> int128\n183: int128 right128 = int128(right256);\n\n/// @audit int256 -> int128\n199: if (!((selfAsInt128 = int128(self)) == self)) revert Errors.CastingError();\n\n/// @audit uint256 -> uint128\n206: if (!((selfAsUint128 = uint128(self)) == self)) revert Errors.CastingError();\n```","loc":["[26](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L26)","[33](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L33)","[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L90)","[97](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L97)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L151)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L151)","[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L162)","[165](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L165)","[180](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L180)","[183](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L183)","[199](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L199)","[206](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L206)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n/// @audit int256 -> int24\n114: return int24(int256(self >> 232));\n\n/// @audit int256 -> int24\n123: return int24(int256(self >> 208));\n\n/// @audit uint256 -> uint128\n132: return uint128(self);\n```","loc":["[114](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L114)","[123](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L123)","[132](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L132)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n/// @audit uint256 -> uint64\n82: return uint64(self);\n\n/// @audit int256 -> int24\n151: return int24(int256(self >> (64 + legIndex * 48 + 12)));\n\n/// @audit int256 -> int24\n162: return int24(int256((self >> (64 + legIndex * 48 + 36)) % 4096));\n```","loc":["[82](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L82)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L151)","[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L162)"]}]},{"severity":"Low","title":"Unsafe solidity low-level call can cause gas grief attack","description":"Using the low-level calls of a solidity address can leave the contract open to gas grief attacks. These attacks occur when the called contract returns a large amount of data. So when calling an external contract, it is necessary to check the length of the return data before reading/copying it (using `returndatasize()`).","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n15: (bool success, bytes memory result) = address(this).delegatecall(data[i]);\n```","loc":["[15](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L15)"]}]},{"severity":"Low","title":"Using zero as a parameter","description":"Taking `0` as a valid argument in Solidity without checks can lead to severe security issues. A historical example is the infamous `0x0` address bug where numerous tokens were lost. This happens because 0 can be interpreted as an uninitialized `address`, leading to transfers to the 0x0 address, effectively burning tokens. Moreover, `0` as a denominator in division operations would cause a runtime exception. It's also often indicative of a logical error in the caller's code. It's important to always validate input and handle edge cases like `0` appropriately. Use `require()` statements to enforce conditions and provide clear error messages to facilitate debugging and safer code.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n683: if (univ3pool == IUniswapV3Pool(address(0))) revert Errors.UniswapPoolNotInitialized();\n```","loc":["[683](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L683)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n220: emit TransferSingle(msg.sender, address(0), to, id, amount);\n\n239: emit TransferSingle(msg.sender, from, address(0), id, amount);\n```","loc":["[220](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L220)","[239](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L239)"]}]},{"severity":"Low","title":"Missing zero address check in initializer","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit missing zero check for `token0`\n/// @audit missing zero check for `token1`\n351: function initializeAMMPool(address token0, address token1, uint24 fee) external {\n // compute the address of the Uniswap v3 pool for the given token0, token1, and fee tier\n```","loc":["[351](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L351)"]}]},{"severity":"Low","title":" `abi.encodePacked()` should not be used with dynamic types when passing the result to a hash function such as `keccak256()`","description":"Use `abi.encode()` instead which will pad items to 32 bytes, which will [prevent hash collisions](https://docs.soliditylang.org/en/v0.8.13/abi-spec.html#non-standard-packed-mode) (e.g. `abi.encodePacked(0x123,0x456)` => `0x123456` => `abi.encodePacked(0x1,0x23456)`, but `abi.encode(0x123,0x456)` => `0x0...1230...456`). \"Unless there is a compelling reason, `abi.encode` should be preferred\". If there is only one argument to `abi.encodePacked()` it can often be cast to `bytes()` or `bytes32()` [instead](https://ethereum.stackexchange.com/questions/30912/how-to-compare-strings-in-solidity#answer-82739).\nIf all arguments are strings and or bytes, `bytes.concat()` should be used instead","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n1353: keccak256(abi.encodePacked(univ3pool, owner, tokenType, tickLower, tickUpper))\n\n1446: keccak256(abi.encodePacked(univ3pool, owner, tokenType, tickLower, tickUpper))\n```","loc":["[1353](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1353)","[1446](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1446)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n57: (uint64(uint256(keccak256(abi.encodePacked(token0, token1, fee)))) >> 32);\n```","loc":["[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L57)"]}]},{"severity":"NonCritical","title":"Assembly blocks should have extensive comments","description":"Assembly blocks take a lot more time to audit than normal Solidity code, and often have gotchas and side-effects that the Solidity versions of the same code do not. Consider adding more comments explaining what is being done in every step of the assembly code, and describe why assembly is being used instead of Solidity.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n394: mstore(0, 0xFA20F71C)\n```","loc":["[394](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L394)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n199: assembly (\"memory-safe\") {\n\n208: assembly (\"memory-safe\") {\n\n225: assembly (\"memory-safe\") {\n\n229: assembly (\"memory-safe\") {\n\n239: assembly (\"memory-safe\") {\n\n244: assembly (\"memory-safe\") {\n\n250: assembly (\"memory-safe\") {\n\n295: assembly (\"memory-safe\") {\n\n303: assembly (\"memory-safe\") {\n\n320: assembly (\"memory-safe\") {\n\n324: assembly (\"memory-safe\") {\n\n330: assembly (\"memory-safe\") {\n\n357: assembly (\"memory-safe\") {\n\n365: assembly (\"memory-safe\") {\n\n382: assembly (\"memory-safe\") {\n\n386: assembly (\"memory-safe\") {\n\n392: assembly (\"memory-safe\") {\n\n419: assembly (\"memory-safe\") {\n\n427: assembly (\"memory-safe\") {\n\n444: assembly (\"memory-safe\") {\n\n448: assembly (\"memory-safe\") {\n\n454: assembly (\"memory-safe\") {\n\n481: assembly (\"memory-safe\") {\n\n489: assembly (\"memory-safe\") {\n\n506: assembly (\"memory-safe\") {\n\n510: assembly (\"memory-safe\") {\n\n516: assembly (\"memory-safe\") {\n```","loc":["[199](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L199)","[208](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L208)","[225](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L225)","[229](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L229)","[239](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L239)","[244](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L244)","[250](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L250)","[295](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L295)","[303](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L303)","[320](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L320)","[324](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L324)","[330](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L330)","[357](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L357)","[365](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L365)","[382](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L382)","[386](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L386)","[392](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L392)","[419](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L419)","[427](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L427)","[444](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L444)","[448](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L448)","[454](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L454)","[481](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L481)","[489](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L489)","[506](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L506)","[510](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L510)","[516](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L516)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n19: assembly (\"memory-safe\") {\n```","loc":["[19](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L19)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n25: assembly (\"memory-safe\") {\n```","loc":["[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L25)"]}]},{"severity":"NonCritical","title":"`abi.encodePacked()` should be replaced with `bytes.concat()`","description":"Solidity version 0.8.4 introduces `bytes.concat()`, which can be used to replace `abi.encodePacked()` on bytes/strings. It can make the intended operation clearer, leading to less reviewer confusion.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n595: abi.encodePacked(\n\n604: abi.encodePacked(\n\n946: abi.encodePacked(\n\n1105: abi.encodePacked(\n\n1353: keccak256(abi.encodePacked(univ3pool, owner, tokenType, tickLower, tickUpper))\n\n1381: abi.encodePacked(address(univ3pool), owner, tokenType, tickLower, tickUpper)\n\n1446: keccak256(abi.encodePacked(univ3pool, owner, tokenType, tickLower, tickUpper))\n```","loc":["[595](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L595)","[604](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L604)","[946](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L946)","[1105](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1105)","[1353](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1353)","[1381](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1381)","[1446](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1446)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n40: abi.encodePacked(\n```","loc":["[40](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L40)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n57: (uint64(uint256(keccak256(abi.encodePacked(token0, token1, fee)))) >> 32);\n```","loc":["[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L57)"]}]},{"severity":"NonCritical","title":"Multiple `address`/ID mappings can be combined into a single `mapping` of an `address`/ID to a `struct`, for readability","description":"Well-organized data structures make code reviews easier, which may lead to fewer bugs. Consider combining related mappings into mappings to structs, so it's clear what data is related","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n62: mapping(address account => mapping(uint256 tokenId => uint256 balance)) public balanceOf;\n\n67: mapping(address owner => mapping(address operator => bool approvedForAll))\n```","loc":["[62](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L62)","[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L67)"]}]},{"severity":"NonCritical","title":"Complex casting","description":"Consider whether the number of casts is really necessary, or whether using a different type would be more appropriate. Alternatively, add comments to explain in detail why the casts are necessary, and any implicit reasons why the cast does not introduce an overflow.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n1120: .toRightSlot(int128(int256(Math.mulDiv128(feeGrowthInside0LastX128, liquidity))))\n\n1121: .toLeftSlot(int128(int256(Math.mulDiv128(feeGrowthInside1LastX128, liquidity))));\n\n1159: movedAmounts = int256(0).toRightSlot(int128(int256(amount0))).toLeftSlot(\n\n1160: int128(int256(amount1))\n\n1186: movedAmounts = int256(0).toRightSlot(-int128(int256(amount0))).toLeftSlot(\n\n1187: -int128(int256(amount1))\n```","loc":["[1120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1120)","[1121](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1121)","[1159](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1159)","[1160](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1160)","[1186](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1186)","[1187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1187)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n76: .toRightSlot(int128(int256(Math.mulDiv128(ammFeesPerLiqToken0X128, startingLiquidity))))\n\n77: .toLeftSlot(int128(int256(Math.mulDiv128(ammFeesPerLiqToken1X128, startingLiquidity))));\n```","loc":["[76](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L76)","[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L77)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n40: uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n\n41: if (absTick > uint256(int256(Constants.MAX_V3POOL_TICK))) revert Errors.InvalidTick();\n```","loc":["[40](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L40)","[41](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L41)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n39: return uint64(uint160(univ3pool) >> 96);\n\n57: (uint64(uint256(keccak256(abi.encodePacked(token0, token1, fee)))) >> 32);\n```","loc":["[39](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L39)","[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L57)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n57: return self + uint256(int256(right));\n\n67: return self + int256(uint256(right));\n\n120: return self + (int256(int128(left)) << 128);\n```","loc":["[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L57)","[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L67)","[120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L120)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n90: return self + (uint256(uint24(_tickLower)) << 232);\n\n101: return self + ((uint256(uint24(_tickUpper))) << 208);\n\n114: return int24(int256(self >> 232));\n\n123: return int24(int256(self >> 208));\n```","loc":["[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L90)","[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L101)","[114](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L114)","[123](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L123)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n151: return int24(int256(self >> (64 + legIndex * 48 + 12)));\n\n162: return int24(int256((self >> (64 + legIndex * 48 + 36)) % 4096));\n\n283: return self + (uint256(uint24(_width) % 4096) << (64 + legIndex * 48 + 36));\n```","loc":["[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L151)","[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L162)","[283](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L283)"]}]},{"severity":"NonCritical","title":"Consider adding a block/deny-list","description":"Doing so will significantly increase centralization, but will help to prevent hackers from using stolen tokens.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n72: contract SemiFungiblePositionManager is ERC1155, Multicall {\n```","loc":["[72](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L72)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n8: abstract contract Multicall {\n```","loc":["[8](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L8)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n10: abstract contract ERC1155 {\n```","loc":["[10](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L10)"]}]},{"severity":"NonCritical","title":"Consider adding emergency-stop functionality","description":"Consider adding `Pausable` to the following contracts so it's possible to stop them in case of an emergency.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n72: contract SemiFungiblePositionManager is ERC1155, Multicall {\n```","loc":["[72](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L72)"]}]},{"severity":"NonCritical","title":"Consider adding formal verification proofs","description":"Formal verification is the act of proving or disproving the correctness of intended algorithms underlying a system with respect to a certain formal specification/property/invariant, using formal methods of mathematics.\n\nSome tools that are currently available to perform these tests on smart contracts are [SMTChecker](https://docs.soliditylang.org/en/latest/smtchecker.html) and [Certora Prover](https://www.certora.com/).","gasSavings":null,"category":null,"instances":[{"content":"```solidity\n\nGlobal finding\n```","loc":["[1](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/)"]}]},{"severity":"NonCritical","title":"Consider bounding input array length","description":"The functions below take in an unbounded array, and make function calls for entries in the array. While the function will revert if it eventually runs out of gas, it may be a nicer user experience to require() that the length of the array is below some reasonable maximum, so that the user doesn't have to use up a full transaction's gas only to see that the transaction reverts.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit consider length check for `ids`\n550: for (uint256 i = 0; i < ids.length; ) {\n```","loc":["[550](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L550)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n/// @audit consider length check for `data`\n14: for (uint256 i = 0; i < data.length; ) {\n```","loc":["[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L14)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit consider length check for `ids`\n141: for (uint256 i = 0; i < ids.length; ) {\n\n/// @audit consider length check for `owners`\n187: for (uint256 i = 0; i < owners.length; ++i) {\n```","loc":["[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L141)","[187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L187)"]}]},{"severity":"NonCritical","title":"Consider using descriptive `constant`s when passing zero as a function argument","description":"Passing zero as a function argument can sometimes result in a security issue (e.g. passing zero as the slippage parameter). Consider using a `constant` variable with a descriptive name, so it's clear that the argument is intentionally being used, and for the right reasons.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n1398: uint256 tempChunk = uint256(0).createChunk(tickLower, tickUpper, 0);\n // how much fees have been accumulated within the liquidity chunk since last time we updated this chunk?\n```","loc":["[1398](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1398)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n363: return self.isLong(0) + self.isLong(1) + self.isLong(2) + self.isLong(3);\n\n464: if (self.optionRatio(0) == 0) revert Errors.InvalidTokenIdParameter(1);\n```","loc":["[363](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L363)","[464](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L464)"]}]},{"severity":"NonCritical","title":"Constants should be put on the left side of comparisons","description":"Putting constants on the left side of comparison statements is a best practice known as [Yoda conditions](https://en.wikipedia.org/wiki/Yoda_conditions). Although solidity's static typing system prevents accidental assignments within conditionals, adopting this practice can improve code readability and consistency, especially when working across multiple languages.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n356: if (address(univ3pool) == address(0)) revert Errors.UniswapPoolNotInitialized();\n\n363: if (s_AddrToPoolIdData[univ3pool] != 0) return;\n\n370: while (address(s_poolContext[poolId].pool) != address(0)) {\n\n615: (s_accountLiquidity[positionKey_to] != 0) ||\n\n616: (s_accountFeesBase[positionKey_to] != 0)\n\n671: if (positionSize == 0) revert Errors.OptionsBalanceZero();\n\n706: if ((itmAmounts != 0) && (swapAtMint)) {\n\n774: if ((itm0 != 0) && (itm1 != 0)) {\n\n810: } else if (itm0 != 0) {\n\n820: if (swapAmount == 0) return int256(0);\n\n971: if (isLong == 0) {\n\n1043: if (_tokenType == 0) {\n\n1217: if (amountToCollect != 0) {\n\n1394: if (netLiquidity != 0) {\n```","loc":["[356](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L356)","[363](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L363)","[370](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L370)","[615](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L615)","[616](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L616)","[671](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L671)","[706](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L706)","[774](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L774)","[810](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L810)","[820](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L820)","[971](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L971)","[1043](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1043)","[1217](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1217)","[1394](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1394)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n47: if (absTick & 0x2 != 0) sqrtR = (sqrtR * 0xfff97272373d413259a46990580e213a) >> 128;\n\n49: if (absTick & 0x4 != 0) sqrtR = (sqrtR * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n\n51: if (absTick & 0x8 != 0) sqrtR = (sqrtR * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n\n53: if (absTick & 0x10 != 0) sqrtR = (sqrtR * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n\n55: if (absTick & 0x20 != 0) sqrtR = (sqrtR * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n\n57: if (absTick & 0x40 != 0) sqrtR = (sqrtR * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n\n59: if (absTick & 0x80 != 0) sqrtR = (sqrtR * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n\n61: if (absTick & 0x100 != 0) sqrtR = (sqrtR * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n\n63: if (absTick & 0x200 != 0) sqrtR = (sqrtR * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n\n65: if (absTick & 0x400 != 0) sqrtR = (sqrtR * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n\n67: if (absTick & 0x800 != 0) sqrtR = (sqrtR * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n\n69: if (absTick & 0x1000 != 0) sqrtR = (sqrtR * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n\n71: if (absTick & 0x2000 != 0) sqrtR = (sqrtR * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n\n73: if (absTick & 0x4000 != 0) sqrtR = (sqrtR * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n\n75: if (absTick & 0x8000 != 0) sqrtR = (sqrtR * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n\n77: if (absTick & 0x10000 != 0) sqrtR = (sqrtR * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n\n79: if (absTick & 0x20000 != 0) sqrtR = (sqrtR * 0x5d6af8dedb81196699c329225ee604) >> 128;\n\n81: if (absTick & 0x40000 != 0) sqrtR = (sqrtR * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n\n83: if (absTick & 0x80000 != 0) sqrtR = (sqrtR * 0x48a170391f7dc42444e8fa2) >> 128;\n\n89: sqrtPriceX96 = uint160((sqrtR >> 32) + (sqrtR % (1 << 32) == 0 ? 0 : 1));\n\n206: if (prod1 == 0) {\n\n302: if (prod1 == 0) {\n\n364: if (prod1 == 0) {\n\n426: if (prod1 == 0) {\n\n488: if (prod1 == 0) {\n```","loc":["[47](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L47)","[49](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L49)","[51](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L51)","[53](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L53)","[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L55)","[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L57)","[59](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L59)","[61](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L61)","[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L63)","[65](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L65)","[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L67)","[69](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L69)","[71](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L71)","[73](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L73)","[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L75)","[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L77)","[79](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L79)","[81](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L81)","[83](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L83)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L89)","[206](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L206)","[302](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L302)","[364](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L364)","[426](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L426)","[488](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L488)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n120: if (tokenId.asset(legIndex) == 0) {\n```","loc":["[120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L120)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n110: if (to.code.length != 0) {\n\n163: if (to.code.length != 0) {\n\n222: if (to.code.length != 0) {\n```","loc":["[110](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L110)","[163](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L163)","[222](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L222)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n443: if (i == 0)\n\n464: if (self.optionRatio(0) == 0) revert Errors.InvalidTokenIdParameter(1);\n\n469: if (self.optionRatio(i) == 0) {\n\n473: if ((self >> (64 + 48 * i)) != 0) revert Errors.InvalidTokenIdParameter(1);\n\n480: if ((self.width(i) == 0)) revert Errors.InvalidTokenIdParameter(5);\n```","loc":["[443](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L443)","[464](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L464)","[469](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L469)","[473](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L473)","[480](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L480)"]}]},{"severity":"NonCritical","title":"Contract does not follow the Solidity Style Guide's suggested layout ordering","description":"The [style guide](https://docs.soliditylang.org/en/v0.8.16/style-guide.html#order-of-layout) says that, within a contract, the ordering should be `1) Type declarations`, `2) State variables`, `3) Events`, `4) Modifiers`, and `5) Functions`, but the contract(s) below do not follow this ordering","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n117: struct PoolAddressAndLock {\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n127: bool internal constant MINT = false;\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n128: bool internal constant BURN = true;\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n135: uint128 private constant VEGOID = 2;\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n139: IUniswapV3Factory internal immutable FACTORY;\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n147: mapping(address univ3pool => uint256 poolIdData) internal s_AddrToPoolIdData;\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n152: mapping(uint64 poolId => PoolAddressAndLock contextData) internal s_poolContext;\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n179: mapping(bytes32 positionKey => uint256 removedAndNetLiquidity) internal s_accountLiquidity;\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n288: mapping(bytes32 positionKey => uint256 accountPremium) private s_accountPremiumOwed;\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n290: mapping(bytes32 positionKey => uint256 accountPremium) private s_accountPremiumGross;\n\n/// @audit event/error `PoolInitialized` came earlier\n/// @audit event/error `TokenizedPositionBurnt` came earlier\n/// @audit event/error `TokenizedPositionMinted` came earlier\n296: mapping(bytes32 positionKey => int256 baseFees0And1) internal s_accountFeesBase;\n```","loc":["[117](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L117)","[127](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L127)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L128)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L135)","[139](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L139)","[147](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L147)","[152](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L152)","[179](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L179)","[288](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L288)","[290](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L290)","[296](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L296)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit event/error `TransferSingle` came earlier\n/// @audit event/error `TransferBatch` came earlier\n/// @audit event/error `ApprovalForAll` came earlier\n/// @audit event/error `NotAuthorized` came earlier\n/// @audit event/error `UnsafeRecipient` came earlier\n62: mapping(address account => mapping(uint256 tokenId => uint256 balance)) public balanceOf;\n\n/// @audit event/error `TransferSingle` came earlier\n/// @audit event/error `TransferBatch` came earlier\n/// @audit event/error `ApprovalForAll` came earlier\n/// @audit event/error `NotAuthorized` came earlier\n/// @audit event/error `UnsafeRecipient` came earlier\n67: mapping(address owner => mapping(address operator => bool approvedForAll))\n```","loc":["[62](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L62)","[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L67)"]}]},{"severity":"NonCritical","title":"Contract should expose an `interface`","description":"All `external`/`public` functions should extend an `interface`. This is useful to make sure that the whole API is extracted.\n\n*Note:* It is possible that the interface is out-of-scope and has not been seen by the bot.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n351: function initializeAMMPool(address token0, address token1, uint24 fee) external {\n\n408: uint256 amount0Owed,\n\n442: int256 amount0Delta,\n\n477: uint256 tokenId,\n\n511: uint256 tokenId,\n\n1344: address univ3pool,\n\n1372: address univ3pool,\n\n1438: address univ3pool,\n\n1458: uint64 poolId\n\n1468: function getPoolId(address univ3pool) external view returns (uint64 poolId) {\n```","loc":["[351](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L351)","[408](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L408)","[442](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L442)","[477](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L477)","[511](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L511)","[1344](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1344)","[1372](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1372)","[1438](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1438)","[1458](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1458)","[1468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1468)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n12: function multicall(bytes[] calldata data) public payable returns (bytes[] memory results) {\n```","loc":["[12](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L12)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n77: function setApprovalForAll(address operator, bool approved) public {\n\n90: function safeTransferFrom(\n\n128: function safeBatchTransferFrom(\n\n178: function balanceOfBatch(\n\n200: function supportsInterface(bytes4 interfaceId) public pure returns (bool) {\n```","loc":["[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L77)","[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L90)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L128)","[178](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L178)","[200](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L200)"]}]},{"severity":"NonCritical","title":"Contracts should have full test coverage","description":"While 100% code coverage does not guarantee that there are no bugs, it often will catch easy-to-find bugs, and will ensure that there are fewer regressions when the code invariably has to be modified. Furthermore, in order to get full coverage, code authors will often have to re-organize their code so that it is more modular, so that each component can be tested separately, which reduces interdependencies between modules and layers, and makes for code that is easier to reason about and audit.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\n\nGlobal finding\n```","loc":["[1](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/)"]}]},{"severity":"NonCritical","title":"Convert simple `if` statements to ternary expressions","description":"Converting some if statements to ternaries (such as `z = (a < b) ? x : y`) can make the code more concise and easier to read.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n120: if (tokenId.asset(legIndex) == 0) {\n legLiquidity = Math.getLiquidityForAmount0(\n uint256(0).addTickLower(tickLower).addTickUpper(tickUpper),\n amount\n );\n } else {\n legLiquidity = Math.getLiquidityForAmount1(\n```","loc":["[120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L120)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n343: } else if (optionRatios < 2 ** 208) {\n optionRatios = 3;\n } else {\n optionRatios = 4;\n```","loc":["[343](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L343)"]}]},{"severity":"NonCritical","title":"Events that mark critical parameter changes should contain both the old and the new value","description":"This should especially be done if the new value is not required to be different from the old value.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n386: emit PoolInitialized(univ3pool);\n\n490: emit TokenizedPositionBurnt(msg.sender, tokenId, positionSize);\n\n523: emit TokenizedPositionMinted(msg.sender, tokenId, positionSize);\n```","loc":["[386](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L386)","[490](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L490)","[523](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L523)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n80: emit ApprovalForAll(msg.sender, operator, approved);\n\n108: emit TransferSingle(msg.sender, from, to, id, amount);\n\n161: emit TransferBatch(msg.sender, from, to, ids, amounts);\n\n220: emit TransferSingle(msg.sender, address(0), to, id, amount);\n\n239: emit TransferSingle(msg.sender, from, address(0), id, amount);\n```","loc":["[80](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L80)","[108](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L108)","[161](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L161)","[220](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L220)","[239](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L239)"]}]},{"severity":"NonCritical","title":"Custom errors has no error details","description":"Consider adding parameters to the error to indicate which user or values caused the failure.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n11: error CastingError();\n\n14: error InvalidTick();\n\n17: error InvalidUniswapCallback();\n\n24: error LeftRightInputError();\n\n27: error NoLegsExercisable();\n\n30: error PositionTooLarge();\n\n33: error NotEnoughLiquidity();\n\n36: error OptionsBalanceZero();\n\n39: error PriceBoundFail();\n\n42: error ReentrantCall();\n\n45: error TransferFailed();\n\n49: error TicksNotInitializable();\n\n52: error UnderOverFlow();\n\n55: error UniswapPoolNotInitialized();\n```","loc":["[11](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L11)","[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L14)","[17](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L17)","[24](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L24)","[27](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L27)","[30](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L30)","[33](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L33)","[36](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L36)","[39](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L39)","[42](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L42)","[45](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L45)","[49](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L49)","[52](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L52)","[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L55)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n51: error NotAuthorized();\n\n54: error UnsafeRecipient();\n```","loc":["[51](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L51)","[54](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L54)"]}]},{"severity":"NonCritical","title":"Solidity version is different in some files","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n2: pragma solidity =0.8.18;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L2)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L2)"]}]},{"severity":"NonCritical","title":"Polymorphic functions make security audits more time-consuming and error-prone","description":"The instances below point to one of two functions with the same name. Consider naming each function differently, in order to make code navigation and analysis easier.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit also found on line 564\n545: address from,\n```","loc":["[545](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L545)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit also found on line 265\n252: function afterTokenTransfer(\n```","loc":["[252](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L252)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n/// @audit also found on line 32\n25: function rightSlot(uint256 self) internal pure returns (uint128) {\n\n/// @audit also found on line 54\n44: function toRightSlot(uint256 self, uint128 right) internal pure returns (uint256) {\n\n/// @audit also found on line 96\n89: function leftSlot(uint256 self) internal pure returns (uint128) {\n\n/// @audit also found on line 118\n108: function toLeftSlot(uint256 self, uint128 left) internal pure returns (uint256) {\n\n/// @audit also found on line 159\n142: function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n```","loc":["[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L25)","[44](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L44)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L89)","[108](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L108)","[142](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L142)"]}]},{"severity":"NonCritical","title":"Duplicated `require()`/`revert()` checks should be refactored","description":"Refactoring duplicate `require()`/`revert()` checks into a modifier or function can make the code more concise, readable and maintainable, and less likely to make errors or omissions when modifying the `require()` or `revert()`.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit duplicated on line 168\n115: revert UnsafeRecipient();\n```","loc":["[115](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L115)"]}]},{"severity":"NonCritical","title":"`else` block not required","description":"One level of nesting can be removed by not having an `else` block when the `if`-block always jumps at the end. For example:\n```solidity\nif (condition) {\n\tbody1...\n\treturn x;\n} else {\n\tbody2...\n}\n```\ncan be changed to:\n```solidity\nif (condition) {\n\tbody1...\n\treturn x;\n}\nbody2...\n```","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n149: if (sqrtPriceX96 < 340275971719517849884101479065584693834) {\n int256 absResult = Math\n .mulDiv192(Math.absUint(amount), uint256(sqrtPriceX96) ** 2)\n .toInt256();\n return amount < 0 ? -absResult : absResult;\n } else {\n\n172: if (sqrtPriceX96 < 340275971719517849884101479065584693834) {\n int256 absResult = Math\n .mulDiv(Math.absUint(amount), 2 ** 192, uint256(sqrtPriceX96) ** 2)\n .toInt256();\n return amount < 0 ? -absResult : absResult;\n } else {\n```","loc":["[149](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L149)","[172](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L172)"]}]},{"severity":"NonCritical","title":"Empty bytes check is missing","description":"Passing empty bytes to a function can cause unexpected behavior, such as certain operations failing, producing incorrect results, or wasting gas. It is recommended to check that all byte parameters are not empty.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit missing empty check for `data`\n408: uint256 amount0Owed,\n uint256 amount1Owed,\n bytes calldata data\n ) external {\n // Decode the mint callback data\n\n/// @audit missing empty check for `data`\n442: int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata data\n ) external {\n // Decode the swap callback data, checks that the UniswapV3Pool has the correct address.\n```","loc":["[408](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L408)","[442](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L442)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit missing empty check for `data`\n90: function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public {\n\n/// @audit missing empty check for `data`\n128: function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) public virtual {\n```","loc":["[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L90)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L128)"]}]},{"severity":"NonCritical","title":"Enable IR-based code generation","description":"The IR-based code generator was introduced with an aim to not only allow code generation to be more transparent and auditable but also to enable more powerful optimization passes that span across functions. You can enable it on the command line using `--via-ir` or with the option `{\"viaIR\": true}`. This will take longer to compile, but you can just simple test it before deploying and if you got a better benchmark then you can add --via-ir to your deploy command More on: https://docs.soliditylang.org/en/v0.8.17/ir-breaking-changes.html","gasSavings":null,"category":null,"instances":[{"content":"```solidity\n\nGlobal finding\n```","loc":["[1](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/)"]}]},{"severity":"NonCritical","title":"Events are emitted without the sender information","description":"When an action is triggered based on a user's action, not being able to filter based on who triggered the action makes event processing a lot more cumbersome. Including the `msg.sender` the events of these types of action will make events much more useful to end users, especially when `msg.sender` is not `tx.origin`.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n388: return;\n```","loc":["[388](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L388)"]}]},{"severity":"NonCritical","title":" Function ordering does not follow the Solidity Style Guide","description":"According to the [solidity style guide](https://docs.soliditylang.org/en/v0.8.17/style-guide.html#order-of-functions), functions should be laid out in the following order: `constructor()`, `receive()`, `fallback()`, `external`, `public`, `internal`, `private`, but the cases below do not follow this pattern","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit a function was seen before constructor\n/// @audit a function was seen before constructor\n342: constructor(IUniswapV3Factory _factory) {\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n351: function initializeAMMPool(address token0, address token1, uint24 fee) external {\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n408: uint256 amount0Owed,\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n442: int256 amount0Delta,\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n477: uint256 tokenId,\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n511: uint256 tokenId,\n\n/// @audit private function `_updateStoredPremia` came earlier from this internal function\n/// @audit private function `_getFeesBase` came earlier from this internal function\n1130: uint256 liquidityChunk,\n\n/// @audit private function `_updateStoredPremia` came earlier from this internal function\n/// @audit private function `_getFeesBase` came earlier from this internal function\n1170: uint256 liquidityChunk,\n\n/// @audit private function `_updateStoredPremia` came earlier from this internal function\n/// @audit private function `_getFeesBase` came earlier from this internal function\n1201: uint256 liquidityChunk,\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `registerTokenTransfer` came earlier from this external function\n/// @audit internal function `_validateAndForwardToAMM` came earlier from this external function\n/// @audit internal function `swapInAMM` came earlier from this external function\n/// @audit internal function `_createPositionInAMM` came earlier from this external function\n/// @audit internal function `_createLegInAMM` came earlier from this external function\n/// @audit private function `_updateStoredPremia` came earlier from this external function\n/// @audit private function `_getFeesBase` came earlier from this external function\n/// @audit internal function `_mintLiquidity` came earlier from this external function\n/// @audit internal function `_burnLiquidity` came earlier from this external function\n/// @audit internal function `_collectAndWritePositionData` came earlier from this external function\n/// @audit private function `_getPremiaDeltas` came earlier from this external function\n1344: address univ3pool,\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `registerTokenTransfer` came earlier from this external function\n/// @audit internal function `_validateAndForwardToAMM` came earlier from this external function\n/// @audit internal function `swapInAMM` came earlier from this external function\n/// @audit internal function `_createPositionInAMM` came earlier from this external function\n/// @audit internal function `_createLegInAMM` came earlier from this external function\n/// @audit private function `_updateStoredPremia` came earlier from this external function\n/// @audit private function `_getFeesBase` came earlier from this external function\n/// @audit internal function `_mintLiquidity` came earlier from this external function\n/// @audit internal function `_burnLiquidity` came earlier from this external function\n/// @audit internal function `_collectAndWritePositionData` came earlier from this external function\n/// @audit private function `_getPremiaDeltas` came earlier from this external function\n1372: address univ3pool,\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `registerTokenTransfer` came earlier from this external function\n/// @audit internal function `_validateAndForwardToAMM` came earlier from this external function\n/// @audit internal function `swapInAMM` came earlier from this external function\n/// @audit internal function `_createPositionInAMM` came earlier from this external function\n/// @audit internal function `_createLegInAMM` came earlier from this external function\n/// @audit private function `_updateStoredPremia` came earlier from this external function\n/// @audit private function `_getFeesBase` came earlier from this external function\n/// @audit internal function `_mintLiquidity` came earlier from this external function\n/// @audit internal function `_burnLiquidity` came earlier from this external function\n/// @audit internal function `_collectAndWritePositionData` came earlier from this external function\n/// @audit private function `_getPremiaDeltas` came earlier from this external function\n1438: address univ3pool,\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `registerTokenTransfer` came earlier from this external function\n/// @audit internal function `_validateAndForwardToAMM` came earlier from this external function\n/// @audit internal function `swapInAMM` came earlier from this external function\n/// @audit internal function `_createPositionInAMM` came earlier from this external function\n/// @audit internal function `_createLegInAMM` came earlier from this external function\n/// @audit private function `_updateStoredPremia` came earlier from this external function\n/// @audit private function `_getFeesBase` came earlier from this external function\n/// @audit internal function `_mintLiquidity` came earlier from this external function\n/// @audit internal function `_burnLiquidity` came earlier from this external function\n/// @audit internal function `_collectAndWritePositionData` came earlier from this external function\n/// @audit private function `_getPremiaDeltas` came earlier from this external function\n1458: uint64 poolId\n\n/// @audit internal function `beginReentrancyLock` came earlier from this external function\n/// @audit internal function `endReentrancyLock` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `afterTokenTransfer` came earlier from this external function\n/// @audit internal function `registerTokenTransfer` came earlier from this external function\n/// @audit internal function `_validateAndForwardToAMM` came earlier from this external function\n/// @audit internal function `swapInAMM` came earlier from this external function\n/// @audit internal function `_createPositionInAMM` came earlier from this external function\n/// @audit internal function `_createLegInAMM` came earlier from this external function\n/// @audit private function `_updateStoredPremia` came earlier from this external function\n/// @audit private function `_getFeesBase` came earlier from this external function\n/// @audit internal function `_mintLiquidity` came earlier from this external function\n/// @audit internal function `_burnLiquidity` came earlier from this external function\n/// @audit internal function `_collectAndWritePositionData` came earlier from this external function\n/// @audit private function `_getPremiaDeltas` came earlier from this external function\n1468: function getPoolId(address univ3pool) external view returns (uint64 poolId) {\n```","loc":["[342](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L342)","[351](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L351)","[408](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L408)","[442](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L442)","[477](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L477)","[511](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L511)","[1130](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1130)","[1170](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1170)","[1201](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1201)","[1344](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1344)","[1372](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1372)","[1438](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1438)","[1458](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1458)","[1468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1468)"]}]},{"severity":"NonCritical","title":"Functions and modifiers should be named in mixedCase style","description":"As the [Solidity Style Guide](https://docs.soliditylang.org/en/v0.8.21/style-guide.html#function-names) suggests: functions and modifiers should be named in mixedCase style.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n306: modifier ReentrancyLock(uint64 poolId) {\n```","loc":["[306](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L306)"]}]},{"severity":"NonCritical","title":"Functions with array parameters should have length checks in place","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `ids`\n/// @audit `amounts`\n545: address from,\n```","loc":["[545](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L545)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit `ids`\n/// @audit `amounts`\n128: function safeBatchTransferFrom(\n\n/// @audit `ids`\n178: function balanceOfBatch(\n\n/// @audit `ids`\n/// @audit `amounts`\n252: function afterTokenTransfer(\n```","loc":["[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L128)","[178](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L178)","[252](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L252)"]}]},{"severity":"NonCritical","title":"High cyclomatic complexity","description":"Consider breaking down these blocks into more manageable units, by splitting things into utility functions, by reducing nesting, and by using early returns","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit Number of blocks: 12\n937: IUniswapV3Pool _univ3pool,\n```","loc":["[937](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L937)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n/// @audit Number of blocks: 10\n186: function mulDiv(\n```","loc":["[186](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L186)"]}]},{"severity":"NonCritical","title":"Inconsistent spacing in comments","description":"Some lines use `// x` and some use `//x`. The instances below point out the usages that don't follow the majority, within each file","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n75: //////////////////////////////////////////////////////////////*/\n\n105: //////////////////////////////////////////////////////////////*/\n\n124: //////////////////////////////////////////////////////////////*/\n\n143: //////////////////////////////////////////////////////////////*/\n\n300: //////////////////////////////////////////////////////////////*/\n\n338: //////////////////////////////////////////////////////////////*/\n\n400: //////////////////////////////////////////////////////////////*/\n\n465: //////////////////////////////////////////////////////////////*/\n\n537: //////////////////////////////////////////////////////////////*/\n\n593: //construct the positionKey for the from and to addresses\n\n625: //update+store liquidity and fee values between accounts\n\n639: //////////////////////////////////////////////////////////////*/\n\n808: //compute the swap amount, set as positive (exact input)\n\n1333: ///////////////////////////////////////////////////////////////////////////*/\n```","loc":["[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L75)","[105](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L105)","[124](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L124)","[143](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L143)","[300](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L300)","[338](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L338)","[400](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L400)","[465](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L465)","[537](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L537)","[593](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L593)","[625](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L625)","[639](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L639)","[808](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L808)","[1333](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1333)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n17: //////////////////////////////////////////////////////////////*/\n\n31: //////////////////////////////////////////////////////////////*/\n\n95: //////////////////////////////////////////////////////////////*/\n\n167: //////////////////////////////////////////////////////////////*/\n\n178: //////////////////////////////////////////////////////////////*/\n\n218: ///////////////////////////////////////////////\n\n220: ///////////////////////////////////////////////\n\n313: ///////////////////////////////////////////////\n\n315: ///////////////////////////////////////////////\n\n375: ///////////////////////////////////////////////\n\n377: ///////////////////////////////////////////////\n\n437: ///////////////////////////////////////////////\n\n439: ///////////////////////////////////////////////\n\n499: ///////////////////////////////////////////////\n\n501: ///////////////////////////////////////////////\n```","loc":["[17](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L17)","[31](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L31)","[95](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L95)","[167](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L167)","[178](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L178)","[218](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L218)","[220](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L220)","[313](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L313)","[315](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L315)","[375](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L375)","[377](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L377)","[437](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L437)","[439](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L439)","[499](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L499)","[501](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L501)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n24: //////////////////////////////////////////////////////////////*/\n\n63: //////////////////////////////////////////////////////////////*/\n\n138: //////////////////////////////////////////////////////////////*/\n```","loc":["[24](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L24)","[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L63)","[138](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L138)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n14: //////////////////////////////////////////////////////////////*/\n```","loc":["[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L14)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n13: //////////////////////////////////////////////////////////////*/\n\n48: //////////////////////////////////////////////////////////////*/\n\n58: //////////////////////////////////////////////////////////////*/\n\n72: //////////////////////////////////////////////////////////////*/\n\n195: //////////////////////////////////////////////////////////////*/\n\n208: //////////////////////////////////////////////////////////////*/\n\n244: //////////////////////////////////////////////////////////////*/\n```","loc":["[13](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L13)","[48](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L48)","[58](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L58)","[72](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L72)","[195](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L195)","[208](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L208)","[244](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L244)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n20: //////////////////////////////////////////////////////////////*/\n\n84: //////////////////////////////////////////////////////////////*/\n\n136: //////////////////////////////////////////////////////////////*/\n\n193: //////////////////////////////////////////////////////////////*/\n```","loc":["[20](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L20)","[84](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L84)","[136](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L136)","[193](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L193)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n55: //////////////////////////////////////////////////////////////*/\n\n107: //////////////////////////////////////////////////////////////*/\n```","loc":["[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L55)","[107](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L107)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n75: //////////////////////////////////////////////////////////////*/\n\n168: //////////////////////////////////////////////////////////////*/\n\n181: //////////////////////////////////////////////////////////////*/\n\n320: //////////////////////////////////////////////////////////////*/\n\n457: //////////////////////////////////////////////////////////////*/\n```","loc":["[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L75)","[168](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L168)","[181](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L181)","[320](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L320)","[457](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L457)"]}]},{"severity":"NonCritical","title":"Invalid NatSpec comment style","description":"NatSpec must begin with `///` or use `/* ... */` syntax","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n359: // @dev pools can be initialized from a Panoptic pool or by calling initializeAMMPool directly, reverting\n\n361: // @dev some pools may not be deployable if the poolId has a collision (since we take only 8 bytes)\n\n366: // @dev in the unlikely case that there is a collision between the first 8 bytes of two different Uni v3 pools\n\n367: // @dev increase the poolId by a pseudo-random number\n\n585: // @dev see `contracts/types/LiquidityChunk.sol`\n\n777: // implement a single \"netting\" swap. Thank you @danrobinson for this puzzle/idea\n\n823: // @dev note this triggers our swap callback function\n\n881: // @dev see `contracts/types/LiquidityChunk.sol`\n```","loc":["[359](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L359)","[361](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L361)","[366](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L366)","[367](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L367)","[585](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L585)","[777](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L777)","[823](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L823)","[881](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L881)"]}]},{"severity":"NonCritical","title":"Large or complicated code bases should implement invariant tests","description":"This includes: large code bases, or code with lots of inline-assembly, complicated math, or complicated interactions between multiple contracts. Invariant fuzzers such as Echidna require the test writer to come up with invariants which should not be violated under any circumstances, and the fuzzer tests various inputs and function calls to ensure that the invariants always hold. Even code with 100% code coverage can still have bugs due to the order of the operations a user performs, and invariant fuzzers may help significantly.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\n\nGlobal finding\n```","loc":["[1](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/)"]}]},{"severity":"NonCritical","title":"Large multiples of ten should use scientific notation","description":"Use a scientific notation rather than decimal literals (e.g. `1e6` instead of `1000000`), for better code readability.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n61: 0x100_000000000100_000000000100_000000000100_0000000000000000;\n\n61: 0x100_000000000100_000000000100_000000000100_0000000000000000;\n\n61: 0x100_000000000100_000000000100_000000000100_0000000000000000;\n\n61: 0x100_000000000100_000000000100_000000000100_0000000000000000;\n```","loc":["[61](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L61)","[61](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L61)","[61](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L61)","[61](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L61)"]}]},{"severity":"NonCritical","title":"Large numeric literals should use underscores for readability","description":"Large hardcoded numbers in code can be difficult to read. Consider using underscores for number literals to improve readability (e.g `1234567` -> `1_234_567`). Consider using an underscore for every third digit from the right.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n11: int24 internal constant MIN_V3POOL_TICK = -887272;\n\n14: int24 internal constant MAX_V3POOL_TICK = 887272;\n\n17: uint160 internal constant MIN_V3POOL_SQRT_RATIO = 4295128739;\n\n21: 1461446703485210103287273052203988822378723970342;\n```","loc":["[11](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L11)","[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L14)","[17](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L17)","[21](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L21)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n149: if (sqrtPriceX96 < 340275971719517849884101479065584693834) {\n\n172: if (sqrtPriceX96 < 340275971719517849884101479065584693834) {\n```","loc":["[149](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L149)","[172](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L172)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n162: return int24(int256((self >> (64 + legIndex * 48 + 36)) % 4096));\n\n283: return self + (uint256(uint24(_width) % 4096) << (64 + legIndex * 48 + 36));\n```","loc":["[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L162)","[283](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L283)"]}]},{"severity":"NonCritical","title":"Long functions should be refactored into multiple, smaller, functions","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit 57 lines\n578: function registerTokenTransfer(address from, address to, uint256 id, uint256 amount) internal {\n // Extract univ3pool from the poolId map to Uniswap Pool\n\n/// @audit 53 lines\n664: uint256 tokenId,\n uint128 positionSize,\n int24 tickLimitLow,\n int24 tickLimitHigh,\n bool isBurn\n ) internal returns (int256 totalCollectedFromAMM, int256 totalMoved, int24 newTick) {\n // Reverts if positionSize is 0 and user did not own the position before minting/burning\n\n/// @audit 94 lines\n744: IUniswapV3Pool univ3pool,\n int256 itmAmounts\n ) internal returns (int256 totalSwapped) {\n // Initialize variables\n bool zeroForOne; // The direction of the swap, true for token0 to token1, false for token1 to token0\n\n/// @audit 71 lines\n849: IUniswapV3Pool univ3pool,\n uint256 tokenId,\n uint128 positionSize,\n bool isBurn\n ) internal returns (int256 totalMoved, int256 totalCollected, int256 itmAmounts) {\n // upper bound on amount of tokens contained across all legs of the position at any given tick\n\n/// @audit 131 lines\n937: IUniswapV3Pool _univ3pool,\n uint256 _tokenId,\n uint256 _leg,\n uint256 _liquidityChunk,\n bool _isBurn\n ) internal returns (int256 _moved, int256 _itmAmounts, int256 _totalCollected) {\n uint256 _tokenType = TokenId.tokenType(_tokenId, _leg);\n\n/// @audit 74 lines\n1256: uint256 currentLiquidity,\n int256 collectedAmounts\n ) private pure returns (uint256 deltaPremiumOwed, uint256 deltaPremiumGross) {\n // extract liquidity values\n uint256 removedLiquidity = currentLiquidity.leftSlot();\n\n/// @audit 54 lines\n1372: address univ3pool,\n address owner,\n uint256 tokenType,\n int24 tickLower,\n int24 tickUpper,\n int24 atTick,\n uint256 isLong\n ) external view returns (uint128 premiumToken0, uint128 premiumToken1) {\n bytes32 positionKey = keccak256(\n```","loc":["[578](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L578)","[664](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L664)","[744](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L744)","[849](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L849)","[937](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L937)","[1256](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1256)","[1372](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1372)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n/// @audit 78 lines\n89: function _getAMMSwapFeesPerLiquidityCollected(\n IUniswapV3Pool univ3pool,\n int24 currentTick,\n int24 tickLower,\n int24 tickUpper\n ) internal view returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) {\n```","loc":["[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L89)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n/// @audit 53 lines\n38: function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n\n/// @audit 94 lines\n186: function mulDiv(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n\n/// @audit 56 lines\n286: function mulDiv64(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n\n/// @audit 56 lines\n348: function mulDiv96(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n\n/// @audit 56 lines\n410: function mulDiv128(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n\n/// @audit 56 lines\n472: function mulDiv192(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n```","loc":["[38](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L38)","[186](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L186)","[286](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L286)","[348](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L348)","[410](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L410)","[472](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L472)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n/// @audit 52 lines\n82: function getLiquidityChunk(\n uint256 tokenId,\n uint256 legIndex,\n uint128 positionSize,\n int24 tickSpacing\n ) internal pure returns (uint256 liquidityChunk) {\n```","loc":["[82](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L82)"]}]},{"severity":"NonCritical","title":"Magic numbers should be replaced with constants","description":"Magic numbers are hard-coded values in code that can make it difficult for developers and maintainers to understand the code, and can also cause confusion or errors. To improve the readability and maintainability of code, it is recommended to replace magic numbers with constants that have good readability.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n// @audit `2`\n386: emit PoolInitialized(univ3pool);\n\n// @audit `255`\n386: emit PoolInitialized(univ3pool);\n\n// @audit `2`\n1282: .toUint128();\n\n// @audit `64`\n1282: .toUint128();\n\n// @audit `2`\n1283: premium1X64_base = Math\n\n// @audit `2`\n1285: .toUint128();\n\n// @audit `64`\n1285: .toUint128();\n\n// @audit `2`\n1286: }\n\n// @audit `2`\n1295: premium0X64_owed = Math\n\n// @audit `2`\n1314: totalLiquidity *\n\n// @audit `2`\n1317: premium0X64_gross = Math\n\n// @audit `2`\n1317: premium0X64_gross = Math\n\n// @audit `2`\n1319: .toUint128();\n\n// @audit `2`\n1322: .toUint128();\n```","loc":["[386](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L386)","[386](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L386)","[1282](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1282)","[1282](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1282)","[1283](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1283)","[1285](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1285)","[1285](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1285)","[1286](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1286)","[1295](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1295)","[1314](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1314)","[1317](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1317)","[1317](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1317)","[1319](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1319)","[1322](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1322)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n// @audit `0xff`\n41: bytes1(0xff),\n```","loc":["[41](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L41)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n// @audit `0x1`\n43: uint256 sqrtR = absTick & 0x1 != 0\n\n// @audit `0xfffcb933bd6fad37aa2d162d1a594001`\n44: ? 0xfffcb933bd6fad37aa2d162d1a594001\n\n// @audit `0x100000000000000000000000000000000`\n45: : 0x100000000000000000000000000000000;\n\n// @audit `0x2`\n47: if (absTick & 0x2 != 0) sqrtR = (sqrtR * 0xfff97272373d413259a46990580e213a) >> 128;\n\n// @audit `0xfff97272373d413259a46990580e213a`\n47: if (absTick & 0x2 != 0) sqrtR = (sqrtR * 0xfff97272373d413259a46990580e213a) >> 128;\n\n// @audit `128`\n47: if (absTick & 0x2 != 0) sqrtR = (sqrtR * 0xfff97272373d413259a46990580e213a) >> 128;\n\n// @audit `0x4`\n49: if (absTick & 0x4 != 0) sqrtR = (sqrtR * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n\n// @audit `0xfff2e50f5f656932ef12357cf3c7fdcc`\n49: if (absTick & 0x4 != 0) sqrtR = (sqrtR * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n\n// @audit `128`\n49: if (absTick & 0x4 != 0) sqrtR = (sqrtR * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n\n// @audit `0x8`\n51: if (absTick & 0x8 != 0) sqrtR = (sqrtR * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n\n// @audit `0xffe5caca7e10e4e61c3624eaa0941cd0`\n51: if (absTick & 0x8 != 0) sqrtR = (sqrtR * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n\n// @audit `128`\n51: if (absTick & 0x8 != 0) sqrtR = (sqrtR * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n\n// @audit `0x10`\n53: if (absTick & 0x10 != 0) sqrtR = (sqrtR * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n\n// @audit `0xffcb9843d60f6159c9db58835c926644`\n53: if (absTick & 0x10 != 0) sqrtR = (sqrtR * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n\n// @audit `128`\n53: if (absTick & 0x10 != 0) sqrtR = (sqrtR * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n\n// @audit `0x20`\n55: if (absTick & 0x20 != 0) sqrtR = (sqrtR * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n\n// @audit `0xff973b41fa98c081472e6896dfb254c0`\n55: if (absTick & 0x20 != 0) sqrtR = (sqrtR * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n\n// @audit `128`\n55: if (absTick & 0x20 != 0) sqrtR = (sqrtR * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n\n// @audit `0x40`\n57: if (absTick & 0x40 != 0) sqrtR = (sqrtR * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n\n// @audit `0xff2ea16466c96a3843ec78b326b52861`\n57: if (absTick & 0x40 != 0) sqrtR = (sqrtR * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n\n// @audit `128`\n57: if (absTick & 0x40 != 0) sqrtR = (sqrtR * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n\n// @audit `0x80`\n59: if (absTick & 0x80 != 0) sqrtR = (sqrtR * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n\n// @audit `0xfe5dee046a99a2a811c461f1969c3053`\n59: if (absTick & 0x80 != 0) sqrtR = (sqrtR * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n\n// @audit `128`\n59: if (absTick & 0x80 != 0) sqrtR = (sqrtR * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n\n// @audit `0x100`\n61: if (absTick & 0x100 != 0) sqrtR = (sqrtR * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n\n// @audit `0xfcbe86c7900a88aedcffc83b479aa3a4`\n61: if (absTick & 0x100 != 0) sqrtR = (sqrtR * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n\n// @audit `128`\n61: if (absTick & 0x100 != 0) sqrtR = (sqrtR * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n\n// @audit `0x200`\n63: if (absTick & 0x200 != 0) sqrtR = (sqrtR * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n\n// @audit `0xf987a7253ac413176f2b074cf7815e54`\n63: if (absTick & 0x200 != 0) sqrtR = (sqrtR * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n\n// @audit `128`\n63: if (absTick & 0x200 != 0) sqrtR = (sqrtR * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n\n// @audit `0x400`\n65: if (absTick & 0x400 != 0) sqrtR = (sqrtR * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n\n// @audit `0xf3392b0822b70005940c7a398e4b70f3`\n65: if (absTick & 0x400 != 0) sqrtR = (sqrtR * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n\n// @audit `128`\n65: if (absTick & 0x400 != 0) sqrtR = (sqrtR * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n\n// @audit `0x800`\n67: if (absTick & 0x800 != 0) sqrtR = (sqrtR * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n\n// @audit `0xe7159475a2c29b7443b29c7fa6e889d9`\n67: if (absTick & 0x800 != 0) sqrtR = (sqrtR * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n\n// @audit `128`\n67: if (absTick & 0x800 != 0) sqrtR = (sqrtR * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n\n// @audit `0x1000`\n69: if (absTick & 0x1000 != 0) sqrtR = (sqrtR * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n\n// @audit `0xd097f3bdfd2022b8845ad8f792aa5825`\n69: if (absTick & 0x1000 != 0) sqrtR = (sqrtR * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n\n// @audit `128`\n69: if (absTick & 0x1000 != 0) sqrtR = (sqrtR * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n\n// @audit `0x2000`\n71: if (absTick & 0x2000 != 0) sqrtR = (sqrtR * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n\n// @audit `0xa9f746462d870fdf8a65dc1f90e061e5`\n71: if (absTick & 0x2000 != 0) sqrtR = (sqrtR * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n\n// @audit `128`\n71: if (absTick & 0x2000 != 0) sqrtR = (sqrtR * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n\n// @audit `0x4000`\n73: if (absTick & 0x4000 != 0) sqrtR = (sqrtR * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n\n// @audit `0x70d869a156d2a1b890bb3df62baf32f7`\n73: if (absTick & 0x4000 != 0) sqrtR = (sqrtR * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n\n// @audit `128`\n73: if (absTick & 0x4000 != 0) sqrtR = (sqrtR * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n\n// @audit `0x8000`\n75: if (absTick & 0x8000 != 0) sqrtR = (sqrtR * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n\n// @audit `0x31be135f97d08fd981231505542fcfa6`\n75: if (absTick & 0x8000 != 0) sqrtR = (sqrtR * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n\n// @audit `128`\n75: if (absTick & 0x8000 != 0) sqrtR = (sqrtR * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n\n// @audit `0x10000`\n77: if (absTick & 0x10000 != 0) sqrtR = (sqrtR * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n\n// @audit `0x9aa508b5b7a84e1c677de54f3e99bc9`\n77: if (absTick & 0x10000 != 0) sqrtR = (sqrtR * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n\n// @audit `128`\n77: if (absTick & 0x10000 != 0) sqrtR = (sqrtR * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n\n// @audit `0x20000`\n79: if (absTick & 0x20000 != 0) sqrtR = (sqrtR * 0x5d6af8dedb81196699c329225ee604) >> 128;\n\n// @audit `0x5d6af8dedb81196699c329225ee604`\n79: if (absTick & 0x20000 != 0) sqrtR = (sqrtR * 0x5d6af8dedb81196699c329225ee604) >> 128;\n\n// @audit `128`\n79: if (absTick & 0x20000 != 0) sqrtR = (sqrtR * 0x5d6af8dedb81196699c329225ee604) >> 128;\n\n// @audit `0x40000`\n81: if (absTick & 0x40000 != 0) sqrtR = (sqrtR * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n\n// @audit `0x2216e584f5fa1ea926041bedfe98`\n81: if (absTick & 0x40000 != 0) sqrtR = (sqrtR * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n\n// @audit `128`\n81: if (absTick & 0x40000 != 0) sqrtR = (sqrtR * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n\n// @audit `0x80000`\n83: if (absTick & 0x80000 != 0) sqrtR = (sqrtR * 0x48a170391f7dc42444e8fa2) >> 128;\n\n// @audit `0x48a170391f7dc42444e8fa2`\n83: if (absTick & 0x80000 != 0) sqrtR = (sqrtR * 0x48a170391f7dc42444e8fa2) >> 128;\n\n// @audit `128`\n83: if (absTick & 0x80000 != 0) sqrtR = (sqrtR * 0x48a170391f7dc42444e8fa2) >> 128;\n\n// @audit `32`\n89: sqrtPriceX96 = uint160((sqrtR >> 32) + (sqrtR % (1 << 32) == 0 ? 0 : 1));\n\n// @audit `32`\n89: sqrtPriceX96 = uint160((sqrtR >> 32) + (sqrtR % (1 << 32) == 0 ? 0 : 1));\n\n// @audit `96`\n109: uint256(liquidityChunk.liquidity()) << 96,\n\n// @audit `3`\n260: uint256 inv = (3 * denominator) ^ 2;\n\n// @audit `2`\n260: uint256 inv = (3 * denominator) ^ 2;\n\n// @audit `2`\n264: inv *= 2 - denominator * inv; // inverse mod 2**8\n\n// @audit `2`\n265: inv *= 2 - denominator * inv; // inverse mod 2**16\n\n// @audit `2`\n266: inv *= 2 - denominator * inv; // inverse mod 2**32\n\n// @audit `2`\n267: inv *= 2 - denominator * inv; // inverse mod 2**64\n\n// @audit `2`\n268: inv *= 2 - denominator * inv; // inverse mod 2**128\n\n// @audit `2`\n269: inv *= 2 - denominator * inv; // inverse mod 2**256\n\n// @audit `2`\n311: require(2 ** 64 > prod1);\n\n// @audit `64`\n311: require(2 ** 64 > prod1);\n\n// @audit `2`\n338: prod0 |= prod1 * 2 ** 192;\n\n// @audit `192`\n338: prod0 |= prod1 * 2 ** 192;\n\n// @audit `2`\n373: require(2 ** 96 > prod1);\n\n// @audit `96`\n373: require(2 ** 96 > prod1);\n\n// @audit `2`\n400: prod0 |= prod1 * 2 ** 160;\n\n// @audit `160`\n402: return prod0;\n\n// @audit `2`\n435: require(2 ** 128 > prod1);\n\n// @audit `128`\n435: require(2 ** 128 > prod1);\n\n// @audit `2`\n462: prod0 |= prod1 * 2 ** 128;\n\n// @audit `128`\n464: return prod0;\n\n// @audit `2`\n497: require(2 ** 192 > prod1);\n\n// @audit `192`\n497: require(2 ** 192 > prod1);\n\n// @audit `2`\n526: return prod0;\n\n// @audit `64`\n526: return prod0;\n```","loc":["[43](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L43)","[44](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L44)","[45](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L45)","[47](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L47)","[47](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L47)","[47](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L47)","[49](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L49)","[49](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L49)","[49](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L49)","[51](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L51)","[51](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L51)","[51](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L51)","[53](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L53)","[53](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L53)","[53](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L53)","[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L55)","[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L55)","[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L55)","[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L57)","[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L57)","[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L57)","[59](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L59)","[59](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L59)","[59](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L59)","[61](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L61)","[61](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L61)","[61](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L61)","[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L63)","[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L63)","[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L63)","[65](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L65)","[65](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L65)","[65](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L65)","[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L67)","[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L67)","[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L67)","[69](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L69)","[69](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L69)","[69](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L69)","[71](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L71)","[71](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L71)","[71](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L71)","[73](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L73)","[73](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L73)","[73](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L73)","[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L75)","[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L75)","[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L75)","[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L77)","[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L77)","[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L77)","[79](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L79)","[79](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L79)","[79](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L79)","[81](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L81)","[81](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L81)","[81](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L81)","[83](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L83)","[83](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L83)","[83](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L83)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L89)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L89)","[109](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L109)","[260](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L260)","[260](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L260)","[264](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L264)","[265](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L265)","[266](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L266)","[267](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L267)","[268](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L268)","[269](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L269)","[311](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L311)","[311](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L311)","[338](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L338)","[338](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L338)","[373](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L373)","[373](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L373)","[400](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L400)","[402](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L402)","[435](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L435)","[435](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L435)","[462](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L462)","[464](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L464)","[497](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L497)","[497](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L497)","[526](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L526)","[526](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L526)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n// @audit `96`\n39: return uint64(uint160(univ3pool) >> 96);\n\n// @audit `32`\n57: (uint64(uint256(keccak256(abi.encodePacked(token0, token1, fee)))) >> 32);\n\n// @audit `340275971719517849884101479065584693834`\n149: if (sqrtPriceX96 < 340275971719517849884101479065584693834) {\n\n// @audit `2`\n151: .mulDiv192(Math.absUint(amount), uint256(sqrtPriceX96) ** 2)\n\n// @audit `340275971719517849884101479065584693834`\n172: if (sqrtPriceX96 < 340275971719517849884101479065584693834) {\n\n// @audit `2`\n174: .mulDiv(Math.absUint(amount), 2 ** 192, uint256(sqrtPriceX96) ** 2)\n\n// @audit `192`\n174: .mulDiv(Math.absUint(amount), 2 ** 192, uint256(sqrtPriceX96) ** 2)\n\n// @audit `2`\n174: .mulDiv(Math.absUint(amount), 2 ** 192, uint256(sqrtPriceX96) ** 2)\n\n// @audit `2`\n181: 2 ** 128,\n\n// @audit `128`\n181: 2 ** 128,\n```","loc":["[39](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L39)","[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L57)","[149](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L149)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L151)","[172](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L172)","[174](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L174)","[174](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L174)","[174](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L174)","[181](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L181)","[181](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L181)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n// @audit `0x01ffc9a7`\n202: interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165\n\n// @audit `0xd9b67a26`\n203: interfaceId == 0xd9b67a26; // ERC165 Interface ID for ERC1155\n```","loc":["[202](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L202)","[203](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L203)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n// @audit `128`\n90: return uint128(self >> 128);\n\n// @audit `128`\n97: return int128(self >> 128);\n\n// @audit `128`\n110: return self + (uint256(left) << 128);\n\n// @audit `128`\n120: return self + (int256(int128(left)) << 128);\n\n// @audit `128`\n130: return self + (int256(left) << 128);\n```","loc":["[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L90)","[97](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L97)","[110](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L110)","[120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L120)","[130](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L130)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n// @audit `232`\n90: return self + (uint256(uint24(_tickLower)) << 232);\n\n// @audit `208`\n101: return self + ((uint256(uint24(_tickUpper))) << 208);\n\n// @audit `232`\n114: return int24(int256(self >> 232));\n\n// @audit `208`\n123: return int24(int256(self >> 208));\n```","loc":["[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L90)","[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L101)","[114](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L114)","[123](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L123)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n// @audit `64`\n95: return uint256((self >> (64 + legIndex * 48)) % 2);\n\n// @audit `48`\n95: return uint256((self >> (64 + legIndex * 48)) % 2);\n\n// @audit `2`\n95: return uint256((self >> (64 + legIndex * 48)) % 2);\n\n// @audit `64`\n105: return uint256((self >> (64 + legIndex * 48 + 1)) % 128);\n\n// @audit `48`\n105: return uint256((self >> (64 + legIndex * 48 + 1)) % 128);\n\n// @audit `128`\n105: return uint256((self >> (64 + legIndex * 48 + 1)) % 128);\n\n// @audit `64`\n115: return uint256((self >> (64 + legIndex * 48 + 8)) % 2);\n\n// @audit `48`\n115: return uint256((self >> (64 + legIndex * 48 + 8)) % 2);\n\n// @audit `8`\n115: return uint256((self >> (64 + legIndex * 48 + 8)) % 2);\n\n// @audit `2`\n115: return uint256((self >> (64 + legIndex * 48 + 8)) % 2);\n\n// @audit `64`\n125: return uint256((self >> (64 + legIndex * 48 + 9)) % 2);\n\n// @audit `48`\n125: return uint256((self >> (64 + legIndex * 48 + 9)) % 2);\n\n// @audit `9`\n125: return uint256((self >> (64 + legIndex * 48 + 9)) % 2);\n\n// @audit `2`\n125: return uint256((self >> (64 + legIndex * 48 + 9)) % 2);\n\n// @audit `64`\n141: return uint256((self >> (64 + legIndex * 48 + 10)) % 4);\n\n// @audit `48`\n141: return uint256((self >> (64 + legIndex * 48 + 10)) % 4);\n\n// @audit `10`\n141: return uint256((self >> (64 + legIndex * 48 + 10)) % 4);\n\n// @audit `4`\n141: return uint256((self >> (64 + legIndex * 48 + 10)) % 4);\n\n// @audit `64`\n151: return int24(int256(self >> (64 + legIndex * 48 + 12)));\n\n// @audit `48`\n151: return int24(int256(self >> (64 + legIndex * 48 + 12)));\n\n// @audit `12`\n151: return int24(int256(self >> (64 + legIndex * 48 + 12)));\n\n// @audit `64`\n162: return int24(int256((self >> (64 + legIndex * 48 + 36)) % 4096));\n\n// @audit `48`\n162: return int24(int256((self >> (64 + legIndex * 48 + 36)) % 4096));\n\n// @audit `36`\n162: return int24(int256((self >> (64 + legIndex * 48 + 36)) % 4096));\n\n// @audit `4096`\n162: return int24(int256((self >> (64 + legIndex * 48 + 36)) % 4096));\n\n// @audit `2`\n195: return self + (uint256(_asset % 2) << (64 + legIndex * 48));\n\n// @audit `64`\n195: return self + (uint256(_asset % 2) << (64 + legIndex * 48));\n\n// @audit `48`\n195: return self + (uint256(_asset % 2) << (64 + legIndex * 48));\n\n// @audit `128`\n210: return self + (uint256(_optionRatio % 128) << (64 + legIndex * 48 + 1));\n\n// @audit `64`\n210: return self + (uint256(_optionRatio % 128) << (64 + legIndex * 48 + 1));\n\n// @audit `48`\n210: return self + (uint256(_optionRatio % 128) << (64 + legIndex * 48 + 1));\n\n// @audit `2`\n226: return self + ((_isLong % 2) << (64 + legIndex * 48 + 8));\n\n// @audit `64`\n226: return self + ((_isLong % 2) << (64 + legIndex * 48 + 8));\n\n// @audit `48`\n226: return self + ((_isLong % 2) << (64 + legIndex * 48 + 8));\n\n// @audit `8`\n226: return self + ((_isLong % 2) << (64 + legIndex * 48 + 8));\n\n// @audit `2`\n240: return self + (uint256(_tokenType % 2) << (64 + legIndex * 48 + 9));\n\n// @audit `64`\n240: return self + (uint256(_tokenType % 2) << (64 + legIndex * 48 + 9));\n\n// @audit `48`\n240: return self + (uint256(_tokenType % 2) << (64 + legIndex * 48 + 9));\n\n// @audit `9`\n240: return self + (uint256(_tokenType % 2) << (64 + legIndex * 48 + 9));\n\n// @audit `4`\n254: return self + (uint256(_riskPartner % 4) << (64 + legIndex * 48 + 10));\n\n// @audit `64`\n254: return self + (uint256(_riskPartner % 4) << (64 + legIndex * 48 + 10));\n\n// @audit `48`\n254: return self + (uint256(_riskPartner % 4) << (64 + legIndex * 48 + 10));\n\n// @audit `10`\n254: return self + (uint256(_riskPartner % 4) << (64 + legIndex * 48 + 10));\n\n// @audit `64`\n268: return self + uint256((int256(_strike) & BITMASK_INT24) << (64 + legIndex * 48 + 12));\n\n// @audit `48`\n268: return self + uint256((int256(_strike) & BITMASK_INT24) << (64 + legIndex * 48 + 12));\n\n// @audit `12`\n268: return self + uint256((int256(_strike) & BITMASK_INT24) << (64 + legIndex * 48 + 12));\n\n// @audit `4096`\n283: return self + (uint256(uint24(_width) % 4096) << (64 + legIndex * 48 + 36));\n\n// @audit `64`\n283: return self + (uint256(uint24(_width) % 4096) << (64 + legIndex * 48 + 36));\n\n// @audit `48`\n283: return self + (uint256(uint24(_width) % 4096) << (64 + legIndex * 48 + 36));\n\n// @audit `36`\n283: return self + (uint256(uint24(_width) % 4096) << (64 + legIndex * 48 + 36));\n\n// @audit `2`\n337: if (optionRatios < 2 ** 64) {\n\n// @audit `64`\n337: if (optionRatios < 2 ** 64) {\n\n// @audit `2`\n339: } else if (optionRatios < 2 ** 112) {\n\n// @audit `112`\n339: } else if (optionRatios < 2 ** 112) {\n\n// @audit `2`\n341: } else if (optionRatios < 2 ** 160) {\n\n// @audit `160`\n341: } else if (optionRatios < 2 ** 160) {\n\n// @audit `2`\n342: optionRatios = 2;\n\n// @audit `2`\n343: } else if (optionRatios < 2 ** 208) {\n\n// @audit `208`\n343: } else if (optionRatios < 2 ** 208) {\n\n// @audit `3`\n344: optionRatios = 3;\n\n// @audit `4`\n346: optionRatios = 4;\n\n// @audit `48`\n353: return self ^ ((LONG_MASK >> (48 * (4 - optionRatios))) & CLEAR_POOLID_MASK);\n\n// @audit `4`\n353: return self ^ ((LONG_MASK >> (48 * (4 - optionRatios))) & CLEAR_POOLID_MASK);\n\n// @audit `2`\n363: return self.isLong(0) + self.isLong(1) + self.isLong(2) + self.isLong(3);\n\n// @audit `3`\n363: return self.isLong(0) + self.isLong(1) + self.isLong(2) + self.isLong(3);\n\n// @audit `2`\n389: int24 oneSidedRange = (selfWidth * tickSpacing) / 2;\n\n// @audit `2`\n417: if (optionRatios < 2 ** 64) {\n\n// @audit `64`\n417: if (optionRatios < 2 ** 64) {\n\n// @audit `2`\n419: } else if (optionRatios < 2 ** 112) {\n\n// @audit `112`\n419: } else if (optionRatios < 2 ** 112) {\n\n// @audit `2`\n421: } else if (optionRatios < 2 ** 160) {\n\n// @audit `160`\n421: } else if (optionRatios < 2 ** 160) {\n\n// @audit `2`\n422: return 2;\n\n// @audit `2`\n423: } else if (optionRatios < 2 ** 208) {\n\n// @audit `208`\n423: } else if (optionRatios < 2 ** 208) {\n\n// @audit `3`\n424: return 3;\n\n// @audit `4`\n426: return 4;\n\n// @audit `0xFFFFFFFFFFFF_FFFFFFFFFFFF_FFFFFFFFFFFF_000000000000_FFFFFFFFFFFFFFFF`\n444: return self & 0xFFFFFFFFFFFF_FFFFFFFFFFFF_FFFFFFFFFFFF_000000000000_FFFFFFFFFFFFFFFF;\n\n// @audit `0xFFFFFFFFFFFF_FFFFFFFFFFFF_000000000000_FFFFFFFFFFFF_FFFFFFFFFFFFFFFF`\n446: return self & 0xFFFFFFFFFFFF_FFFFFFFFFFFF_000000000000_FFFFFFFFFFFF_FFFFFFFFFFFFFFFF;\n\n// @audit `2`\n447: if (i == 2)\n\n// @audit `0xFFFFFFFFFFFF_000000000000_FFFFFFFFFFFF_FFFFFFFFFFFF_FFFFFFFFFFFFFFFF`\n448: return self & 0xFFFFFFFFFFFF_000000000000_FFFFFFFFFFFF_FFFFFFFFFFFF_FFFFFFFFFFFFFFFF;\n\n// @audit `3`\n449: if (i == 3)\n\n// @audit `0x000000000000_FFFFFFFFFFFF_FFFFFFFFFFFF_FFFFFFFFFFFF_FFFFFFFFFFFFFFFF`\n450: return self & 0x000000000000_FFFFFFFFFFFF_FFFFFFFFFFFF_FFFFFFFFFFFF_FFFFFFFFFFFFFFFF;\n\n// @audit `4`\n468: for (uint256 i = 0; i < 4; ++i) {\n\n// @audit `64`\n473: if ((self >> (64 + 48 * i)) != 0) revert Errors.InvalidTokenIdParameter(1);\n\n// @audit `48`\n473: if ((self >> (64 + 48 * i)) != 0) revert Errors.InvalidTokenIdParameter(1);\n\n// @audit `5`\n480: if ((self.width(i) == 0)) revert Errors.InvalidTokenIdParameter(5);\n\n// @audit `4`\n485: ) revert Errors.InvalidTokenIdParameter(4);\n\n// @audit `3`\n494: revert Errors.InvalidTokenIdParameter(3);\n\n// @audit `3`\n500: ) revert Errors.InvalidTokenIdParameter(3);\n\n// @audit `4`\n513: revert Errors.InvalidTokenIdParameter(4);\n\n// @audit `5`\n518: revert Errors.InvalidTokenIdParameter(5);\n```","loc":["[95](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L95)","[95](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L95)","[95](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L95)","[105](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L105)","[105](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L105)","[105](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L105)","[115](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L115)","[115](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L115)","[115](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L115)","[115](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L115)","[125](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L125)","[125](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L125)","[125](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L125)","[125](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L125)","[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L141)","[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L141)","[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L141)","[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L141)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L151)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L151)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L151)","[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L162)","[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L162)","[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L162)","[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L162)","[195](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L195)","[195](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L195)","[195](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L195)","[210](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L210)","[210](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L210)","[210](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L210)","[226](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L226)","[226](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L226)","[226](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L226)","[226](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L226)","[240](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L240)","[240](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L240)","[240](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L240)","[240](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L240)","[254](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L254)","[254](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L254)","[254](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L254)","[254](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L254)","[268](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L268)","[268](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L268)","[268](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L268)","[283](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L283)","[283](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L283)","[283](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L283)","[283](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L283)","[337](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L337)","[337](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L337)","[339](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L339)","[339](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L339)","[341](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L341)","[341](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L341)","[342](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L342)","[343](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L343)","[343](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L343)","[344](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L344)","[346](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L346)","[353](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L353)","[353](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L353)","[363](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L363)","[363](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L363)","[389](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L389)","[417](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L417)","[417](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L417)","[419](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L419)","[419](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L419)","[421](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L421)","[421](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L421)","[422](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L422)","[423](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L423)","[423](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L423)","[424](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L424)","[426](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L426)","[444](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L444)","[446](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L446)","[447](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L447)","[448](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L448)","[449](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L449)","[450](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L450)","[468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L468)","[473](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L473)","[473](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L473)","[480](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L480)","[485](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L485)","[494](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L494)","[500](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L500)","[513](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L513)","[518](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L518)"]}]},{"severity":"NonCritical","title":"Missing NatSpec from contract declarations","description":"e.g. `@dev` or `@notice`, and it must appear above the contract definition braces in order to be identified by the compiler as NatSpec.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n72: contract SemiFungiblePositionManager is ERC1155, Multicall {\n```","loc":["[72](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L72)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@author` from contract declaration","description":"Some contract definitions have an incomplete NatSpec: add a `@author` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n72: contract SemiFungiblePositionManager is ERC1155, Multicall {\n```","loc":["[72](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L72)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@dev` from contract declaration","description":"Some contract definitions have an incomplete NatSpec: add a `@dev` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n72: contract SemiFungiblePositionManager is ERC1155, Multicall {\n```","loc":["[72](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L72)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n10: library CallbackLib {\n```","loc":["[10](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L10)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n6: library Constants {\n```","loc":["[6](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L6)"]},{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n6: library Errors {\n```","loc":["[6](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L6)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n12: library Math {\n```","loc":["[12](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L12)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n13: library PanopticMath {\n```","loc":["[13](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L13)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n10: abstract contract ERC1155 {\n```","loc":["[10](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L10)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n13: library LeftRight {\n```","loc":["[13](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L13)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@dev` from event declaration","description":"Some event definitions have an incomplete NatSpec: add a `@dev` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n79: event PoolInitialized(address indexed uniswapPool);\n```","loc":["[79](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L79)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n21: event TransferSingle(\n\n35: event TransferBatch(\n\n44: event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n```","loc":["[21](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L21)","[35](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L35)","[44](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L44)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@dev` from function declaration","description":"Some function definitions have an incomplete NatSpec: add a `@dev` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n331: function endReentrancyLock(uint64 poolId) internal {\n\n342: constructor(IUniswapV3Factory _factory) {\n\n511: uint256 tokenId,\n\n545: address from,\n\n564: address from,\n\n664: uint256 tokenId,\n\n744: IUniswapV3Pool univ3pool,\n\n1074: bytes32 positionKey,\n\n1094: IUniswapV3Pool univ3pool,\n\n1201: uint256 liquidityChunk,\n\n1256: uint256 currentLiquidity,\n```","loc":["[331](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L331)","[342](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L342)","[511](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L511)","[545](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L545)","[564](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L564)","[664](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L664)","[744](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L744)","[1074](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1074)","[1094](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1094)","[1201](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1201)","[1256](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1256)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n28: function validateCallback(\n```","loc":["[28](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L28)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n119: function getAmount1ForLiquidity(\n\n154: function getLiquidityForAmount1(\n\n172: function toUint128(uint256 toDowncast) internal pure returns (uint128 downcastedInt) {\n\n286: function mulDiv64(uint256 a, uint256 b) internal pure returns (uint256 result) {\n\n348: function mulDiv96(uint256 a, uint256 b) internal pure returns (uint256 result) {\n\n410: function mulDiv128(uint256 a, uint256 b) internal pure returns (uint256 result) {\n\n472: function mulDiv192(uint256 a, uint256 b) internal pure returns (uint256 result) {\n```","loc":["[119](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L119)","[154](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L154)","[172](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L172)","[286](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L286)","[348](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L348)","[410](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L410)","[472](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L472)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n48: function getFinalPoolId(\n\n82: function getLiquidityChunk(\n```","loc":["[48](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L48)","[82](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L82)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n16: function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L16)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n12: function multicall(bytes[] calldata data) public payable returns (bytes[] memory results) {\n```","loc":["[12](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L12)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n77: function setApprovalForAll(address operator, bool approved) public {\n\n200: function supportsInterface(bytes4 interfaceId) public pure returns (bool) {\n\n214: function _mint(address to, uint256 id, uint256 amount) internal {\n\n236: function _burn(address from, uint256 id, uint256 amount) internal {\n```","loc":["[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L77)","[200](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L200)","[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L214)","[236](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L236)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n25: function rightSlot(uint256 self) internal pure returns (uint128) {\n\n32: function rightSlot(int256 self) internal pure returns (int128) {\n\n44: function toRightSlot(uint256 self, uint128 right) internal pure returns (uint256) {\n\n54: function toRightSlot(uint256 self, int128 right) internal pure returns (uint256) {\n\n65: function toRightSlot(int256 self, uint128 right) internal pure returns (int256) {\n\n75: function toRightSlot(int256 self, int128 right) internal pure returns (int256) {\n\n89: function leftSlot(uint256 self) internal pure returns (uint128) {\n\n96: function leftSlot(int256 self) internal pure returns (int128) {\n\n108: function toLeftSlot(uint256 self, uint128 left) internal pure returns (uint256) {\n\n118: function toLeftSlot(int256 self, uint128 left) internal pure returns (int256) {\n\n128: function toLeftSlot(int256 self, int128 left) internal pure returns (int256) {\n\n142: function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n\n159: function add(int256 x, int256 y) internal pure returns (int256 z) {\n\n177: function sub(int256 x, int256 y) internal pure returns (int256 z) {\n\n198: function toInt128(int256 self) internal pure returns (int128 selfAsInt128) {\n\n205: function toUint128(uint256 self) internal pure returns (uint128 selfAsUint128) {\n\n212: function toInt256(uint256 self) internal pure returns (int256) {\n```","loc":["[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L25)","[32](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L32)","[44](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L44)","[54](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L54)","[65](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L65)","[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L75)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L89)","[96](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L96)","[108](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L108)","[118](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L118)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L128)","[142](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L142)","[159](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L159)","[177](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L177)","[198](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L198)","[205](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L205)","[212](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L212)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n63: function createChunk(\n\n78: function addLiquidity(uint256 self, uint128 amount) internal pure returns (uint256) {\n\n88: function addTickLower(uint256 self, int24 _tickLower) internal pure returns (uint256) {\n\n98: function addTickUpper(uint256 self, int24 _tickUpper) internal pure returns (uint256) {\n\n112: function tickLower(uint256 self) internal pure returns (int24) {\n\n121: function tickUpper(uint256 self) internal pure returns (int24) {\n\n130: function liquidity(uint256 self) internal pure returns (uint128) {\n```","loc":["[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L63)","[78](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L78)","[88](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L88)","[98](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L98)","[112](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L112)","[121](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L121)","[130](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L130)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n80: function univ3pool(uint256 self) internal pure returns (uint64) {\n\n113: function isLong(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n123: function tokenType(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n139: function riskPartner(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n149: function strike(uint256 self, uint256 legIndex) internal pure returns (int24) {\n\n173: function addUniv3pool(uint256 self, uint64 _poolId) internal pure returns (uint256) {\n\n220: function addIsLong(\n\n234: function addTokenType(\n\n248: function addRiskPartner(\n\n262: function addStrike(\n\n276: function addWidth(\n\n298: function addLeg(\n\n361: function countLongs(uint256 self) internal pure returns (uint256) {\n```","loc":["[80](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L80)","[113](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L113)","[123](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L123)","[139](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L139)","[149](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L149)","[173](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L173)","[220](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L220)","[234](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L234)","[248](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L248)","[262](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L262)","[276](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L276)","[298](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L298)","[361](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L361)"]}]},{"severity":"NonCritical","title":"Error declarations should have NatSpec descriptions","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n51: error NotAuthorized();\n\n54: error UnsafeRecipient();\n```","loc":["[51](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L51)","[54](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L54)"]}]},{"severity":"NonCritical","title":"NatSpec documentation for function is missing","description":"It is recommended that Solidity contracts are fully annotated using NatSpec for all public interfaces (everything in the ABI). It is clearly stated in the Solidity official documentation. In complex projects such as DeFi, the interpretation of all functions and their arguments and returns is important for code readability and auditability.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n16: function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L16)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@notice` from contract declaration","description":"Some contract definitions have an incomplete NatSpec: add a `@notice` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n72: contract SemiFungiblePositionManager is ERC1155, Multicall {\n```","loc":["[72](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L72)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n10: library CallbackLib {\n```","loc":["[10](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L10)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n6: library Constants {\n```","loc":["[6](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L6)"]},{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n6: library Errors {\n```","loc":["[6](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L6)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n12: library Math {\n```","loc":["[12](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L12)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n13: library PanopticMath {\n```","loc":["[13](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L13)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n10: abstract contract ERC1155 {\n```","loc":["[10](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L10)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@notice` from function declaration","description":"Some function definitions have an incomplete NatSpec: add a `@notice` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n82: function getLiquidityChunk(\n```","loc":["[82](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L82)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n16: function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L16)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@param` from event declaration","description":"Some event definitions have an incomplete NatSpec: add a `@param` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n44: event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n```","loc":["[44](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L44)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@param` from function declaration","description":"Some function definitions have an incomplete NatSpec: add a `@param` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n/// @audit missing @param for `token`\n/// @audit missing @param for `from`\n/// @audit missing @param for `to`\n/// @audit missing @param for `amount`\n16: function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L16)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n/// @audit missing @param for `_poolId`\n173: function addUniv3pool(uint256 self, uint64 _poolId) internal pure returns (uint256) {\n\n/// @audit missing @param for `_asset`\n189: function addAsset(\n uint256 self,\n uint256 _asset,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n/// @audit missing @param for `_optionRatio`\n204: function addOptionRatio(\n uint256 self,\n uint256 _optionRatio,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n/// @audit missing @param for `_tokenType`\n234: function addTokenType(\n uint256 self,\n uint256 _tokenType,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n/// @audit missing @param for `_riskPartner`\n248: function addRiskPartner(\n uint256 self,\n uint256 _riskPartner,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n/// @audit missing @param for `_strike`\n262: function addStrike(\n uint256 self,\n int24 _strike,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n/// @audit missing @param for `_width`\n276: function addWidth(\n uint256 self,\n int24 _width,\n uint256 legIndex\n ) internal pure returns (uint256) {\n```","loc":["[173](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L173)","[189](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L189)","[204](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L204)","[234](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L234)","[248](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L248)","[262](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L262)","[276](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L276)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@return` from function declaration","description":"Some function definitions have an incomplete NatSpec: add a `@return` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n1094: IUniswapV3Pool univ3pool,\n uint128 liquidity,\n uint256 liquidityChunk\n ) private view returns (int256 feesBase) {\n // now collect fee growth within the liquidity chunk in `liquidityChunk`\n```","loc":["[1094](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1094)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n103: function optionRatio(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n327: function flipToBurnToken(uint256 self) internal pure returns (uint256) {\n```","loc":["[103](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L103)","[327](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L327)"]}]},{"severity":"NonCritical","title":"Missing NatSpec `@title` from contract declaration","description":"Some contract definitions have an incomplete NatSpec: add a `@title` notation to improve the code documentation.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n72: contract SemiFungiblePositionManager is ERC1155, Multicall {\n```","loc":["[72](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L72)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n11: library SafeTransferLib {\n```","loc":["[11](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L11)"]}]},{"severity":"NonCritical","title":"There is no need to initialize variables with 0","description":"Since the variables are automatically set to 0 when created, it is redundant to initialize it with 0 again.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n550: for (uint256 i = 0; i < ids.length; ) {\n\n583: for (uint256 leg = 0; leg < numLegs; ) {\n\n860: for (uint256 leg = 0; leg < numLegs; ) {\n```","loc":["[550](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L550)","[583](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L583)","[860](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L860)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n14: for (uint256 i = 0; i < data.length; ) {\n```","loc":["[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L14)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n141: for (uint256 i = 0; i < ids.length; ) {\n\n187: for (uint256 i = 0; i < owners.length; ++i) {\n```","loc":["[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L141)","[187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L187)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n468: for (uint256 i = 0; i < 4; ++i) {\n```","loc":["[468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L468)"]}]},{"severity":"NonCritical","title":"Non-assembly method available","description":"There are some automated tools that will flag a project as having higher complexity if there is inline-assembly, so it's best to avoid using it where it's not necessary. In addition, most assembly methods can be replaced by non-assembly methods, for example:\n- `assembly{ g := gas() }` => `uint256 g = gasleft()`\n- `assembly{ id := chainid() }` => `uint256 id = block.chainid`\n- `assembly { r := mulmod(a, b, d) }` => `uint256 m = mulmod(x, y, k)`\n- `assembly { size := extcodesize() }` => `uint256 size = address(a).code.length`\n- etc.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n200: let mm := mulmod(a, b, not(0))\n\n226: remainder := mulmod(a, b, denominator)\n\n296: let mm := mulmod(a, b, not(0))\n\n321: remainder := mulmod(a, b, 0x10000000000000000)\n\n358: let mm := mulmod(a, b, not(0))\n\n383: remainder := mulmod(a, b, 0x1000000000000000000000000)\n\n420: let mm := mulmod(a, b, not(0))\n\n445: remainder := mulmod(a, b, 0x100000000000000000000000000000000)\n\n482: let mm := mulmod(a, b, not(0))\n\n507: remainder := mulmod(a, b, 0x1000000000000000000000000000000000000000000000000)\n```","loc":["[200](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L200)","[226](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L226)","[296](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L296)","[321](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L321)","[358](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L358)","[383](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L383)","[420](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L420)","[445](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L445)","[482](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L482)","[507](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L507)"]}]},{"severity":"NonCritical","title":"Put all system-wide constants in one file","description":"Putting all the system-wide constants in a single file improves code readability, makes it easier to understand the basic configuration and limitations of the system, and makes maintenance easier.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n127: bool internal constant MINT = false;\n\n128: bool internal constant BURN = true;\n\n135: uint128 private constant VEGOID = 2;\n```","loc":["[127](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L127)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L128)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L135)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n8: uint256 internal constant FP96 = 0x1000000000000000000000000;\n\n11: int24 internal constant MIN_V3POOL_TICK = -887272;\n\n14: int24 internal constant MAX_V3POOL_TICK = 887272;\n\n17: uint160 internal constant MIN_V3POOL_SQRT_RATIO = 4295128739;\n\n20: uint160 internal constant MAX_V3POOL_SQRT_RATIO =\n\n25: bytes32 internal constant V3POOL_INIT_CODE_HASH =\n```","loc":["[8](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L8)","[11](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L11)","[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L14)","[17](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L17)","[20](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L20)","[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L25)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n16: int256 internal constant RIGHT_HALF_BIT_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L16)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n60: uint256 internal constant LONG_MASK =\n\n63: uint256 internal constant CLEAR_POOLID_MASK =\n\n66: uint256 internal constant OPTION_RATIO_MASK =\n\n68: int256 internal constant BITMASK_INT24 = 0xFFFFFF;\n\n71: uint256 internal constant RISK_PARTNER_MASK = 0xFFFFFFFFF3FF;\n```","loc":["[60](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L60)","[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L63)","[66](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L66)","[68](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L68)","[71](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L71)"]}]},{"severity":"NonCritical","title":"Redundant `return` statement in a function with named return variables","description":"Because the return variable (or its default value) has been assigned, explicit return at the end of the function is unnecessary, as it is returned automatically.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n744: IUniswapV3Pool univ3pool,\n\n1458: uint64 poolId\n```","loc":["[744](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L744)","[1458](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1458)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n119: function getAmount1ForLiquidity(\n\n154: function getLiquidityForAmount1(\n\n186: function mulDiv(\n\n286: function mulDiv64(uint256 a, uint256 b) internal pure returns (uint256 result) {\n\n348: function mulDiv96(uint256 a, uint256 b) internal pure returns (uint256 result) {\n\n410: function mulDiv128(uint256 a, uint256 b) internal pure returns (uint256 result) {\n\n472: function mulDiv192(uint256 a, uint256 b) internal pure returns (uint256 result) {\n```","loc":["[119](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L119)","[154](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L154)","[186](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L186)","[286](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L286)","[348](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L348)","[410](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L410)","[472](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L472)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n177: function sub(int256 x, int256 y) internal pure returns (int256 z) {\n```","loc":["[177](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L177)"]}]},{"severity":"NonCritical","title":"Unnecessary cast","description":"The variable is being cast to its own type.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit no need to cast `univ3pool` into address\n356: if (address(univ3pool) == address(0)) revert Errors.UniswapPoolNotInitialized();\n\n/// @audit no need to cast `univ3pool` into address\n356: if (address(univ3pool) == address(0)) revert Errors.UniswapPoolNotInitialized();\n\n/// @audit no need to cast `univ3pool` into address\n356: if (address(univ3pool) == address(0)) revert Errors.UniswapPoolNotInitialized();\n\n/// @audit no need to cast `univ3pool` into address\n356: if (address(univ3pool) == address(0)) revert Errors.UniswapPoolNotInitialized();\n\n/// @audit no need to cast `univ3pool` into address\n356: if (address(univ3pool) == address(0)) revert Errors.UniswapPoolNotInitialized();\n\n/// @audit no need to cast `amount0Delta` into int256\n457: uint256 amountToPay = amount0Delta > 0 ? uint256(amount0Delta) : uint256(amount1Delta);\n\n/// @audit no need to cast `amount1Delta` into int256\n457: uint256 amountToPay = amount0Delta > 0 ? uint256(amount0Delta) : uint256(amount1Delta);\n\n/// @audit no need to cast `univ3pool` into address\n596: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n596: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n596: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n596: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n596: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n605: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n605: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n605: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n605: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n605: address(univ3pool),\n\n/// @audit no need to cast `univ3pool` into address\n1381: abi.encodePacked(address(univ3pool), owner, tokenType, tickLower, tickUpper)\n\n/// @audit no need to cast `univ3pool` into address\n1381: abi.encodePacked(address(univ3pool), owner, tokenType, tickLower, tickUpper)\n\n/// @audit no need to cast `univ3pool` into address\n1381: abi.encodePacked(address(univ3pool), owner, tokenType, tickLower, tickUpper)\n\n/// @audit no need to cast `univ3pool` into address\n1381: abi.encodePacked(address(univ3pool), owner, tokenType, tickLower, tickUpper)\n\n/// @audit no need to cast `univ3pool` into address\n1381: abi.encodePacked(address(univ3pool), owner, tokenType, tickLower, tickUpper)\n```","loc":["[356](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L356)","[356](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L356)","[356](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L356)","[356](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L356)","[356](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L356)","[457](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L457)","[457](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L457)","[596](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L596)","[596](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L596)","[596](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L596)","[596](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L596)","[596](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L596)","[605](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L605)","[605](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L605)","[605](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L605)","[605](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L605)","[605](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L605)","[1381](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1381)","[1381](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1381)","[1381](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1381)","[1381](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1381)","[1381](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1381)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n/// @audit no need to cast `x` into int256\n25: return x > 0 ? uint256(x) : uint256(-x);\n```","loc":["[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L25)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n/// @audit no need to cast `left` into int128\n120: return self + (int256(int128(left)) << 128);\n\n/// @audit no need to cast `self` into int256\n214: return int256(self);\n\n/// @audit no need to cast `self` into int256\n214: return int256(self);\n\n/// @audit no need to cast `self` into int256\n214: return int256(self);\n\n/// @audit no need to cast `self` into int256\n214: return int256(self);\n\n/// @audit no need to cast `self` into int256\n214: return int256(self);\n\n/// @audit no need to cast `self` into int256\n214: return int256(self);\n\n/// @audit no need to cast `self` into int256\n214: return int256(self);\n```","loc":["[120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L120)","[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L214)","[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L214)","[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L214)","[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L214)","[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L214)","[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L214)","[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L214)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n/// @audit no need to cast `_tickLower` into int24\n90: return self + (uint256(uint24(_tickLower)) << 232);\n\n/// @audit no need to cast `_tickLower` into int24\n90: return self + (uint256(uint24(_tickLower)) << 232);\n\n/// @audit no need to cast `_tickUpper` into int24\n101: return self + ((uint256(uint24(_tickUpper))) << 208);\n\n/// @audit no need to cast `_tickUpper` into int24\n101: return self + ((uint256(uint24(_tickUpper))) << 208);\n```","loc":["[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L90)","[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L90)","[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L101)","[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L101)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n/// @audit no need to cast `_width` into int24\n283: return self + (uint256(uint24(_width) % 4096) << (64 + legIndex * 48 + 36));\n\n/// @audit no need to cast `_width` into int24\n283: return self + (uint256(uint24(_width) % 4096) << (64 + legIndex * 48 + 36));\n```","loc":["[283](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L283)","[283](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L283)"]}]},{"severity":"NonCritical","title":"Unused `error` definition","description":"The following `error`s are defined but not used. It is recommended to check the code for logical omissions that cause them not to be used. If it's determined that they are not needed anywhere, it's best to remove them from the codebase to improve code clarity and minimize confusion. Note that there may be cases where an error appears to be used because it has multiple definitions in different files. In such cases, the definitions should be moved to a separate file.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n11: error CastingError();\n\n14: error InvalidTick();\n\n17: error InvalidUniswapCallback();\n\n21: error InvalidTokenIdParameter(uint256 parameterType);\n\n24: error LeftRightInputError();\n\n27: error NoLegsExercisable();\n\n30: error PositionTooLarge();\n\n33: error NotEnoughLiquidity();\n\n36: error OptionsBalanceZero();\n\n39: error PriceBoundFail();\n\n42: error ReentrantCall();\n\n45: error TransferFailed();\n\n49: error TicksNotInitializable();\n\n52: error UnderOverFlow();\n\n55: error UniswapPoolNotInitialized();\n```","loc":["[11](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L11)","[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L14)","[17](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L17)","[21](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L21)","[24](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L24)","[27](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L27)","[30](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L30)","[33](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L33)","[36](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L36)","[39](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L39)","[42](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L42)","[45](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L45)","[49](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L49)","[52](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L52)","[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L55)"]}]},{"severity":"NonCritical","title":"Unused arguments should be removed or implemented","description":"Some arguments are never used: if this is intentional, consider removing these arguments from the function. Otherwise, implement the missing logic accordingly.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit `from`\n/// @audit `to`\n/// @audit `ids`\n/// @audit `amounts`\n252: function afterTokenTransfer(\n\n/// @audit `from`\n/// @audit `to`\n/// @audit `id`\n/// @audit `amount`\n265: function afterTokenTransfer(\n```","loc":["[252](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L252)","[265](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L265)"]}]},{"severity":"NonCritical","title":"Unused import","description":"The identifier is imported but never used within the file.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n/// @audit `TokenId`\n5: import {TokenId} from \"@types/TokenId.sol\";\n```","loc":["[5](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L5)"]}]},{"severity":"NonCritical","title":"Unused named return","description":"Declaring named returns, but not using them, is confusing to the reader. Consider either completely removing them (by declaring just the type without a name), or remove the return statement and do a variable assignment. This would improve the readability of the code, and it may also help reduce regressions during future code refactors.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `UniswapV3Pool` not used\n1458: uint64 poolId\n ) external view returns (IUniswapV3Pool UniswapV3Pool) {\n return s_poolContext[poolId].pool;\n```","loc":["[1458](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1458)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n/// @audit `amount0` not used\n101: function getAmount0ForLiquidity(\n uint256 liquidityChunk\n ) internal pure returns (uint256 amount0) {\n\n/// @audit `amount1` not used\n119: function getAmount1ForLiquidity(\n uint256 liquidityChunk\n ) internal pure returns (uint256 amount1) {\n\n/// @audit `liquidity` not used\n135: function getLiquidityForAmount0(\n uint256 liquidityChunk,\n uint256 amount0\n ) internal pure returns (uint128 liquidity) {\n\n/// @audit `liquidity` not used\n154: function getLiquidityForAmount1(\n uint256 liquidityChunk,\n uint256 amount1\n ) internal pure returns (uint128 liquidity) {\n```","loc":["[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L101)","[119](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L119)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L135)","[154](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L154)"]}]},{"severity":"NonCritical","title":"Unused contract variables","description":"The following state variables are defined but not used. It is recommended to check the code for logical omissions that cause them not to be used. If it's determined that they are not needed anywhere, it's best to remove them from the codebase to improve code clarity and minimize confusion.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n16: int256 internal constant RIGHT_HALF_BIT_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L16)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n63: uint256 internal constant CLEAR_POOLID_MASK =\n\n66: uint256 internal constant OPTION_RATIO_MASK =\n\n68: int256 internal constant BITMASK_INT24 = 0xFFFFFF;\n```","loc":["[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L63)","[66](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L66)","[68](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L68)"]}]},{"severity":"NonCritical","title":"Consider using `delete` rather than assigning zero/false to clear values","description":"The `delete` keyword more closely matches the semantics of what is being done, and draws more attention to the changing of state, which may lead to a more thorough audit of its associated logic.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n333: s_poolContext[poolId].locked = false;\n\n627: s_accountLiquidity[positionKey_from] = 0;\n\n630: s_accountFeesBase[positionKey_from] = 0;\n```","loc":["[333](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L333)","[627](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L627)","[630](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L630)"]}]},{"severity":"NonCritical","title":"Solidity compiler version is not fixed","description":"To prevent the actual contracts deployed from behaving differently depending on the compiler version, it is recommended to use a fixed solidity version.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L2)"]}]},{"severity":"NonCritical","title":"Expressions for constant values should use `immutable` rather than `constant`","description":"While it doesn't save any gas because the compiler knows that developers often make this mistake, it's still best to use the right tool for the task at hand. There is a difference between `constant` variables and `immutable` variables, and they should each be used in their appropriate contexts. `constants` should be used for literal values written into the code, and `immutable` variables should be used for expressions, or values calculated in, or passed into the constructor.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n127: bool internal constant MINT = false;\n\n128: bool internal constant BURN = true;\n\n135: uint128 private constant VEGOID = 2;\n```","loc":["[127](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L127)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L128)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L135)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n8: uint256 internal constant FP96 = 0x1000000000000000000000000;\n\n11: int24 internal constant MIN_V3POOL_TICK = -887272;\n\n14: int24 internal constant MAX_V3POOL_TICK = 887272;\n\n17: uint160 internal constant MIN_V3POOL_SQRT_RATIO = 4295128739;\n\n20: uint160 internal constant MAX_V3POOL_SQRT_RATIO =\n\n25: bytes32 internal constant V3POOL_INIT_CODE_HASH =\n```","loc":["[8](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L8)","[11](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L11)","[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L14)","[17](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L17)","[20](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L20)","[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L25)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n16: int256 internal constant RIGHT_HALF_BIT_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L16)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n60: uint256 internal constant LONG_MASK =\n\n63: uint256 internal constant CLEAR_POOLID_MASK =\n\n66: uint256 internal constant OPTION_RATIO_MASK =\n\n68: int256 internal constant BITMASK_INT24 = 0xFFFFFF;\n\n71: uint256 internal constant RISK_PARTNER_MASK = 0xFFFFFFFFF3FF;\n```","loc":["[60](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L60)","[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L63)","[66](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L66)","[68](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L68)","[71](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L71)"]}]},{"severity":"NonCritical","title":"Upgrade `openzeppelin` to the latest version (`5.0.0`)","description":"These contracts import contracts from openzeppelin contracts but they are not using the latest version. For more information, please visit: [OpenZeppelin GitHub Releases](https://github.com/OpenZeppelin/openzeppelin-contracts/releases) It is recommended to always use the latest version to take advantage of updates and security fixes.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\n\nGlobal finding\n```","loc":["[1](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/)"]}]},{"severity":"NonCritical","title":"Use the latest solidity version for deployment (`0.8.23`)","description":"Upgrading to a newer Solidity release can optimize gas usage, take advantage of new features and improve overall contract efficiency. Where possible, based on compatibility requirements, it is recommended to use newer/latest solidity version to take advantage of the latest optimizations and features.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n2: pragma solidity =0.8.18;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n2: pragma solidity =0.8.18;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L2)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L2)"]}]},{"severity":"NonCritical","title":"Use of `override` is unnecessary","description":"Starting with Solidity version [0.8.8](https://docs.soliditylang.org/en/v0.8.20/contracts.html#function-overriding), using the `override` keyword when the function solely overrides an interface function, and the function doesn't exist in multiple base contracts, is unnecessary.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n549: ) internal override {\n\n568: ) internal override {\n```","loc":["[549](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L549)","[568](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L568)"]}]},{"severity":"NonCritical","title":"Use a struct to encapsulate multiple function parameters","description":"If a function has too many parameters, replacing them with a struct can improve code readability and maintainability, increase reusability, and reduce the likelihood of errors when passing the parameters.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit 7 parameters\n1372: address univ3pool,\n address owner,\n uint256 tokenType,\n int24 tickLower,\n int24 tickUpper,\n int24 atTick,\n uint256 isLong\n ) external view returns (uint128 premiumToken0, uint128 premiumToken1) {\n bytes32 positionKey = keccak256(\n```","loc":["[1372](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1372)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n/// @audit 9 parameters\n298: function addLeg(\n uint256 self,\n uint256 legIndex,\n uint256 _optionRatio,\n uint256 _asset,\n uint256 _isLong,\n uint256 _tokenType,\n uint256 _riskPartner,\n int24 _strike,\n int24 _width\n ) internal pure returns (uint256 tokenId) {\n```","loc":["[298](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L298)"]}]},{"severity":"NonCritical","title":"Use `type(X).max` instead of constant formulas like `2**n`","description":"Earlier versions of solidity can use `uint<n>(-1)` instead. Expressions `2**n -1` can often be rewritten to accommodate the change (e.g. by using a `>` instead of a `>=`, which will also saves gas).","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n1281: .mulDiv(collected0, totalLiquidity * 2 ** 64, netLiquidity ** 2)\n\n1284: .mulDiv(collected1, totalLiquidity * 2 ** 64, netLiquidity ** 2)\n```","loc":["[1281](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1281)","[1284](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1284)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n264: inv *= 2 - denominator * inv; // inverse mod 2**8\n\n265: inv *= 2 - denominator * inv; // inverse mod 2**16\n\n266: inv *= 2 - denominator * inv; // inverse mod 2**32\n\n267: inv *= 2 - denominator * inv; // inverse mod 2**64\n\n268: inv *= 2 - denominator * inv; // inverse mod 2**128\n\n269: inv *= 2 - denominator * inv; // inverse mod 2**256\n\n311: require(2 ** 64 > prod1);\n\n400: prod0 |= prod1 * 2 ** 160;\n\n435: require(2 ** 128 > prod1);\n\n462: prod0 |= prod1 * 2 ** 128;\n\n524: prod0 |= prod1 * 2 ** 64;\n```","loc":["[264](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L264)","[265](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L265)","[266](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L266)","[267](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L267)","[268](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L268)","[269](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L269)","[311](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L311)","[400](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L400)","[435](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L435)","[462](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L462)","[524](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L524)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n181: 2 ** 128,\n```","loc":["[181](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L181)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n337: if (optionRatios < 2 ** 64) {\n\n341: } else if (optionRatios < 2 ** 160) {\n\n417: if (optionRatios < 2 ** 64) {\n\n421: } else if (optionRatios < 2 ** 160) {\n```","loc":["[337](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L337)","[341](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L341)","[417](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L417)","[421](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L421)"]}]},{"severity":"NonCritical","title":"Whitespace in Expressions","description":"See the [Whitespace in Expressions](https://docs.soliditylang.org/en/latest/style-guide.html#whitespace-in-expressions) section of the Solidity Style Guide.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n711: (, newTick, , , , , ) = univ3pool.slot0();\n\n775: (uint160 sqrtPriceX96, , , , , , ) = _univ3pool.slot0();\n\n1102: (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = univ3pool\n```","loc":["[711](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L711)","[775](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L775)","[1102](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1102)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n101: (, , uint256 lowerOut0, uint256 lowerOut1, , , , ) = univ3pool.ticks(tickLower);\n\n102: (, , uint256 upperOut0, uint256 upperOut1, , , , ) = univ3pool.ticks(tickUpper);\n```","loc":["[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L101)","[102](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L102)"]}]},{"severity":"NonCritical","title":"Common functions should be refactored to a common base contract","description":"The functions below have the same implementation as is seen in other files. The functions should be refactored into functions of a common base contract.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n/// @audit seen in contracts/types/TokenId.sol\n130: function liquidity(uint256 self) internal pure returns (uint128) {\n```","loc":["[130](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L130)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n/// @audit seen in contracts/types/LiquidityChunk.sol\n80: function univ3pool(uint256 self) internal pure returns (uint64) {\n```","loc":["[80](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L80)"]}]},{"severity":"NonCritical","title":"Names of `private`/`internal` functions should be prefixed with an underscore","description":"It is recommended by the [Solidity Style Guide](https://docs.soliditylang.org/en/v0.8.20/style-guide.html#underscore-prefix-for-non-external-functions-and-variables)","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n321: function beginReentrancyLock(uint64 poolId) internal {\n // check if the pool is already locked, if so, revert\n\n331: function endReentrancyLock(uint64 poolId) internal {\n // gas refund is triggered here by returning the slot to its original value\n\n545: address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts\n ) internal override {\n for (uint256 i = 0; i < ids.length; ) {\n\n564: address from,\n address to,\n uint256 id,\n uint256 amount\n ) internal override {\n registerTokenTransfer(from, to, id, amount);\n\n578: function registerTokenTransfer(address from, address to, uint256 id, uint256 amount) internal {\n // Extract univ3pool from the poolId map to Uniswap Pool\n\n744: IUniswapV3Pool univ3pool,\n int256 itmAmounts\n ) internal returns (int256 totalSwapped) {\n // Initialize variables\n bool zeroForOne; // The direction of the swap, true for token0 to token1, false for token1 to token0\n```","loc":["[321](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L321)","[331](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L331)","[545](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L545)","[564](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L564)","[578](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L578)","[744](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L744)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n28: function validateCallback(\n address sender,\n address factory,\n PoolFeatures memory features\n ) internal pure {\n```","loc":["[28](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L28)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n23: function absUint(int256 x) internal pure returns (uint256) {\n\n38: function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n\n101: function getAmount0ForLiquidity(\n uint256 liquidityChunk\n ) internal pure returns (uint256 amount0) {\n\n119: function getAmount1ForLiquidity(\n uint256 liquidityChunk\n ) internal pure returns (uint256 amount1) {\n\n135: function getLiquidityForAmount0(\n uint256 liquidityChunk,\n uint256 amount0\n ) internal pure returns (uint128 liquidity) {\n\n154: function getLiquidityForAmount1(\n uint256 liquidityChunk,\n uint256 amount1\n ) internal pure returns (uint128 liquidity) {\n\n172: function toUint128(uint256 toDowncast) internal pure returns (uint128 downcastedInt) {\n\n186: function mulDiv(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n\n286: function mulDiv64(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n\n348: function mulDiv96(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n\n410: function mulDiv128(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n\n472: function mulDiv192(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n```","loc":["[23](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L23)","[38](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L38)","[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L101)","[119](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L119)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L135)","[154](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L154)","[172](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L172)","[186](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L186)","[286](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L286)","[348](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L348)","[410](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L410)","[472](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L472)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n38: function getPoolId(address univ3pool) internal pure returns (uint64) {\n\n48: function getFinalPoolId(\n uint64 basePoolId,\n address token0,\n address token1,\n uint24 fee\n ) internal pure returns (uint64) {\n\n82: function getLiquidityChunk(\n uint256 tokenId,\n uint256 legIndex,\n uint128 positionSize,\n int24 tickSpacing\n ) internal pure returns (uint256 liquidityChunk) {\n\n145: function convert0to1(int256 amount, uint160 sqrtPriceX96) internal pure returns (int256) {\n\n168: function convert1to0(int256 amount, uint160 sqrtPriceX96) internal pure returns (int256) {\n```","loc":["[38](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L38)","[48](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L48)","[82](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L82)","[145](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L145)","[168](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L168)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n16: function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L16)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n252: function afterTokenTransfer(\n\n265: function afterTokenTransfer(\n```","loc":["[252](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L252)","[265](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L265)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n25: function rightSlot(uint256 self) internal pure returns (uint128) {\n\n32: function rightSlot(int256 self) internal pure returns (int128) {\n\n44: function toRightSlot(uint256 self, uint128 right) internal pure returns (uint256) {\n\n54: function toRightSlot(uint256 self, int128 right) internal pure returns (uint256) {\n\n65: function toRightSlot(int256 self, uint128 right) internal pure returns (int256) {\n\n75: function toRightSlot(int256 self, int128 right) internal pure returns (int256) {\n\n89: function leftSlot(uint256 self) internal pure returns (uint128) {\n\n96: function leftSlot(int256 self) internal pure returns (int128) {\n\n108: function toLeftSlot(uint256 self, uint128 left) internal pure returns (uint256) {\n\n118: function toLeftSlot(int256 self, uint128 left) internal pure returns (int256) {\n\n128: function toLeftSlot(int256 self, int128 left) internal pure returns (int256) {\n\n142: function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n\n159: function add(int256 x, int256 y) internal pure returns (int256 z) {\n\n177: function sub(int256 x, int256 y) internal pure returns (int256 z) {\n\n198: function toInt128(int256 self) internal pure returns (int128 selfAsInt128) {\n\n205: function toUint128(uint256 self) internal pure returns (uint128 selfAsUint128) {\n\n212: function toInt256(uint256 self) internal pure returns (int256) {\n```","loc":["[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L25)","[32](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L32)","[44](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L44)","[54](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L54)","[65](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L65)","[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L75)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L89)","[96](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L96)","[108](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L108)","[118](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L118)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L128)","[142](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L142)","[159](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L159)","[177](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L177)","[198](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L198)","[205](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L205)","[212](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L212)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n63: function createChunk(\n uint256 self,\n int24 _tickLower,\n int24 _tickUpper,\n uint128 amount\n ) internal pure returns (uint256) {\n\n78: function addLiquidity(uint256 self, uint128 amount) internal pure returns (uint256) {\n\n88: function addTickLower(uint256 self, int24 _tickLower) internal pure returns (uint256) {\n\n98: function addTickUpper(uint256 self, int24 _tickUpper) internal pure returns (uint256) {\n\n112: function tickLower(uint256 self) internal pure returns (int24) {\n\n121: function tickUpper(uint256 self) internal pure returns (int24) {\n\n130: function liquidity(uint256 self) internal pure returns (uint128) {\n```","loc":["[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L63)","[78](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L78)","[88](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L88)","[98](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L98)","[112](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L112)","[121](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L121)","[130](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L130)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n80: function univ3pool(uint256 self) internal pure returns (uint64) {\n\n93: function asset(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n103: function optionRatio(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n113: function isLong(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n123: function tokenType(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n139: function riskPartner(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n149: function strike(uint256 self, uint256 legIndex) internal pure returns (int24) {\n\n160: function width(uint256 self, uint256 legIndex) internal pure returns (int24) {\n\n173: function addUniv3pool(uint256 self, uint64 _poolId) internal pure returns (uint256) {\n\n189: function addAsset(\n uint256 self,\n uint256 _asset,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n204: function addOptionRatio(\n uint256 self,\n uint256 _optionRatio,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n220: function addIsLong(\n uint256 self,\n uint256 _isLong,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n234: function addTokenType(\n uint256 self,\n uint256 _tokenType,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n248: function addRiskPartner(\n uint256 self,\n uint256 _riskPartner,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n262: function addStrike(\n uint256 self,\n int24 _strike,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n276: function addWidth(\n uint256 self,\n int24 _width,\n uint256 legIndex\n ) internal pure returns (uint256) {\n\n298: function addLeg(\n uint256 self,\n uint256 legIndex,\n uint256 _optionRatio,\n uint256 _asset,\n uint256 _isLong,\n uint256 _tokenType,\n uint256 _riskPartner,\n int24 _strike,\n int24 _width\n ) internal pure returns (uint256 tokenId) {\n\n327: function flipToBurnToken(uint256 self) internal pure returns (uint256) {\n\n361: function countLongs(uint256 self) internal pure returns (uint256) {\n\n374: function asTicks(\n uint256 self,\n uint256 legIndex,\n int24 tickSpacing\n ) internal pure returns (int24 legLowerTick, int24 legUpperTick) {\n\n410: function countLegs(uint256 self) internal pure returns (uint256) {\n\n442: function clearLeg(uint256 self, uint256 i) internal pure returns (uint256) {\n\n463: function validate(uint256 self) internal pure returns (uint64) {\n```","loc":["[80](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L80)","[93](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L93)","[103](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L103)","[113](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L113)","[123](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L123)","[139](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L139)","[149](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L149)","[160](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L160)","[173](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L173)","[189](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L189)","[204](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L204)","[220](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L220)","[234](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L234)","[248](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L248)","[262](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L262)","[276](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L276)","[298](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L298)","[327](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L327)","[361](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L361)","[374](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L374)","[410](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L410)","[442](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L442)","[463](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L463)"]}]},{"severity":"NonCritical","title":"Names of `private`/`internal` state variables should be prefixed with an underscore","description":"It is recommended by the [Solidity Style Guide](https://docs.soliditylang.org/en/v0.8.20/style-guide.html#underscore-prefix-for-non-external-functions-and-variables)","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n127: bool internal constant MINT = false;\n\n128: bool internal constant BURN = true;\n\n135: uint128 private constant VEGOID = 2;\n\n139: IUniswapV3Factory internal immutable FACTORY;\n\n147: mapping(address univ3pool => uint256 poolIdData) internal s_AddrToPoolIdData;\n\n152: mapping(uint64 poolId => PoolAddressAndLock contextData) internal s_poolContext;\n\n179: mapping(bytes32 positionKey => uint256 removedAndNetLiquidity) internal s_accountLiquidity;\n\n288: mapping(bytes32 positionKey => uint256 accountPremium) private s_accountPremiumOwed;\n\n290: mapping(bytes32 positionKey => uint256 accountPremium) private s_accountPremiumGross;\n\n296: mapping(bytes32 positionKey => int256 baseFees0And1) internal s_accountFeesBase;\n```","loc":["[127](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L127)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L128)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L135)","[139](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L139)","[147](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L147)","[152](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L152)","[179](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L179)","[288](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L288)","[290](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L290)","[296](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L296)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n8: uint256 internal constant FP96 = 0x1000000000000000000000000;\n\n11: int24 internal constant MIN_V3POOL_TICK = -887272;\n\n14: int24 internal constant MAX_V3POOL_TICK = 887272;\n\n17: uint160 internal constant MIN_V3POOL_SQRT_RATIO = 4295128739;\n\n20: uint160 internal constant MAX_V3POOL_SQRT_RATIO =\n\n25: bytes32 internal constant V3POOL_INIT_CODE_HASH =\n```","loc":["[8](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L8)","[11](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L11)","[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L14)","[17](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L17)","[20](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L20)","[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L25)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n16: int256 internal constant RIGHT_HALF_BIT_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L16)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n60: uint256 internal constant LONG_MASK =\n\n63: uint256 internal constant CLEAR_POOLID_MASK =\n\n66: uint256 internal constant OPTION_RATIO_MASK =\n\n68: int256 internal constant BITMASK_INT24 = 0xFFFFFF;\n\n71: uint256 internal constant RISK_PARTNER_MASK = 0xFFFFFFFFF3FF;\n```","loc":["[60](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L60)","[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L63)","[66](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L66)","[68](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L68)","[71](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L71)"]}]},{"severity":"NonCritical","title":" `require()` / `revert()` statements should have descriptive reason strings","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n325: // activate lock\n\n356: if (address(univ3pool) == address(0)) revert Errors.UniswapPoolNotInitialized();\n\n619: // Revert if not all balance is transferred\n\n623: int256 fromBase = s_accountFeesBase[positionKey_from];\n\n673: /// @dev the flipToBurnToken() function flips the isLong bits\n\n683: if (univ3pool == IUniswapV3Pool(address(0))) revert Errors.UniswapPoolNotInitialized();\n\n715: return (totalCollectedFromAMM, totalMoved, newTick);\n\n919: }\n\n991: } else {\n```","loc":["[325](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L325)","[356](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L356)","[619](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L619)","[623](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L623)","[673](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L673)","[683](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L683)","[715](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L715)","[919](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L919)","[991](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L991)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n50: ) revert Errors.InvalidUniswapCallback();\n```","loc":["[50](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L50)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n41: if (absTick > uint256(int256(Constants.MAX_V3POOL_TICK))) revert Errors.InvalidTick();\n\n173: if ((downcastedInt = uint128(toDowncast)) != toDowncast) revert Errors.CastingError();\n\n207: require(denominator > 0);\n\n216: require(denominator > prod1);\n\n311: require(2 ** 64 > prod1);\n\n373: require(2 ** 96 > prod1);\n\n435: require(2 ** 128 > prod1);\n\n497: require(2 ** 192 > prod1);\n```","loc":["[41](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L41)","[173](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L173)","[207](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L207)","[216](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L216)","[311](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L311)","[373](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L373)","[435](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L435)","[497](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L497)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n40: if (!success) revert Errors.TransferFailed();\n```","loc":["[40](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L40)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n55: if (right < 0) revert Errors.LeftRightInputError();\n\n151: if (z < x || (uint128(z) < uint128(x))) revert Errors.UnderOverFlow();\n\n167: if (left128 != left256 || right128 != right256) revert Errors.UnderOverFlow();\n\n185: if (left128 != left256 || right128 != right256) revert Errors.UnderOverFlow();\n\n199: if (!((selfAsInt128 = int128(self)) == self)) revert Errors.CastingError();\n\n206: if (!((selfAsUint128 = uint128(self)) == self)) revert Errors.CastingError();\n\n213: if (self > uint256(type(int256).max)) revert Errors.CastingError();\n```","loc":["[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L55)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L151)","[167](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L167)","[185](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L185)","[199](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L199)","[206](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L206)","[213](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L213)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n401: ) revert Errors.TicksNotInitializable();\n\n464: if (self.optionRatio(0) == 0) revert Errors.InvalidTokenIdParameter(1);\n\n473: if ((self >> (64 + 48 * i)) != 0) revert Errors.InvalidTokenIdParameter(1);\n\n480: if ((self.width(i) == 0)) revert Errors.InvalidTokenIdParameter(5);\n\n485: ) revert Errors.InvalidTokenIdParameter(4);\n\n494: revert Errors.InvalidTokenIdParameter(3);\n\n500: ) revert Errors.InvalidTokenIdParameter(3);\n\n513: revert Errors.InvalidTokenIdParameter(4);\n\n518: revert Errors.InvalidTokenIdParameter(5);\n```","loc":["[401](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L401)","[464](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L464)","[473](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L473)","[480](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L480)","[485](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L485)","[494](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L494)","[500](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L500)","[513](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L513)","[518](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L518)"]}]},{"severity":"NonCritical","title":"Variables should be named in mixedCase style","description":"As the [Solidity Style Guide](https://docs.soliditylang.org/en/latest/style-guide.html#naming-styles) suggests: `arguments`, `local variables` and `mutable state variables` should be named in mixedCase style.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `UniswapV3Pool`\n1460: return s_poolContext[poolId].pool;\n```","loc":["[1460](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1460)"]}]},{"severity":"NonCritical","title":"Event is missing `indexed` fields","description":"Index event fields make the field more quickly accessible to off-chain tools that parse events. However, note that each index field costs extra gas during emission, so it's not necessarily best to index the maximum allowed per event (three fields). Each event should use three indexed fields if there are three or more fields, and gas usage is not particularly of concern for the events in question. If there are fewer than three fields, all of the fields should be indexed.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n86: event TokenizedPositionBurnt(\n\n97: event TokenizedPositionMinted(\n```","loc":["[86](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L86)","[97](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L97)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n44: event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n```","loc":["[44](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L44)"]}]},{"severity":"NonCritical","title":"Functions not used internally could be marked `external`","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n54: function calculateAMMSwapFeesLiquidityChunk(\n```","loc":["[54](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L54)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n12: function multicall(bytes[] calldata data) public payable returns (bytes[] memory results) {\n```","loc":["[12](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L12)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n77: function setApprovalForAll(address operator, bool approved) public {\n\n90: function safeTransferFrom(\n\n178: function balanceOfBatch(\n\n200: function supportsInterface(bytes4 interfaceId) public pure returns (bool) {\n```","loc":["[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L77)","[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L90)","[178](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L178)","[200](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L200)"]}]},{"severity":"Gas","title":"Optimize gas by using do-while loops","description":"Using `do-while` loops instead of `for` loops can be more gas-efficient. Even if you add an `if` condition to account for the case where the loop doesn't execute at all, a `do-while` loop can still be cheaper in terms of gas.","gasSavings":1785,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n550: for (uint256 i = 0; i < ids.length; ) {\n\n583: for (uint256 leg = 0; leg < numLegs; ) {\n\n860: for (uint256 leg = 0; leg < numLegs; ) {\n```","loc":["[550](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L550)","[583](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L583)","[860](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L860)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n14: for (uint256 i = 0; i < data.length; ) {\n```","loc":["[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L14)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n141: for (uint256 i = 0; i < ids.length; ) {\n\n187: for (uint256 i = 0; i < owners.length; ++i) {\n```","loc":["[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L141)","[187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L187)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n468: for (uint256 i = 0; i < 4; ++i) {\n```","loc":["[468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L468)"]}]},{"severity":"Gas","title":"Multiple `address`/ID mappings can be combined into a single `mapping` of an `address`/ID to a `struct`, where appropriate","description":"Saves a storage slot for the mapping. Depending on the circumstances and sizes of types, can avoid a Gsset (20000 gas) per mapping combined. Reads and subsequent writes can also be cheaper when a function requires both values and they both fit in the same storage slot. Finally, if both fields are accessed in the same function, can save ~42 gas per access due to not having to [recalculate the key's keccak256 hash](https://gist.github.com/IllIllI000/ec23a57daa30a8f8ca8b9681c8ccefb0) (Gkeccak256 - 30 gas) and that calculation's associated stack operations.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n62: mapping(address account => mapping(uint256 tokenId => uint256 balance)) public balanceOf;\n\n67: mapping(address owner => mapping(address operator => bool approvedForAll))\n```","loc":["[62](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L62)","[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L67)"]}]},{"severity":"Gas","title":"Consider activating via-ir for deploying","description":"By using `--via-ir` or `{\"viaIR\": true}`, the compiler is able to use more advanced [multi-function optimizations](https://docs.soliditylang.org/en/v0.8.17/ir-breaking-changes.html#solidity-ir-based-codegen-changes), for extra gas savings.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\n\nGlobal finding\n```","loc":["[1](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/)"]}]},{"severity":"Gas","title":"Divisions can be `unchecked` to save gas","description":"The expression `type(int).min/(-1)` is the only case where division causes an overflow. Therefore, uncheck can be used to [save gas](https://gist.github.com/DadeKuma/3bc597338ae774b8b3bd43280d55271f) in scenarios where it is certain that such an overflow will not occur.","gasSavings":200,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n229: s_accountPremiumOwed += feeGrowthX128 * R * (1 + ν*R/N) / R\n\n272: = ∆feeGrowthX128 * t * (T - R + ν*R^2/T) / N \n\n273: = ∆feeGrowthX128 * t * (N + ν*R^2/T) / N\n\n1293: uint256 numerator = netLiquidity + (removedLiquidity / 2 ** VEGOID);\n\n1316: ((removedLiquidity ** 2) / 2 ** (VEGOID));\n```","loc":["[229](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L229)","[272](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L272)","[273](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L273)","[1293](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1293)","[1316](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1316)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n86: if (tick > 0) sqrtR = type(uint256).max / sqrtR;\n\n112: ) / lowPriceX96;\n```","loc":["[86](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L86)","[112](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L112)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n385: int24 minTick = (Constants.MIN_V3POOL_TICK / tickSpacing) * tickSpacing;\n\n386: int24 maxTick = (Constants.MAX_V3POOL_TICK / tickSpacing) * tickSpacing;\n\n389: int24 oneSidedRange = (selfWidth * tickSpacing) / 2;\n```","loc":["[385](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L385)","[386](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L386)","[389](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L389)"]}]},{"severity":"Gas","title":"Do not calculate constants","description":"Due to how constant variables are implemented (replacements at compile-time), an expression assigned to a constant variable is recomputed each time that the variable is used, which wastes some gas.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n11: int24 internal constant MIN_V3POOL_TICK = -887272;\n```","loc":["[11](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L11)"]}]},{"severity":"Gas","title":"Duplicated `require()`/`revert()` checks should be refactored to a modifier or function to save gas","description":"Saves deployment costs.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit duplicated on line 168\n115: revert UnsafeRecipient();\n```","loc":["[115](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L115)"]}]},{"severity":"Gas","title":"Increments can be `unchecked` to save gas","description":"Using `unchecked` increments can save gas by bypassing the built-in overflow checks. This can save 30-40 gas per iteration. So it is recommended to use unchecked increments when overflow is not possible.","gasSavings":120,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n187: for (uint256 i = 0; i < owners.length; ++i) {\n```","loc":["[187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L187)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n468: for (uint256 i = 0; i < 4; ++i) {\n```","loc":["[468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L468)"]}]},{"severity":"Gas","title":"`internal` functions only called once can be inlined to save gas","description":"If an `internal` function is only used once, there is no need to modularize it, unless the function calling it would otherwise be too long and complex. Not inlining costs 20 to 40 gas because of two extra JUMP instructions and additional stack operations needed for function calls.","gasSavings":540,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `beginReentrancyLock` is used only once\n321: function beginReentrancyLock(uint64 poolId) internal {\n\n/// @audit `endReentrancyLock` is used only once\n331: function endReentrancyLock(uint64 poolId) internal {\n\n/// @audit `swapInAMM` is used only once\n744: IUniswapV3Pool univ3pool,\n\n/// @audit `_createPositionInAMM` is used only once\n849: IUniswapV3Pool univ3pool,\n\n/// @audit `_createLegInAMM` is used only once\n937: IUniswapV3Pool _univ3pool,\n\n/// @audit `_mintLiquidity` is used only once\n1130: uint256 liquidityChunk,\n\n/// @audit `_burnLiquidity` is used only once\n1170: uint256 liquidityChunk,\n\n/// @audit `_collectAndWritePositionData` is used only once\n1201: uint256 liquidityChunk,\n```","loc":["[321](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L321)","[331](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L331)","[744](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L744)","[849](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L849)","[937](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L937)","[1130](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1130)","[1170](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1170)","[1201](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1201)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n/// @audit `_getAMMSwapFeesPerLiquidityCollected` is used only once\n89: function _getAMMSwapFeesPerLiquidityCollected(\n```","loc":["[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L89)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit `_mint` is used only once\n214: function _mint(address to, uint256 id, uint256 amount) internal {\n\n/// @audit `_burn` is used only once\n236: function _burn(address from, uint256 id, uint256 amount) internal {\n```","loc":["[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L214)","[236](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L236)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n/// @audit `addAsset` is used only once\n189: function addAsset(\n\n/// @audit `addOptionRatio` is used only once\n204: function addOptionRatio(\n\n/// @audit `addIsLong` is used only once\n220: function addIsLong(\n\n/// @audit `addTokenType` is used only once\n234: function addTokenType(\n\n/// @audit `addRiskPartner` is used only once\n248: function addRiskPartner(\n\n/// @audit `addStrike` is used only once\n262: function addStrike(\n\n/// @audit `addWidth` is used only once\n276: function addWidth(\n```","loc":["[189](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L189)","[204](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L204)","[220](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L220)","[234](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L234)","[248](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L248)","[262](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L262)","[276](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L276)"]}]},{"severity":"Gas","title":"Multiple accesses of the same mapping/array key/index should be cached","description":"The instances below point to the second+ access of a value inside a mapping/array, within a function. Caching a mapping's value in a local `storage` or `calldata` variable when the value is accessed [multiple times](https://gist.github.com/IllIllI000/ec23a57daa30a8f8ca8b9681c8ccefb0), saves ~42 gas per access due to not having to recalculate the key's keccak256 hash (Gkeccak256 - 30 gas) and that calculation's associated stack operations. Caching an array's struct avoids recalculating the array offsets into memory/calldata","gasSavings":420,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `s_poolContext[poolId]` is also accessed on line 323\n326: s_poolContext[poolId].locked = true;\n\n/// @audit `s_poolContext[poolId]` is also accessed on line 370\n375: s_poolContext[poolId] = PoolAddressAndLock({\n\n/// @audit `s_AddrToPoolIdData[univ3pool]` is also accessed on line 363\n384: s_AddrToPoolIdData[univ3pool] = uint256(poolId) + 2 ** 255;\n\n/// @audit `s_accountLiquidity[positionKey_to]` is also accessed on line 615\n626: s_accountLiquidity[positionKey_to] = fromLiq;\n\n/// @audit `s_accountLiquidity[positionKey_from]` is also accessed on line 620\n627: s_accountLiquidity[positionKey_from] = 0;\n\n/// @audit `s_accountFeesBase[positionKey_to]` is also accessed on line 616\n629: s_accountFeesBase[positionKey_to] = fromBase;\n\n/// @audit `s_accountFeesBase[positionKey_from]` is also accessed on line 623\n630: s_accountFeesBase[positionKey_from] = 0;\n\n/// @audit `s_accountLiquidity[positionKey]` is also accessed on line 959\n1004: s_accountLiquidity[positionKey] = uint256(0).toLeftSlot(removedLiquidity).toRightSlot(\n\n/// @audit `s_accountFeesBase[positionKey]` is also accessed on line 1402\n1409: amountToCollect = feesBase.sub(s_accountFeesBase[positionKey]);\n```","loc":["[326](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L326)","[375](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L375)","[384](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L384)","[626](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L626)","[627](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L627)","[629](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L629)","[630](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L630)","[1004](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1004)","[1409](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1409)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n/// @audit ` = ` is also accessed on line 182\n188: balances[i] = balanceOf[owners[i]][ids[i]];\n```","loc":["[188](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L188)"]}]},{"severity":"Gas","title":"Newer versions of solidity are more gas efficient","description":"The solidity language continues to pursue more efficient gas optimization schemes. Adopting a newer version of solidity can be more gas efficient.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n2: pragma solidity =0.8.18;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n2: pragma solidity =0.8.18;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L2)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L2)"]}]},{"severity":"Gas","title":"Operator `>=`/`<=` costs less gas than operator `>`/`<`","description":"The compiler uses opcodes `GT` and `ISZERO` for code that uses `>`, but only requires `LT` for `>=`. A similar behavior applies for `>`, which uses opcodes `LT` and `ISZERO`, but only requires `GT` for `<=`. It can save 3 gas for each. It should be converted to the `<=`/`>=` equivalent when comparing against integer literals.","gasSavings":147,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n417: if (amount0Owed > 0)\n\n424: if (amount1Owed > 0)\n\n452: address token = amount0Delta > 0\n\n457: uint256 amountToPay = amount0Delta > 0 ? uint256(amount0Delta) : uint256(amount1Delta);\n\n550: for (uint256 i = 0; i < ids.length; ) {\n\n583: for (uint256 leg = 0; leg < numLegs; ) {\n\n687: if (tickLimitLow > tickLimitHigh) {\n\n806: zeroForOne = net0 < 0;\n\n811: zeroForOne = itm0 < 0;\n\n814: zeroForOne = itm1 > 0;\n\n860: for (uint256 leg = 0; leg < numLegs; ) {\n\n917: if (amount0 > uint128(type(int128).max) || amount1 > uint128(type(int128).max))\n\n917: if (amount0 > uint128(type(int128).max) || amount1 > uint128(type(int128).max))\n\n985: if (startingLiquidity < chunkLiquidity) {\n\n1390: if (atTick < type(int24).max) {\n```","loc":["[417](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L417)","[424](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L424)","[452](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L452)","[457](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L457)","[550](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L550)","[583](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L583)","[687](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L687)","[806](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L806)","[811](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L811)","[814](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L814)","[860](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L860)","[917](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L917)","[917](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L917)","[985](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L985)","[1390](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1390)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n106: if (currentTick < tickLower) {\n```","loc":["[106](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L106)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n25: return x > 0 ? uint256(x) : uint256(-x);\n\n40: uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n\n41: if (absTick > uint256(int256(Constants.MAX_V3POOL_TICK))) revert Errors.InvalidTick();\n\n86: if (tick > 0) sqrtR = type(uint256).max / sqrtR;\n\n207: require(denominator > 0);\n\n216: require(denominator > prod1);\n\n311: require(2 ** 64 > prod1);\n\n373: require(2 ** 96 > prod1);\n\n435: require(2 ** 128 > prod1);\n\n497: require(2 ** 192 > prod1);\n```","loc":["[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L25)","[40](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L40)","[41](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L41)","[86](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L86)","[207](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L207)","[216](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L216)","[311](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L311)","[373](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L373)","[435](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L435)","[497](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L497)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n149: if (sqrtPriceX96 < 340275971719517849884101479065584693834) {\n\n153: return amount < 0 ? -absResult : absResult;\n\n158: return amount < 0 ? -absResult : absResult;\n\n172: if (sqrtPriceX96 < 340275971719517849884101479065584693834) {\n\n176: return amount < 0 ? -absResult : absResult;\n\n185: return amount < 0 ? -absResult : absResult;\n```","loc":["[149](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L149)","[153](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L153)","[158](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L158)","[172](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L172)","[176](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L176)","[185](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L185)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n14: for (uint256 i = 0; i < data.length; ) {\n```","loc":["[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L14)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n141: for (uint256 i = 0; i < ids.length; ) {\n\n187: for (uint256 i = 0; i < owners.length; ++i) {\n```","loc":["[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L141)","[187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L187)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n55: if (right < 0) revert Errors.LeftRightInputError();\n\n151: if (z < x || (uint128(z) < uint128(x))) revert Errors.UnderOverFlow();\n\n213: if (self > uint256(type(int256).max)) revert Errors.CastingError();\n```","loc":["[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L55)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L151)","[213](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L213)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n337: if (optionRatios < 2 ** 64) {\n\n339: } else if (optionRatios < 2 ** 112) {\n\n341: } else if (optionRatios < 2 ** 160) {\n\n343: } else if (optionRatios < 2 ** 208) {\n\n399: legLowerTick < minTick ||\n\n400: legUpperTick > maxTick\n\n417: if (optionRatios < 2 ** 64) {\n\n419: } else if (optionRatios < 2 ** 112) {\n\n421: } else if (optionRatios < 2 ** 160) {\n\n423: } else if (optionRatios < 2 ** 208) {\n\n468: for (uint256 i = 0; i < 4; ++i) {\n```","loc":["[337](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L337)","[339](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L339)","[341](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L341)","[343](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L343)","[399](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L399)","[400](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L400)","[417](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L417)","[419](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L419)","[421](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L421)","[423](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L423)","[468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L468)"]}]},{"severity":"Gas","title":"Optimize Gas by splitting `if() revert` statements","description":"Using boolean operators in a single `if() revert` statement can consume more gas than necessary. Consider splitting these statements to save gas.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n713: if ((newTick >= tickLimitHigh) || (newTick <= tickLimitLow)) revert Errors.PriceBoundFail();\n\n917: if (amount0 > uint128(type(int128).max) || amount1 > uint128(type(int128).max))\n```","loc":["[713](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L713)","[917](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L917)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n97: if (!(msg.sender == from || isApprovedForAll[from][msg.sender])) revert NotAuthorized();\n\n135: if (!(msg.sender == from || isApprovedForAll[from][msg.sender])) revert NotAuthorized();\n```","loc":["[97](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L97)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L135)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n151: if (z < x || (uint128(z) < uint128(x))) revert Errors.UnderOverFlow();\n\n167: if (left128 != left256 || right128 != right256) revert Errors.UnderOverFlow();\n\n185: if (left128 != left256 || right128 != right256) revert Errors.UnderOverFlow();\n```","loc":["[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L151)","[167](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L167)","[185](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L185)"]}]},{"severity":"Gas","title":"Optimize names to save gas","description":"`public`/`external` function names and `public` member variable names can be optimized to save gas. See this [link](https://gist.github.com/IllIllI000/a5d8b486a8259f9f77891a919febd1a9) for an example of how it works. Below are the interfaces/abstract contracts that can be optimized so that the most frequently-called functions use the least amount of gas possible during method lookup. Method IDs that have two leading zero bytes can save 128 gas each during deployment, and renaming functions to have lower method IDs will save 22 gas per call, [per sorted position shifted](https://medium.com/joyso/solidity-how-does-function-name-affect-gas-consumption-in-smart-contract-47d270d8ac92)","gasSavings":22,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `initializeAMMPool`, `uniswapV3MintCallback`, `uniswapV3SwapCallback`, `burnTokenizedPosition`, `mintTokenizedPosition`, `getAccountLiquidity`, `getAccountPremium`, `getAccountFeesBase`, `getUniswapV3PoolFromId`, `getPoolId`\n72: contract SemiFungiblePositionManager is ERC1155, Multicall {\n```","loc":["[72](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L72)"]}]},{"severity":"Gas","title":"Reduce gas usage by moving to Solidity 0.8.19 or later","description":"Solidity version 0.8.19 introduced a number of gas optimizations, refer to the [Solidity 0.8.19 Release Announcement](https://soliditylang.org/blog/2023/02/22/solidity-0.8.19-release-announcement/) for details.","gasSavings":13000,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n2: pragma solidity =0.8.18;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n2: pragma solidity =0.8.18;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L2)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L2)"]}]},{"severity":"Gas","title":"Remove or replace unused state variables","description":"Saves a storage slot. If the variable is assigned a non-zero value, saves Gsset (20000 gas). If it's assigned a zero value, saves Gsreset (2900 gas). If the variable remains unassigned, there is no gas savings unless the variable is `public`, in which case the compiler-generated non-payable getter deployment cost is saved. If the state variable is overriding an interface's public function, mark the variable as `constant` or `immutable` so that it does not use a storage slot.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n16: int256 internal constant RIGHT_HALF_BIT_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L16)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n63: uint256 internal constant CLEAR_POOLID_MASK =\n\n66: uint256 internal constant OPTION_RATIO_MASK =\n\n68: int256 internal constant BITMASK_INT24 = 0xFFFFFF;\n```","loc":["[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L63)","[66](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L66)","[68](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L68)"]}]},{"severity":"Gas","title":"The result of a function call should be cached rather than re-calling the function","description":"The function calls in solidity are expensive. If the same result of the same function calls are to be used several times, the result should be cached to reduce the gas consumption of repeated calls.","gasSavings":2200,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `tokenType` is called 2 times\n/// @audit `tickLower` is called 2 times\n/// @audit `tickUpper` is called 2 times\n578: function registerTokenTransfer(address from, address to, uint256 id, uint256 amount) internal {\n // Extract univ3pool from the poolId map to Uniswap Pool\n\n/// @audit `add` is called 3 times\n849: IUniswapV3Pool univ3pool,\n uint256 tokenId,\n uint128 positionSize,\n bool isBurn\n ) internal returns (int256 totalMoved, int256 totalCollected, int256 itmAmounts) {\n // upper bound on amount of tokens contained across all legs of the position at any given tick\n\n/// @audit `rightSlot` is called 3 times\n/// @audit `leftSlot` is called 2 times\n/// @audit `toRightSlot` is called 2 times\n/// @audit `toLeftSlot` is called 2 times\n937: IUniswapV3Pool _univ3pool,\n uint256 _tokenId,\n uint256 _leg,\n uint256 _liquidityChunk,\n bool _isBurn\n ) internal returns (int256 _moved, int256 _itmAmounts, int256 _totalCollected) {\n uint256 _tokenType = TokenId.tokenType(_tokenId, _leg);\n\n/// @audit `add` is called 2 times\n1074: bytes32 positionKey,\n uint256 currentLiquidity,\n int256 collectedAmounts\n ) private {\n (uint256 deltaPremiumOwed, uint256 deltaPremiumGross) = _getPremiaDeltas(\n\n/// @audit `mulDiv128` is called 2 times\n1094: IUniswapV3Pool univ3pool,\n uint128 liquidity,\n uint256 liquidityChunk\n ) private view returns (int256 feesBase) {\n // now collect fee growth within the liquidity chunk in `liquidityChunk`\n\n/// @audit `rightSlot` is called 4 times\n/// @audit `sub` is called 2 times\n/// @audit `leftSlot` is called 3 times\n1201: uint256 liquidityChunk,\n IUniswapV3Pool univ3pool,\n uint256 currentLiquidity,\n bytes32 positionKey,\n int256 movedInLeg,\n uint256 isLong\n ) internal returns (int256 collectedOut) {\n uint128 startingLiquidity = currentLiquidity.rightSlot();\n\n/// @audit `leftSlot` is called 2 times\n/// @audit `rightSlot` is called 2 times\n/// @audit `mulDiv` is called 6 times\n/// @audit `toUint128` is called 6 times\n/// @audit `toRightSlot` is called 2 times\n/// @audit `toLeftSlot` is called 2 times\n1256: uint256 currentLiquidity,\n int256 collectedAmounts\n ) private pure returns (uint256 deltaPremiumOwed, uint256 deltaPremiumGross) {\n // extract liquidity values\n uint256 removedLiquidity = currentLiquidity.leftSlot();\n\n/// @audit `rightSlot` is called 2 times\n/// @audit `add` is called 2 times\n1372: address univ3pool,\n address owner,\n uint256 tokenType,\n int24 tickLower,\n int24 tickUpper,\n int24 atTick,\n uint256 isLong\n ) external view returns (uint128 premiumToken0, uint128 premiumToken1) {\n bytes32 positionKey = keccak256(\n```","loc":["[578](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L578)","[849](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L849)","[937](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L937)","[1074](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1074)","[1094](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1094)","[1201](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1201)","[1256](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1256)","[1372](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1372)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n/// @audit `mulDiv128` is called 2 times\n54: function calculateAMMSwapFeesLiquidityChunk(\n IUniswapV3Pool univ3pool,\n int24 currentTick,\n uint128 startingLiquidity,\n uint256 liquidityChunk\n ) public view returns (int256 feesEachToken) {\n```","loc":["[54](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L54)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n/// @audit `getSqrtRatioAtTick` is called 2 times\n101: function getAmount0ForLiquidity(\n uint256 liquidityChunk\n ) internal pure returns (uint256 amount0) {\n\n/// @audit `getSqrtRatioAtTick` is called 2 times\n119: function getAmount1ForLiquidity(\n uint256 liquidityChunk\n ) internal pure returns (uint256 amount1) {\n\n/// @audit `getSqrtRatioAtTick` is called 2 times\n135: function getLiquidityForAmount0(\n uint256 liquidityChunk,\n uint256 amount0\n ) internal pure returns (uint128 liquidity) {\n\n/// @audit `getSqrtRatioAtTick` is called 2 times\n154: function getLiquidityForAmount1(\n uint256 liquidityChunk,\n uint256 amount1\n ) internal pure returns (uint128 liquidity) {\n\n/// @audit `sub` is called 4 times\n186: function mulDiv(\n uint256 a,\n uint256 b,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n\n/// @audit `sub` is called 3 times\n286: function mulDiv64(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n\n/// @audit `sub` is called 3 times\n348: function mulDiv96(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n\n/// @audit `sub` is called 3 times\n410: function mulDiv128(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n\n/// @audit `sub` is called 3 times\n472: function mulDiv192(uint256 a, uint256 b) internal pure returns (uint256 result) {\n unchecked {\n```","loc":["[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L101)","[119](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L119)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L135)","[154](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L154)","[186](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L186)","[286](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L286)","[348](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L348)","[410](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L410)","[472](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L472)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n/// @audit `addTickLower` is called 2 times\n/// @audit `addTickUpper` is called 2 times\n82: function getLiquidityChunk(\n uint256 tokenId,\n uint256 legIndex,\n uint128 positionSize,\n int24 tickSpacing\n ) internal pure returns (uint256 liquidityChunk) {\n\n/// @audit `absUint` is called 2 times\n/// @audit `toInt256` is called 2 times\n145: function convert0to1(int256 amount, uint160 sqrtPriceX96) internal pure returns (int256) {\n\n/// @audit `absUint` is called 2 times\n/// @audit `mulDiv` is called 2 times\n/// @audit `toInt256` is called 2 times\n168: function convert1to0(int256 amount, uint160 sqrtPriceX96) internal pure returns (int256) {\n```","loc":["[82](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L82)","[145](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L145)","[168](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L168)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n/// @audit `add` is called 3 times\n16: function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L16)"]}]},{"severity":"Gas","title":"Structs can be packed into fewer storage slots","description":"Each slot saved can avoid an extra Gsset (20000 gas) for the first setting of the struct. Subsequent reads as well as writes have smaller gas savings.","gasSavings":20000,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n/// @audit 3 slots -> 2 slots by new order:\n/*\n *\t address token0 (20 Bytes)\n *\t uint24 fee (3 Bytes)\n *\t address token1 (20 Bytes)\n */\n12: struct PoolFeatures {\n address token0;\n address token1;\n uint24 fee;\n```","loc":["[12](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L12)"]}]},{"severity":"Gas","title":"Unused named return variables without optimizer waste gas","description":"Consider changing the variable to be an unnamed one, since the variable is never assigned, nor is it returned by name. If the optimizer is not turned on, leaving the code as it is will also waste gas for the stack variable.","gasSavings":45,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit `UniswapV3Pool` not used\n1458: uint64 poolId\n ) external view returns (IUniswapV3Pool UniswapV3Pool) {\n return s_poolContext[poolId].pool;\n```","loc":["[1458](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1458)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n/// @audit `amount0` not used\n101: function getAmount0ForLiquidity(\n uint256 liquidityChunk\n ) internal pure returns (uint256 amount0) {\n\n/// @audit `amount1` not used\n119: function getAmount1ForLiquidity(\n uint256 liquidityChunk\n ) internal pure returns (uint256 amount1) {\n\n/// @audit `liquidity` not used\n135: function getLiquidityForAmount0(\n uint256 liquidityChunk,\n uint256 amount0\n ) internal pure returns (uint128 liquidity) {\n\n/// @audit `liquidity` not used\n154: function getLiquidityForAmount1(\n uint256 liquidityChunk,\n uint256 amount1\n ) internal pure returns (uint128 liquidity) {\n```","loc":["[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L101)","[119](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L119)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L135)","[154](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L154)"]}]},{"severity":"Gas","title":"Use assembly to compute hashes to save gas","description":"If the arguments to the encode call can fit into the scratch space (two words or fewer), then it's more efficient to use assembly to generate the hash (80 gas):\n\n`keccak256(abi.encodePacked(x, y)) -> assembly {mstore(0x00, a); mstore(0x20, b); let hash := keccak256(0x00, 0x40); }`","gasSavings":880,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n594: bytes32 positionKey_from = keccak256(\n\n603: bytes32 positionKey_to = keccak256(\n\n945: bytes32 positionKey = keccak256(\n\n1104: keccak256(\n\n1353: keccak256(abi.encodePacked(univ3pool, owner, tokenType, tickLower, tickUpper))\n\n1380: bytes32 positionKey = keccak256(\n\n1446: keccak256(abi.encodePacked(univ3pool, owner, tokenType, tickLower, tickUpper))\n```","loc":["[594](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L594)","[603](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L603)","[945](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L945)","[1104](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1104)","[1353](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1353)","[1380](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1380)","[1446](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1446)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n39: keccak256(\n\n43: keccak256(abi.encode(features)),\n```","loc":["[39](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L39)","[43](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L43)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n26: keccak256(\n```","loc":["[26](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L26)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n57: (uint64(uint256(keccak256(abi.encodePacked(token0, token1, fee)))) >> 32);\n```","loc":["[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L57)"]}]},{"severity":"Gas","title":"Use assembly to emit events","description":"To efficiently emit events, it's possible to utilize assembly by making use of scratch space and the free memory pointer. This approach has the advantage of potentially avoiding the costs associated with memory expansion.\n\nHowever, it's important to note that in order to safely optimize this process, it is preferable to cache and restore the free memory pointer.\n\nA good example of such practice can be seen in [Solady's](https://github.com/Vectorized/solady/blob/main/src/tokens/ERC1155.sol#L167) codebase.","gasSavings":304,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n386: emit PoolInitialized(univ3pool);\n\n490: emit TokenizedPositionBurnt(msg.sender, tokenId, positionSize);\n\n523: emit TokenizedPositionMinted(msg.sender, tokenId, positionSize);\n```","loc":["[386](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L386)","[490](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L490)","[523](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L523)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n80: emit ApprovalForAll(msg.sender, operator, approved);\n\n108: emit TransferSingle(msg.sender, from, to, id, amount);\n\n161: emit TransferBatch(msg.sender, from, to, ids, amounts);\n\n220: emit TransferSingle(msg.sender, address(0), to, id, amount);\n\n239: emit TransferSingle(msg.sender, from, address(0), id, amount);\n```","loc":["[80](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L80)","[108](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L108)","[161](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L161)","[220](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L220)","[239](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L239)"]}]},{"severity":"Gas","title":"Use assembly to validate `msg.sender`","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n97: if (!(msg.sender == from || isApprovedForAll[from][msg.sender])) revert NotAuthorized();\n\n135: if (!(msg.sender == from || isApprovedForAll[from][msg.sender])) revert NotAuthorized();\n```","loc":["[97](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L97)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L135)"]}]},{"severity":"Gas","title":"Use assembly to write address/contract type storage values","description":"Using `assembly { sstore(state.slot, addr)` instead of `state = addr` can save gas.","gasSavings":50,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n346: /// @notice Initialize a Uniswap v3 pool in the SemifungiblePositionManager contract\n```","loc":["[346](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L346)"]}]},{"severity":"Gas","title":"Using a double `if` statement instead of a logical AND (`&&`)","description":"Using a double `if` statement instead of a logical AND (`&&`) can provide similar short-circuiting behavior whereas double if is slightly [more gas efficient](https://gist.github.com/DadeKuma/931ce6794a050201ec6544dbcc31316c).","gasSavings":120,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n706: if ((itmAmounts != 0) && (swapAtMint)) {\n\n774: if ((itm0 != 0) && (itm1 != 0)) {\n```","loc":["[706](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L706)","[774](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L774)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n512: if ((isLong == isLongP) && (tokenType == tokenTypeP))\n\n517: if ((isLong != isLongP) && (tokenType != tokenTypeP))\n```","loc":["[512](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L512)","[517](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L517)"]}]},{"severity":"Gas","title":"Use a more recent version of solidity","description":"- Use a solidity version of at least 0.8.2 to get simple compiler automatic inlining.\n- Use a solidity version of at least 0.8.3 to get better struct packing and cheaper multiple storage reads.\n- Use a solidity version of at least 0.8.4 to get custom errors, which are cheaper at deployment than revert()/require() strings.\n- Use a solidity version of at least 0.8.10 to have external calls skip contract existence checks if the external call has a return value.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n2: pragma solidity =0.8.18;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Errors.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Errors.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L2)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L2)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n2: pragma solidity =0.8.18;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L2)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L2)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n2: pragma solidity ^0.8.0;\n```","loc":["[2](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L2)"]}]},{"severity":"Gas","title":"Use `uint256(1)`/`uint256(2)` instead of `true`/`false` to save gas for changes","description":"Avoids a Gsset (20000 gas) when changing from false to true, after having been true in the past. Since most of the bools aren't changed twice in one transaction, I've counted the amount of gas as half of the full amount, for each variable.","gasSavings":25650,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n127: bool internal constant MINT = false;\n\n128: bool internal constant BURN = true;\n```","loc":["[127](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L127)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L128)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n67: mapping(address owner => mapping(address operator => bool approvedForAll))\n```","loc":["[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L67)"]}]},{"severity":"Gas","title":"Use `unchecked` block for safe subtractions","description":"If it can be confirmed that the subtraction operation will not overflow, using an unchecked block can save gas. For example, `require(x <= y); z = y - x;` can be optimized to `require(x <= y); unchecked { z = y - x; }`","gasSavings":255,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n/// @audit this subtraction is checked on line 584\n878: }\n\n/// @audit this subtraction is checked on line 986\n994: }\n```","loc":["[878](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L878)","[994](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L994)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n/// @audit this subtraction is checked on line 391\n391: (legLowerTick, legUpperTick) = (selfStrike - oneSidedRange, selfStrike + oneSidedRange);\n```","loc":["[391](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L391)"]}]},{"severity":"Gas","title":"Using bitmap to store bool states can save gas","description":"Using a bitmap instead of a bool array or a bool mapping to store boolean states can save gas fees. This is because the bitmap can store 256 boolean values in a single slot instead of 256 slots, which can save gas when writing bool values or when reading multiple bool values from the same slot.","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n67: mapping(address owner => mapping(address operator => bool approvedForAll))\n```","loc":["[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L67)"]}]},{"severity":"Gas","title":"Using `constant`s directly, rather than caching the value, saves gas","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n/// @audit `OPTION_RATIO_MASK`\n332: uint256 optionRatios = self & OPTION_RATIO_MASK;\n\n/// @audit `OPTION_RATIO_MASK`\n412: uint256 optionRatios = self & OPTION_RATIO_MASK;\n```","loc":["[332](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L332)","[412](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L412)"]}]},{"severity":"Gas","title":"Using `this` to access functions results in an external call, wasting gas","description":"External calls have an overhead of 100 gas, which can be avoided by not referencing the function using `this`. Contracts are allowed to override their parents' functions and change the visibility from `external` to `public`, so make this change if it's required in order to call the function internally.","gasSavings":100,"category":null,"instances":[{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n15: (bool success, bytes memory result) = address(this).delegatecall(data[i]);\n```","loc":["[15](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L15)"]}]},{"severity":"Gas","title":"Using bools for storage incurs overhead","description":"Use uint256(1) and uint256(2) for true/false to avoid a Gwarmaccess (100 gas), and to avoid Gsset (20000 gas) when changing from ‘false’ to ‘true’, after having been ‘true’ in the past. See [source](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/58f635312aa21f947cae5f8578638a85aa2519f5/contracts/security/ReentrancyGuard.sol#L23-L27).","gasSavings":300,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n127: bool internal constant MINT = false;\n\n128: bool internal constant BURN = true;\n```","loc":["[127](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L127)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L128)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n67: mapping(address owner => mapping(address operator => bool approvedForAll))\n```","loc":["[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L67)"]}]},{"severity":"Gas","title":"Cache array length outside of loop","description":"If not cached, the solidity compiler will always read the length of the array during each iteration. That is, if it is a storage array, this is an extra sload operation (100 additional extra gas for each iteration except for the first) and if it is a memory array, this is an extra mload operation (3 additional gas for each iteration except for the first).","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n550: for (uint256 i = 0; i < ids.length; ) {\n```","loc":["[550](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L550)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n14: for (uint256 i = 0; i < data.length; ) {\n```","loc":["[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L14)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n141: for (uint256 i = 0; i < ids.length; ) {\n\n187: for (uint256 i = 0; i < owners.length; ++i) {\n```","loc":["[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L141)","[187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L187)"]}]},{"severity":"Gas","title":"Don't initialize variables with default value","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n550: for (uint256 i = 0; i < ids.length; ) {\n\n583: for (uint256 leg = 0; leg < numLegs; ) {\n\n860: for (uint256 leg = 0; leg < numLegs; ) {\n```","loc":["[550](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L550)","[583](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L583)","[860](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L860)"]},{"content":"```solidity\nFile: contracts/multicall/Multicall.sol\n\n14: for (uint256 i = 0; i < data.length; ) {\n```","loc":["[14](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/multicall/Multicall.sol#L14)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n141: for (uint256 i = 0; i < ids.length; ) {\n\n187: for (uint256 i = 0; i < owners.length; ++i) {\n```","loc":["[141](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L141)","[187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L187)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n468: for (uint256 i = 0; i < 4; ++i) {\n```","loc":["[468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L468)"]}]},{"severity":"Gas","title":"Usage of `int`s/`uint`s smaller than 32 bytes incurs overhead","description":"Using `int`s/`uint`s smaller than 32 bytes may cost more gas. This is because the EVM operates on 32 bytes at a time, so if an element is smaller than 32 bytes, the EVM must perform more operations to reduce the size of the element from 32 bytes to the desired size.","gasSavings":7645,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n89: uint128 positionSize\n\n100: uint128 positionSize\n\n135: uint128 private constant VEGOID = 2;\n\n152: mapping(uint64 poolId => PoolAddressAndLock contextData) internal s_poolContext;\n\n306: modifier ReentrancyLock(uint64 poolId) {\n\n321: function beginReentrancyLock(uint64 poolId) internal {\n\n331: function endReentrancyLock(uint64 poolId) internal {\n\n368: uint64 poolId = PanopticMath.getPoolId(univ3pool);\n\n478: uint128 positionSize,\n\n512: uint128 positionSize,\n\n589: uint128(amount),\n\n665: uint128 positionSize,\n\n756: int128 itm0 = itmAmounts.rightSlot();\n\n757: int128 itm1 = itmAmounts.leftSlot();\n\n775: (uint160 sqrtPriceX96, , , , , , ) = _univ3pool.slot0();\n\n851: uint128 positionSize,\n\n870: uint128 _positionSize = positionSize;\n\n917: if (amount0 > uint128(type(int128).max) || amount1 > uint128(type(int128).max))\n\n917: if (amount0 > uint128(type(int128).max) || amount1 > uint128(type(int128).max))\n\n917: if (amount0 > uint128(type(int128).max) || amount1 > uint128(type(int128).max))\n\n917: if (amount0 > uint128(type(int128).max) || amount1 > uint128(type(int128).max))\n\n957: uint128 updatedLiquidity;\n\n967: uint128 startingLiquidity = currentLiquidity.rightSlot();\n\n968: uint128 removedLiquidity = currentLiquidity.leftSlot();\n\n969: uint128 chunkLiquidity = _liquidityChunk.liquidity();\n\n1095: uint128 liquidity,\n\n1120: .toRightSlot(int128(int256(Math.mulDiv128(feeGrowthInside0LastX128, liquidity))))\n\n1121: .toLeftSlot(int128(int256(Math.mulDiv128(feeGrowthInside1LastX128, liquidity))));\n\n1159: movedAmounts = int256(0).toRightSlot(int128(int256(amount0))).toLeftSlot(\n\n1160: int128(int256(amount1))\n\n1186: movedAmounts = int256(0).toRightSlot(-int128(int256(amount0))).toLeftSlot(\n\n1187: -int128(int256(amount1))\n\n1208: uint128 startingLiquidity = currentLiquidity.rightSlot();\n\n1222: (uint128 receivedAmount0, uint128 receivedAmount1) = univ3pool.collect(\n\n1222: (uint128 receivedAmount0, uint128 receivedAmount1) = univ3pool.collect(\n\n1226: uint128(amountToCollect.rightSlot()),\n\n1227: uint128(amountToCollect.leftSlot())\n\n1231: uint128 collected0;\n\n1232: uint128 collected1;\n\n1235: ? receivedAmount0 - uint128(-movedInLeg.rightSlot())\n\n1238: ? receivedAmount1 - uint128(-movedInLeg.leftSlot())\n\n1272: uint128 premium0X64_base;\n\n1273: uint128 premium1X64_base;\n\n1276: uint128 collected0 = uint128(collectedAmounts.rightSlot());\n\n1276: uint128 collected0 = uint128(collectedAmounts.rightSlot());\n\n1277: uint128 collected1 = uint128(collectedAmounts.leftSlot());\n\n1277: uint128 collected1 = uint128(collectedAmounts.leftSlot());\n\n1282: .toUint128();\n\n1285: .toUint128();\n\n1289: uint128 premium0X64_owed;\n\n1290: uint128 premium1X64_owed;\n\n1297: .toUint128();\n\n1300: .toUint128();\n\n1309: uint128 premium0X64_gross;\n\n1310: uint128 premium1X64_gross;\n\n1319: .toUint128();\n\n1322: .toUint128();\n\n1379: ) external view returns (uint128 premiumToken0, uint128 premiumToken1) {\n\n1379: ) external view returns (uint128 premiumToken0, uint128 premiumToken1) {\n\n1393: uint128 netLiquidity = accountLiquidities.rightSlot();\n\n1443: ) external view returns (int128 feesBase0, int128 feesBase1) {\n\n1443: ) external view returns (int128 feesBase0, int128 feesBase1) {\n\n1458: uint64 poolId\n\n1468: function getPoolId(address univ3pool) external view returns (uint64 poolId) {\n\n1469: poolId = uint64(s_AddrToPoolIdData[univ3pool]);\n```","loc":["[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L89)","[100](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L100)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L135)","[152](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L152)","[306](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L306)","[321](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L321)","[331](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L331)","[368](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L368)","[478](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L478)","[512](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L512)","[589](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L589)","[665](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L665)","[756](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L756)","[757](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L757)","[775](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L775)","[851](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L851)","[870](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L870)","[917](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L917)","[917](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L917)","[917](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L917)","[917](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L917)","[957](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L957)","[967](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L967)","[968](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L968)","[969](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L969)","[1095](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1095)","[1120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1120)","[1121](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1121)","[1159](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1159)","[1160](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1160)","[1186](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1186)","[1187](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1187)","[1208](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1208)","[1222](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1222)","[1222](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1222)","[1226](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1226)","[1227](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1227)","[1231](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1231)","[1232](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1232)","[1235](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1235)","[1238](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1238)","[1272](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1272)","[1273](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1273)","[1276](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1276)","[1276](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1276)","[1277](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1277)","[1277](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1277)","[1282](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1282)","[1285](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1285)","[1289](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1289)","[1290](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1290)","[1297](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1297)","[1300](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1300)","[1309](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1309)","[1310](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1310)","[1319](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1319)","[1322](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1322)","[1379](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1379)","[1379](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1379)","[1393](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1393)","[1443](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1443)","[1443](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1443)","[1458](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1458)","[1468](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1468)","[1469](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1469)"]},{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n37: uint160(\n```","loc":["[37](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L37)"]},{"content":"```solidity\nFile: contracts/libraries/Constants.sol\n\n17: uint160 internal constant MIN_V3POOL_SQRT_RATIO = 4295128739;\n\n20: uint160 internal constant MAX_V3POOL_SQRT_RATIO =\n```","loc":["[17](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L17)","[20](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Constants.sol#L20)"]},{"content":"```solidity\nFile: contracts/libraries/FeesCalc.sol\n\n57: uint128 startingLiquidity,\n\n76: .toRightSlot(int128(int256(Math.mulDiv128(ammFeesPerLiqToken0X128, startingLiquidity))))\n\n77: .toLeftSlot(int128(int256(Math.mulDiv128(ammFeesPerLiqToken1X128, startingLiquidity))));\n```","loc":["[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L57)","[76](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L76)","[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/FeesCalc.sol#L77)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n38: function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\n\n89: sqrtPriceX96 = uint160((sqrtR >> 32) + (sqrtR % (1 << 32) == 0 ? 0 : 1));\n\n104: uint160 lowPriceX96 = getSqrtRatioAtTick(liquidityChunk.tickLower());\n\n105: uint160 highPriceX96 = getSqrtRatioAtTick(liquidityChunk.tickUpper());\n\n122: uint160 lowPriceX96 = getSqrtRatioAtTick(liquidityChunk.tickLower());\n\n123: uint160 highPriceX96 = getSqrtRatioAtTick(liquidityChunk.tickUpper());\n\n138: ) internal pure returns (uint128 liquidity) {\n\n139: uint160 lowPriceX96 = getSqrtRatioAtTick(liquidityChunk.tickLower());\n\n140: uint160 highPriceX96 = getSqrtRatioAtTick(liquidityChunk.tickUpper());\n\n144: toUint128(\n\n157: ) internal pure returns (uint128 liquidity) {\n\n158: uint160 lowPriceX96 = getSqrtRatioAtTick(liquidityChunk.tickLower());\n\n159: uint160 highPriceX96 = getSqrtRatioAtTick(liquidityChunk.tickUpper());\n\n161: return toUint128(mulDiv(amount1, Constants.FP96, highPriceX96 - lowPriceX96));\n\n172: function toUint128(uint256 toDowncast) internal pure returns (uint128 downcastedInt) {\n\n172: function toUint128(uint256 toDowncast) internal pure returns (uint128 downcastedInt) {\n\n173: if ((downcastedInt = uint128(toDowncast)) != toDowncast) revert Errors.CastingError();\n```","loc":["[38](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L38)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L89)","[104](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L104)","[105](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L105)","[122](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L122)","[123](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L123)","[138](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L138)","[139](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L139)","[140](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L140)","[144](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L144)","[157](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L157)","[158](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L158)","[159](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L159)","[161](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L161)","[172](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L172)","[172](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L172)","[173](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L173)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n38: function getPoolId(address univ3pool) internal pure returns (uint64) {\n\n39: return uint64(uint160(univ3pool) >> 96);\n\n39: return uint64(uint160(univ3pool) >> 96);\n\n49: uint64 basePoolId,\n\n53: ) internal pure returns (uint64) {\n\n57: (uint64(uint256(keccak256(abi.encodePacked(token0, token1, fee)))) >> 32);\n\n85: uint128 positionSize,\n\n118: uint128 legLiquidity;\n\n145: function convert0to1(int256 amount, uint160 sqrtPriceX96) internal pure returns (int256) {\n\n168: function convert1to0(int256 amount, uint160 sqrtPriceX96) internal pure returns (int256) {\n```","loc":["[38](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L38)","[39](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L39)","[39](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L39)","[49](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L49)","[53](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L53)","[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L57)","[85](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L85)","[118](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L118)","[145](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L145)","[168](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L168)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n25: function rightSlot(uint256 self) internal pure returns (uint128) {\n\n26: return uint128(self);\n\n32: function rightSlot(int256 self) internal pure returns (int128) {\n\n33: return int128(self);\n\n44: function toRightSlot(uint256 self, uint128 right) internal pure returns (uint256) {\n\n54: function toRightSlot(uint256 self, int128 right) internal pure returns (uint256) {\n\n65: function toRightSlot(int256 self, uint128 right) internal pure returns (int256) {\n\n75: function toRightSlot(int256 self, int128 right) internal pure returns (int256) {\n\n89: function leftSlot(uint256 self) internal pure returns (uint128) {\n\n90: return uint128(self >> 128);\n\n96: function leftSlot(int256 self) internal pure returns (int128) {\n\n97: return int128(self >> 128);\n\n108: function toLeftSlot(uint256 self, uint128 left) internal pure returns (uint256) {\n\n118: function toLeftSlot(int256 self, uint128 left) internal pure returns (int256) {\n\n120: return self + (int256(int128(left)) << 128);\n\n128: function toLeftSlot(int256 self, int128 left) internal pure returns (int256) {\n\n151: if (z < x || (uint128(z) < uint128(x))) revert Errors.UnderOverFlow();\n\n151: if (z < x || (uint128(z) < uint128(x))) revert Errors.UnderOverFlow();\n\n162: int128 left128 = int128(left256);\n\n162: int128 left128 = int128(left256);\n\n165: int128 right128 = int128(right256);\n\n165: int128 right128 = int128(right256);\n\n180: int128 left128 = int128(left256);\n\n180: int128 left128 = int128(left256);\n\n183: int128 right128 = int128(right256);\n\n183: int128 right128 = int128(right256);\n\n198: function toInt128(int256 self) internal pure returns (int128 selfAsInt128) {\n\n199: if (!((selfAsInt128 = int128(self)) == self)) revert Errors.CastingError();\n\n205: function toUint128(uint256 self) internal pure returns (uint128 selfAsUint128) {\n\n205: function toUint128(uint256 self) internal pure returns (uint128 selfAsUint128) {\n\n205: function toUint128(uint256 self) internal pure returns (uint128 selfAsUint128) {\n\n206: if (!((selfAsUint128 = uint128(self)) == self)) revert Errors.CastingError();\n\n206: if (!((selfAsUint128 = uint128(self)) == self)) revert Errors.CastingError();\n```","loc":["[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L25)","[26](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L26)","[32](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L32)","[33](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L33)","[44](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L44)","[54](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L54)","[65](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L65)","[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L75)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L89)","[90](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L90)","[96](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L96)","[97](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L97)","[108](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L108)","[118](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L118)","[120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L120)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L128)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L151)","[151](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L151)","[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L162)","[162](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L162)","[165](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L165)","[165](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L165)","[180](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L180)","[180](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L180)","[183](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L183)","[183](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L183)","[198](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L198)","[199](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L199)","[205](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L205)","[205](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L205)","[205](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L205)","[206](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L206)","[206](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L206)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n67: uint128 amount\n\n78: function addLiquidity(uint256 self, uint128 amount) internal pure returns (uint256) {\n\n130: function liquidity(uint256 self) internal pure returns (uint128) {\n\n132: return uint128(self);\n```","loc":["[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L67)","[78](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L78)","[130](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L130)","[132](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L132)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n80: function univ3pool(uint256 self) internal pure returns (uint64) {\n\n82: return uint64(self);\n\n173: function addUniv3pool(uint256 self, uint64 _poolId) internal pure returns (uint256) {\n\n463: function validate(uint256 self) internal pure returns (uint64) {\n```","loc":["[80](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L80)","[82](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L82)","[173](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L173)","[463](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L463)"]}]},{"severity":"Gas","title":"Constructors can be marked as `payable` to save deployment gas","description":"Payable functions cost less gas to execute, because the compiler does not have to add extra checks to ensure that no payment is provided. A constructor can be safely marked as payable, because only the deployer would be able to pass funds, and the project itself would not pass any funds.","gasSavings":21,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n342: constructor(IUniswapV3Factory _factory) {\n```","loc":["[342](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L342)"]}]},{"severity":"Gas","title":"Use shift Right/Left instead of division/multiplication if possible","description":"\n","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n1316: ((removedLiquidity ** 2) / 2 ** (VEGOID));\n```","loc":["[1316](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1316)"]}]},{"severity":"Gas","title":"Using assembly to check for zero can save gas","description":"Using assembly to check for zero can save gas by allowing more direct access to the evm and reducing some of the overhead associated with high-level operations in solidity.","gasSavings":318,"category":null,"instances":[{"content":"```solidity\nFile: contracts/SemiFungiblePositionManager.sol\n\n356: if (address(univ3pool) == address(0)) revert Errors.UniswapPoolNotInitialized();\n\n363: if (s_AddrToPoolIdData[univ3pool] != 0) return;\n\n370: while (address(s_poolContext[poolId].pool) != address(0)) {\n\n615: (s_accountLiquidity[positionKey_to] != 0) ||\n\n616: (s_accountFeesBase[positionKey_to] != 0)\n\n671: if (positionSize == 0) revert Errors.OptionsBalanceZero();\n\n707: totalMoved = swapInAMM(univ3pool, itmAmounts).add(totalMoved);\n\n775: (uint160 sqrtPriceX96, , , , , , ) = _univ3pool.slot0();\n\n775: (uint160 sqrtPriceX96, , , , , , ) = _univ3pool.slot0();\n\n811: zeroForOne = itm0 < 0;\n\n822: // swap tokens in the Uniswap pool\n\n972: // selling/short: so move from msg.sender *to* uniswap\n\n1032: ? _mintLiquidity(_liquidityChunk, _univ3pool)\n\n1044: // Add this in-the-money amount transacted.\n\n1218: // first collect amounts from Uniswap corresponding to this position\n\n1395: int256 amountToCollect;\n```","loc":["[356](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L356)","[363](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L363)","[370](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L370)","[615](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L615)","[616](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L616)","[671](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L671)","[707](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L707)","[775](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L775)","[775](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L775)","[811](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L811)","[822](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L822)","[972](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L972)","[1032](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1032)","[1044](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1044)","[1218](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1218)","[1395](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/SemiFungiblePositionManager.sol#L1395)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n43: uint256 sqrtR = absTick & 0x1 != 0\n\n47: if (absTick & 0x2 != 0) sqrtR = (sqrtR * 0xfff97272373d413259a46990580e213a) >> 128;\n\n49: if (absTick & 0x4 != 0) sqrtR = (sqrtR * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n\n51: if (absTick & 0x8 != 0) sqrtR = (sqrtR * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n\n53: if (absTick & 0x10 != 0) sqrtR = (sqrtR * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n\n55: if (absTick & 0x20 != 0) sqrtR = (sqrtR * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n\n57: if (absTick & 0x40 != 0) sqrtR = (sqrtR * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n\n59: if (absTick & 0x80 != 0) sqrtR = (sqrtR * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n\n61: if (absTick & 0x100 != 0) sqrtR = (sqrtR * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n\n63: if (absTick & 0x200 != 0) sqrtR = (sqrtR * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n\n65: if (absTick & 0x400 != 0) sqrtR = (sqrtR * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n\n67: if (absTick & 0x800 != 0) sqrtR = (sqrtR * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n\n69: if (absTick & 0x1000 != 0) sqrtR = (sqrtR * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n\n71: if (absTick & 0x2000 != 0) sqrtR = (sqrtR * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n\n73: if (absTick & 0x4000 != 0) sqrtR = (sqrtR * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n\n75: if (absTick & 0x8000 != 0) sqrtR = (sqrtR * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n\n77: if (absTick & 0x10000 != 0) sqrtR = (sqrtR * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n\n79: if (absTick & 0x20000 != 0) sqrtR = (sqrtR * 0x5d6af8dedb81196699c329225ee604) >> 128;\n\n81: if (absTick & 0x40000 != 0) sqrtR = (sqrtR * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n\n83: if (absTick & 0x80000 != 0) sqrtR = (sqrtR * 0x48a170391f7dc42444e8fa2) >> 128;\n\n89: sqrtPriceX96 = uint160((sqrtR >> 32) + (sqrtR % (1 << 32) == 0 ? 0 : 1));\n\n206: if (prod1 == 0) {\n\n302: if (prod1 == 0) {\n\n364: if (prod1 == 0) {\n\n426: if (prod1 == 0) {\n\n488: if (prod1 == 0) {\n```","loc":["[43](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L43)","[47](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L47)","[49](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L49)","[51](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L51)","[53](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L53)","[55](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L55)","[57](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L57)","[59](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L59)","[61](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L61)","[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L63)","[65](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L65)","[67](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L67)","[69](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L69)","[71](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L71)","[73](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L73)","[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L75)","[77](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L77)","[79](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L79)","[81](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L81)","[83](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L83)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L89)","[206](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L206)","[302](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L302)","[364](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L364)","[426](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L426)","[488](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L488)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n120: if (tokenId.asset(legIndex) == 0) {\n```","loc":["[120](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L120)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n110: if (to.code.length != 0) {\n\n163: if (to.code.length != 0) {\n\n222: if (to.code.length != 0) {\n```","loc":["[110](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L110)","[163](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L163)","[222](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L222)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n397: legLowerTick % tickSpacing != 0 ||\n\n398: legUpperTick % tickSpacing != 0 ||\n\n443: if (i == 0)\n\n464: if (self.optionRatio(0) == 0) revert Errors.InvalidTokenIdParameter(1);\n\n469: if (self.optionRatio(i) == 0) {\n\n473: if ((self >> (64 + 48 * i)) != 0) revert Errors.InvalidTokenIdParameter(1);\n\n480: if ((self.width(i) == 0)) revert Errors.InvalidTokenIdParameter(5);\n```","loc":["[397](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L397)","[398](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L398)","[443](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L443)","[464](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L464)","[469](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L469)","[473](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L473)","[480](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L480)"]}]},{"severity":"Gas","title":"`internal` functions not called by the contract should be removed","description":"If the functions are required by an interface, the contract should inherit from that interface and use the `override` keyword","gasSavings":null,"category":null,"instances":[{"content":"```solidity\nFile: contracts/libraries/CallbackLib.sol\n\n28: function validateCallback(\n```","loc":["[28](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/CallbackLib.sol#L28)"]},{"content":"```solidity\nFile: contracts/libraries/Math.sol\n\n23: function absUint(int256 x) internal pure returns (uint256) {\n\n101: function getAmount0ForLiquidity(\n\n119: function getAmount1ForLiquidity(\n\n135: function getLiquidityForAmount0(\n\n154: function getLiquidityForAmount1(\n\n286: function mulDiv64(uint256 a, uint256 b) internal pure returns (uint256 result) {\n\n410: function mulDiv128(uint256 a, uint256 b) internal pure returns (uint256 result) {\n\n472: function mulDiv192(uint256 a, uint256 b) internal pure returns (uint256 result) {\n```","loc":["[23](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L23)","[101](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L101)","[119](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L119)","[135](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L135)","[154](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L154)","[286](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L286)","[410](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L410)","[472](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/Math.sol#L472)"]},{"content":"```solidity\nFile: contracts/libraries/PanopticMath.sol\n\n38: function getPoolId(address univ3pool) internal pure returns (uint64) {\n\n48: function getFinalPoolId(\n\n82: function getLiquidityChunk(\n\n145: function convert0to1(int256 amount, uint160 sqrtPriceX96) internal pure returns (int256) {\n\n168: function convert1to0(int256 amount, uint160 sqrtPriceX96) internal pure returns (int256) {\n```","loc":["[38](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L38)","[48](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L48)","[82](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L82)","[145](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L145)","[168](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/PanopticMath.sol#L168)"]},{"content":"```solidity\nFile: contracts/libraries/SafeTransferLib.sol\n\n16: function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n```","loc":["[16](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/libraries/SafeTransferLib.sol#L16)"]},{"content":"```solidity\nFile: contracts/tokens/ERC1155Minimal.sol\n\n214: function _mint(address to, uint256 id, uint256 amount) internal {\n\n236: function _burn(address from, uint256 id, uint256 amount) internal {\n```","loc":["[214](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L214)","[236](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/tokens/ERC1155Minimal.sol#L236)"]},{"content":"```solidity\nFile: contracts/types/LeftRight.sol\n\n25: function rightSlot(uint256 self) internal pure returns (uint128) {\n\n32: function rightSlot(int256 self) internal pure returns (int128) {\n\n44: function toRightSlot(uint256 self, uint128 right) internal pure returns (uint256) {\n\n54: function toRightSlot(uint256 self, int128 right) internal pure returns (uint256) {\n\n65: function toRightSlot(int256 self, uint128 right) internal pure returns (int256) {\n\n75: function toRightSlot(int256 self, int128 right) internal pure returns (int256) {\n\n89: function leftSlot(uint256 self) internal pure returns (uint128) {\n\n96: function leftSlot(int256 self) internal pure returns (int128) {\n\n108: function toLeftSlot(uint256 self, uint128 left) internal pure returns (uint256) {\n\n118: function toLeftSlot(int256 self, uint128 left) internal pure returns (int256) {\n\n128: function toLeftSlot(int256 self, int128 left) internal pure returns (int256) {\n\n142: function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n\n159: function add(int256 x, int256 y) internal pure returns (int256 z) {\n\n177: function sub(int256 x, int256 y) internal pure returns (int256 z) {\n\n198: function toInt128(int256 self) internal pure returns (int128 selfAsInt128) {\n\n205: function toUint128(uint256 self) internal pure returns (uint128 selfAsUint128) {\n\n212: function toInt256(uint256 self) internal pure returns (int256) {\n```","loc":["[25](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L25)","[32](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L32)","[44](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L44)","[54](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L54)","[65](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L65)","[75](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L75)","[89](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L89)","[96](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L96)","[108](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L108)","[118](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L118)","[128](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L128)","[142](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L142)","[159](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L159)","[177](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L177)","[198](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L198)","[205](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L205)","[212](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LeftRight.sol#L212)"]},{"content":"```solidity\nFile: contracts/types/LiquidityChunk.sol\n\n63: function createChunk(\n\n78: function addLiquidity(uint256 self, uint128 amount) internal pure returns (uint256) {\n\n88: function addTickLower(uint256 self, int24 _tickLower) internal pure returns (uint256) {\n\n98: function addTickUpper(uint256 self, int24 _tickUpper) internal pure returns (uint256) {\n\n112: function tickLower(uint256 self) internal pure returns (int24) {\n\n121: function tickUpper(uint256 self) internal pure returns (int24) {\n\n130: function liquidity(uint256 self) internal pure returns (uint128) {\n```","loc":["[63](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L63)","[78](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L78)","[88](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L88)","[98](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L98)","[112](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L112)","[121](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L121)","[130](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/LiquidityChunk.sol#L130)"]},{"content":"```solidity\nFile: contracts/types/TokenId.sol\n\n80: function univ3pool(uint256 self) internal pure returns (uint64) {\n\n93: function asset(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n103: function optionRatio(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n113: function isLong(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n123: function tokenType(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n139: function riskPartner(uint256 self, uint256 legIndex) internal pure returns (uint256) {\n\n149: function strike(uint256 self, uint256 legIndex) internal pure returns (int24) {\n\n160: function width(uint256 self, uint256 legIndex) internal pure returns (int24) {\n\n173: function addUniv3pool(uint256 self, uint64 _poolId) internal pure returns (uint256) {\n\n298: function addLeg(\n\n327: function flipToBurnToken(uint256 self) internal pure returns (uint256) {\n\n361: function countLongs(uint256 self) internal pure returns (uint256) {\n\n374: function asTicks(\n\n410: function countLegs(uint256 self) internal pure returns (uint256) {\n\n442: function clearLeg(uint256 self, uint256 i) internal pure returns (uint256) {\n\n463: function validate(uint256 self) internal pure returns (uint64) {\n```","loc":["[80](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L80)","[93](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L93)","[103](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L103)","[113](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L113)","[123](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L123)","[139](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L139)","[149](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L149)","[160](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L160)","[173](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L173)","[298](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L298)","[327](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L327)","[361](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L361)","[374](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L374)","[410](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L410)","[442](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L442)","[463](https://github.com/code-423n4/2023-11-panoptic/blob/2647928c33be4a58883110befd7fd065448478ef/contracts/types/TokenId.sol#L463)"]}]}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment