{
    "Function": "initializeAMMPool",
    "File": "contracts/SemiFungiblePositionManager.sol",
    "Parent Contracts": [
        "contracts/multicall/Multicall.sol",
        "contracts/tokens/ERC1155Minimal.sol"
    ],
    "High-Level Calls": [
        "IUniswapV3Factory",
        "PanopticMath",
        "PanopticMath"
    ],
    "Internal Calls": [
        "mstore(uint256,uint256)",
        "revert UniswapPoolNotInitialized()"
    ],
    "Library Calls": [
        "getFinalPoolId",
        "getPoolId"
    ],
    "Low-Level Calls": [],
    "Code": "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        address univ3pool = FACTORY.getPool(token0, token1, fee);\n\n        // reverts if the Uni v3 pool has not been initialized\n        if (address(univ3pool) == address(0)) revert Errors.UniswapPoolNotInitialized();\n\n        // return if the pool has already been initialized in SFPM\n        // @dev pools can be initialized from a Panoptic pool or by calling initializeAMMPool directly, reverting\n        // would prevent any PanopticPool from being deployed\n        // @dev some pools may not be deployable if the poolId has a collision (since we take only 8 bytes)\n        // if poolId == 0, we have a bit on the left set if it was initialized, so this will still return properly\n        if (s_AddrToPoolIdData[univ3pool] != 0) return;\n\n        // Set the base poolId as last 8 bytes of the address (the first 16 hex characters)\n        // @dev in the unlikely case that there is a collision between the first 8 bytes of two different Uni v3 pools\n        // @dev increase the poolId by a pseudo-random number\n        uint64 poolId = PanopticMath.getPoolId(univ3pool);\n\n        while (address(s_poolContext[poolId].pool) != address(0)) {\n            poolId = PanopticMath.getFinalPoolId(poolId, token0, token1, fee);\n        }\n        // store the poolId => UniswapV3Pool information in a mapping\n        // `locked` can be initialized to false because the pool address makes the slot nonzero\n        s_poolContext[poolId] = PoolAddressAndLock({\n            pool: IUniswapV3Pool(univ3pool),\n            locked: false\n        });\n\n        // store the UniswapV3Pool => poolId information in a mapping\n        // add a bit on the end to indicate that the pool is initialized\n        // (this is for the case that poolId == 0, so we can make a distinction between zero and uninitialized)\n        unchecked {\n            s_AddrToPoolIdData[univ3pool] = uint256(poolId) + 2 ** 255;\n        }\n        emit PoolInitialized(univ3pool);\n\n        return;\n\n        // this disables `memoryguard` when compiling this contract via IR\n        // it is classed as a potentially unsafe assembly block by the compiler, but is in fact safe\n        // we need this because enabling `memoryguard` and therefore StackLimitEvader increases the size of the contract significantly beyond the size limit\n        assembly {\n            mstore(0, 0xFA20F71C)\n        }\n    }"
}