File size: 159,134 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
  "language": "Solidity",
  "sources": {
    "contracts/src/LSSVMPairMissingEnumerableERC20.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {LSSVMPairERC20} from \"./LSSVMPairERC20.sol\";\nimport {LSSVMPairMissingEnumerable} from \"./LSSVMPairMissingEnumerable.sol\";\nimport {IRouter} from \"./IRouter.sol\";\n\ncontract LSSVMPairMissingEnumerableERC20 is\n    LSSVMPairMissingEnumerable,\n    LSSVMPairERC20\n{\n    function pairVariant() public pure override returns (IRouter.PairVariant) {\n        return IRouter.PairVariant.MISSING_ENUMERABLE_ERC20;\n    }\n}\n"
    },
    "contracts/src/IRouter.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {ERC20} from \"../lib/solmate/src/tokens/ERC20.sol\";\n\ninterface IRouter {\n    enum PairVariant {\n        ENUMERABLE_ETH,\n        MISSING_ENUMERABLE_ETH,\n        ENUMERABLE_ERC20,\n        MISSING_ENUMERABLE_ERC20,\n        MISSING_ENUMERABLE_ERC20_IN_SUDO\n    }\n\n    function pairTransferNFTFrom(\n        IERC721 nft,\n        address _rc,\n        address _ar,\n        uint256 ids,\n        PairVariant pairVariant\n    ) external;\n\n    function pairTransferERC20From(\n        ERC20 _token,\n        address routerCaller,\n        address _assetRecipient,\n        uint256 inputAmount,\n        PairVariant pairVariant\n    ) external;\n}\n"
    },
    "contracts/src/LSSVMPairMissingEnumerable.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {EnumerableSet} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport {LSSVMPair} from \"./LSSVMPair.sol\";\nimport {IERC1155} from \"@openzeppelin/contracts/token/ERC1155/IERC1155.sol\";\nimport {ERC20} from \"../lib/solmate/src/tokens/ERC20.sol\";\nimport {ILSSVMPairFactoryLike} from \"./ILSSVMPairFactoryLike.sol\";\nimport {LSSVMPairFactory} from \"./LSSVMPairFactory.sol\";\nimport {ICurve} from \"./bonding-curves/ICurve.sol\";\nimport {SafeTransferLib} from \"../lib/solmate/src/utils/SafeTransferLib.sol\";\n\n/**\n    @title An NFT/Token pair for an NFT that does not implement ERC721Enumerable\n    @author boredGenius and 0xmons\n */\nabstract contract LSSVMPairMissingEnumerable is LSSVMPair {\n    using SafeTransferLib for ERC20;\n\n    using EnumerableSet for EnumerableSet.UintSet;\n\n    // Used for internal ID tracking\n    EnumerableSet.UintSet private idSet;\n    bool public isSudoMirror;\n    address public sudoPoolAddress;\n\n    /// @inheritdoc LSSVMPair\n    function _sendAnyNFTsToRecipient(\n        IERC721 _nft,\n        address nftRecipient,\n        uint256 numNFTs\n    ) internal override {\n        // Send NFTs to recipient\n        // We're missing enumerable, so we also update the pair's own ID set\n        // NOTE: We start from last index to first index to save on gas\n        require(_nft == nft());\n        uint256 lastIndex = idSet.length() - 1;\n        for (uint256 i; i < numNFTs; ) {\n            uint256 nftId = idSet.at(lastIndex);\n            uint256[] memory nftIds;\n            nftIds[0] = nftId;\n            if (isSudoMirror) {\n                // TODO: move this out of the loop\n                LSSVMPairMissingEnumerable(sudoPoolAddress).withdrawERC721(_nft, nftIds);\n                _nft.safeTransferFrom(address(this), nftRecipient, nftId);\n            } else {\n                require(nft().ownerOf(nftIds[i]) == owner(), \"NFT not owned by pool owner\");\n                ILSSVMPairFactoryLike(address(factory())).requestNFTTransferFrom(_nft, owner(), nftRecipient, nftId);\n            }\n            \n            idSet.remove(nftId);\n            unchecked {\n                --lastIndex;\n                ++i;\n            }\n        }\n    }\n\n    /// @inheritdoc LSSVMPair\n    function _sendSpecificNFTsToRecipient(\n        IERC721 _nft,\n        address nftRecipient,\n        uint256[] calldata nftIds\n    ) internal override {\n        // Send NFTs to caller\n        // If missing enumerable, update pool's own ID set\n        require(_nft == nft());\n        if (isSudoMirror) LSSVMPairMissingEnumerable(sudoPoolAddress).withdrawERC721(_nft, nftIds);\n        uint256 numNFTs = nftIds.length;\n        for (uint256 i; i < numNFTs; ) {\n            require(idSet.contains(nftIds[i]), \"NFT not permitted!\");\n            if (isSudoMirror) {\n                _nft.safeTransferFrom(\n                    address(this),\n                    nftRecipient,\n                    nftIds[i]\n                );\n            } else {\n                require(nft().ownerOf(nftIds[i]) == owner(), \"NFT not owned by pool owner\");\n                ILSSVMPairFactoryLike(address(factory())).requestNFTTransferFrom(_nft, owner(), nftRecipient, nftIds[i]);\n            }\n            \n            // Remove from id set\n            idSet.remove(nftIds[i]);\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    function changeDelta(uint128 newDelta) external override onlyOwner {\n        ICurve _bondingCurve = bondingCurve();\n        require(\n            _bondingCurve.validateDelta(newDelta),\n            \"Invalid delta for curve\"\n        );\n        if (delta != newDelta) {\n            delta = newDelta;\n            emit DeltaUpdate(newDelta);\n        }\n        if (isSudoMirror) LSSVMPairMissingEnumerable(sudoPoolAddress).changeDelta(newDelta);\n    }\n\n    function changeSpotPrice(uint128 newSpotPrice) external override onlyOwner {\n        ICurve _bondingCurve = bondingCurve();\n        require(\n            _bondingCurve.validateSpotPrice(newSpotPrice),\n            \"Invalid new spot price for curve\"\n        );\n        if (spotPrice != newSpotPrice) {\n            spotPrice = newSpotPrice;\n            emit SpotPriceUpdate(newSpotPrice);\n        }\n        if (isSudoMirror) return LSSVMPairMissingEnumerable(sudoPoolAddress).changeSpotPrice(newSpotPrice);\n    }\n\n    /// @inheritdoc LSSVMPair\n    function getAllHeldIds() external view override returns (uint256[] memory) {\n        if (isSudoMirror) return LSSVMPairMissingEnumerable(sudoPoolAddress).getAllHeldIds();\n        uint256 numNFTs = idSet.length();\n        uint256[] memory ids = new uint256[](numNFTs);\n        uint256 y = 0;\n        for (uint256 i; i < numNFTs; ) {\n            if (\n                nft().isApprovedForAll(\n                    owner(),\n                    address(factory())\n                ) && nft().ownerOf(idSet.at(i)) == owner()\n            ) {\n                ids[y] = idSet.at(i);\n                unchecked {\n                    ++y;\n                }\n            }\n            unchecked {\n                ++i;\n            }\n        }\n        uint256[] memory idsCopy = new uint256[](y);\n        for (uint256 i; i < y; ) {\n            idsCopy[i] = ids[i];\n            unchecked {\n                ++i;\n            }\n        }\n        return idsCopy;\n    }\n\n    function addNFTToPool(uint256[] calldata ids) external nonReentrant {\n        for (uint256 i; i < ids.length; i++) {\n            // if(nft().isApprovedForAll(nftOwner, address(this)) && nftOwner == msg.sender) {\n            idSet.add(ids[i]);\n            if (isSudoMirror) {\n              ILSSVMPairFactoryLike(address(factory())).requestNFTTransferFrom(nft(), owner(), address(this), ids[i]);\n            }\n            \n            // emit event\n        }\n        if (isSudoMirror) {\n            ILSSVMPairFactoryLike(ILSSVMPairFactoryLike(address(factory())).sisterFactory()).depositNFTs(nft(), ids, sudoPoolAddress);\n        }\n    }\n\n    function removeNFTFromPool(uint256[] calldata ids) external onlyOwner {\n        if (isSudoMirror) LSSVMPairMissingEnumerable(sudoPoolAddress).withdrawERC721(nft(), ids);\n        for (uint256 i; i < ids.length; i++) {\n            // address nftOwner = nft().ownerOf(ids[i]);\n            // if (nftOwner == msg.sender) {\n            idSet.remove(ids[i]);\n            if (isSudoMirror) {\n              nft().safeTransferFrom(address(this), owner(), ids[i]);\n            }\n            // }\n            // emit event\n            emit NFTWithdrawal();\n        }\n    }\n\n    function createSudoPool(\n      address factoryAddress,\n        address payable _assetRecipient) external payable returns (address){\n          require(msg.sender == address(factory()));\n          require(sudoPoolAddress == address(0), \"Sudo Pool Already Initialized\");\n          uint256[] memory arr;\n          isSudoMirror = true;\n          sudoPoolAddress = address(ILSSVMPairFactoryLike(factoryAddress).createPairETH{value: msg.value}(address(nft()), address(bondingCurve()), _assetRecipient, uint8(poolType()), delta, fee, spotPrice, arr));\n          nft().setApprovalForAll(ILSSVMPairFactoryLike(address(factory())).sisterFactory(), true);\n        return sudoPoolAddress;\n    }\n\n    function onERC721Received(\n        address,\n        address,\n        uint256,\n        bytes memory\n    ) public virtual returns (bytes4) {\n        return this.onERC721Received.selector;\n    }\n\n    // function removeStaleNFTs() public {\n    //     uint256 numNFTs = idSet.length();\n    //     for (uint256 i; i < numNFTs; ) {\n    //         if (\n    //             !nft().isApprovedForAll(\n    //                 permissionedIds[idSet.at(i)],\n    //                 address(this)\n    //             ) || nft().ownerOf(idSet.at(i)) != permissionedIds[idSet.at(i)]\n    //         ) {\n    //             idSet.remove(idSet.at(i));\n    //             permissionedIds[idSet.at(i)] = address(0);\n    //         }\n    //     }\n    //     // emit event\n        \n    // }\n\n    /// @inheritdoc LSSVMPair\n    function withdrawERC721(IERC721 a, uint256[] calldata nftIds)\n        external\n        override\n        onlyOwner\n    {\n        IERC721 _nft = nft();\n        require(a != _nft);\n        uint256 numNFTs = nftIds.length;\n        \n        // If it's not the pair's NFT, just withdraw normally\n        if (a != _nft) {\n            for (uint256 i; i < numNFTs; ) {\n                a.safeTransferFrom(address(this), msg.sender, nftIds[i]);\n\n                unchecked {\n                    ++i;\n                }\n            }\n        }\n    }\n\n    function withdrawERC721Sudo(IERC721 a, uint256[] calldata nftIds)\n        external\n        onlyOwner\n    {\n        IERC721 _nft = nft();\n        require(a != _nft);\n        uint256 numNFTs = nftIds.length;\n        \n        // If it's not the pair's NFT, just withdraw normally\n        if (a != _nft) {\n            if (isSudoMirror) LSSVMPairMissingEnumerable(sudoPoolAddress).withdrawERC721(a, nftIds);\n            for (uint256 i; i < numNFTs; ) {\n                a.safeTransferFrom(address(this), msg.sender, nftIds[i]);\n\n                unchecked {\n                    ++i;\n                }\n            }\n        }\n    }\n\n    function token_() public pure returns (ERC20 _token) {\n        uint256 paramsLength = _immutableParamsLength();\n        assembly {\n            _token := shr(\n                0x60,\n                calldataload(add(sub(calldatasize(), paramsLength), 61))\n            )\n        }\n    }\n\n    /// @inheritdoc LSSVMPair\n    function withdrawERC20(ERC20 a, uint256 amount)\n        external\n        override\n        onlyOwner\n    {\n        a.safeTransfer(msg.sender, amount);\n\n        if (a == token_()) {\n            // emit event since it is the pair token\n            emit TokenWithdrawal(amount);\n        }\n    }\n\n    function withdrawERC20Sudo(ERC20 a, uint256 amount)\n        external\n        onlyOwner\n    {\n        if (isSudoMirror) LSSVMPairMissingEnumerable(sudoPoolAddress).withdrawERC20(a, amount);\n        a.safeTransfer(msg.sender, amount);\n\n        if (a == token_()) {\n            // emit event since it is the pair token\n            emit TokenWithdrawal(amount);\n        }\n    }\n\n    function withdrawERC1155(\n        IERC1155 a,\n        uint256[] calldata ids,\n        uint256[] calldata amounts\n    ) external override onlyOwner {\n      a.safeBatchTransferFrom(address(this), msg.sender, ids, amounts, \"\");\n    }\n\n    function withdrawERC1155Sudo(\n        IERC1155 a,\n        uint256[] calldata ids,\n        uint256[] calldata amounts\n    ) external onlyOwner {\n      if (isSudoMirror) LSSVMPairMissingEnumerable(sudoPoolAddress).withdrawERC1155(a, ids, amounts);\n        a.safeBatchTransferFrom(address(this), msg.sender, ids, amounts, \"\");\n    }\n}\n"
    },
    "contracts/src/LSSVMPairERC20.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {SafeTransferLib} from \"../lib/solmate/src/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"../lib/solmate/src/tokens/ERC20.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {LSSVMPair} from \"./LSSVMPair.sol\";\nimport {ILSSVMPairFactoryLike} from \"./ILSSVMPairFactoryLike.sol\";\nimport {IRouter} from \"./IRouter.sol\";\nimport {ICurve} from \"./bonding-curves/ICurve.sol\";\nimport {CurveErrorCodes} from \"./bonding-curves/CurveErrorCodes.sol\";\n\n/**\n    @title An NFT/Token pair where the token is an ERC20\n    @author boredGenius and 0xmons\n */\nabstract contract LSSVMPairERC20 is LSSVMPair {\n    using SafeTransferLib for ERC20;\n\n    uint256 internal constant IMMUTABLE_PARAMS_LENGTH = 81;\n\n    /**\n        @notice Returns the ERC20 token associated with the pair\n        @dev See LSSVMPairCloner for an explanation on how this works\n     */\n    function token() public pure returns (ERC20 _token) {\n        uint256 paramsLength = _immutableParamsLength();\n        assembly {\n            _token := shr(\n                0x60,\n                calldataload(add(sub(calldatasize(), paramsLength), 61))\n            )\n        }\n    }\n\n    /// @inheritdoc LSSVMPair\n    function _pullTokenInputAndPayProtocolFee(\n        uint256 inputAmount,\n        bool isRouter,\n        address routerCaller,\n        ILSSVMPairFactoryLike _factory,\n        uint256 protocolFee\n    ) internal override {\n        require(msg.value == 0, \"ERC20 pair\");\n\n        ERC20 _token = token();\n        address _assetRecipient = getAssetRecipient();\n\n        if (isRouter) {\n            // Verify if router is allowed\n            IRouter router = IRouter(payable(msg.sender));\n\n            // Locally scoped to avoid stack too deep\n            {\n                (bool routerAllowed, ) = _factory.routerStatus(router);\n                require(routerAllowed, \"Not router\");\n            }\n\n            // Cache state and then call router to transfer tokens from user\n            uint256 beforeBalance = _token.balanceOf(_assetRecipient);\n            router.pairTransferERC20From(\n                _token,\n                routerCaller,\n                _assetRecipient,\n                inputAmount - protocolFee,\n                pairVariant()\n            );\n\n            // Verify token transfer (protect pair against malicious router)\n            require(\n                _token.balanceOf(_assetRecipient) - beforeBalance ==\n                    inputAmount - protocolFee,\n                \"ERC20 not transferred in\"\n            );\n\n            router.pairTransferERC20From(\n                _token,\n                routerCaller,\n                address(_factory),\n                protocolFee,\n                pairVariant()\n            );\n\n            // Note: no check for factory balance's because router is assumed to be set by factory owner\n            // so there is no incentive to *not* pay protocol fee\n        } else {\n            // Transfer tokens directly\n            _token.safeTransferFrom(\n                msg.sender,\n                _assetRecipient,\n                inputAmount - protocolFee\n            );\n\n            // Take protocol fee (if it exists)\n            if (protocolFee > 0) {\n                _token.safeTransferFrom(\n                    msg.sender,\n                    address(_factory),\n                    protocolFee\n                );\n            }\n        }\n    }\n\n    /// @inheritdoc LSSVMPair\n    function _refundTokenToSender(uint256 inputAmount) internal override {\n        // Do nothing since we transferred the exact input amount\n    }\n\n    /// @inheritdoc LSSVMPair\n    function _payProtocolFeeFromPair(\n        ILSSVMPairFactoryLike _factory,\n        uint256 protocolFee\n    ) internal override {\n        // Take protocol fee (if it exists)\n        if (protocolFee > 0) {\n            ERC20 _token = token();\n\n            // Round down to the actual token balance if there are numerical stability issues with the bonding curve calculations\n            uint256 pairTokenBalance = _token.balanceOf(address(this));\n            if (protocolFee > pairTokenBalance) {\n                protocolFee = pairTokenBalance;\n            }\n            if (protocolFee > 0) {\n                _token.safeTransfer(address(_factory), protocolFee);\n            }\n        }\n    }\n\n    /// @inheritdoc LSSVMPair\n    function _sendTokenOutput(\n        address payable tokenRecipient,\n        uint256 outputAmount\n    ) internal override {\n        // Send tokens to caller\n        if (outputAmount > 0) {\n            token().safeTransfer(tokenRecipient, outputAmount);\n        }\n    }\n\n    /// @inheritdoc LSSVMPair\n    // @dev see LSSVMPairCloner for params length calculation\n    function _immutableParamsLength() internal pure override returns (uint256) {\n        return IMMUTABLE_PARAMS_LENGTH;\n    }\n\n    \n}\n"
    },
    "contracts/lib/solmate/src/utils/SafeTransferLib.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Modified from Gnosis (https://github.com/gnosis/gp-v2-contracts/blob/main/src/contracts/libraries/GPv2SafeERC20.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\nlibrary SafeTransferLib {\n    /*///////////////////////////////////////////////////////////////\n                            ETH OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    function safeTransferETH(address to, uint256 amount) internal {\n        bool callStatus;\n\n        assembly {\n            // Transfer the ETH and store if it succeeded or not.\n            callStatus := call(gas(), to, amount, 0, 0, 0, 0)\n        }\n\n        require(callStatus, \"ETH_TRANSFER_FAILED\");\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                           ERC20 OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    function safeTransferFrom(\n        ERC20 token,\n        address from,\n        address to,\n        uint256 amount\n    ) internal {\n        bool callStatus;\n\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata to memory piece by piece:\n            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) // Begin with the function selector.\n            mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the \"from\" argument.\n            mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 68), amount) // Finally append the \"amount\" argument. No mask as it's a full 32 byte value.\n\n            // Call the token and store if it succeeded or not.\n            // We use 100 because the calldata length is 4 + 32 * 3.\n            callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0)\n        }\n\n        require(didLastOptionalReturnCallSucceed(callStatus), \"TRANSFER_FROM_FAILED\");\n    }\n\n    function safeTransfer(\n        ERC20 token,\n        address to,\n        uint256 amount\n    ) internal {\n        bool callStatus;\n\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata to memory piece by piece:\n            mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) // Begin with the function selector.\n            mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 36), amount) // Finally append the \"amount\" argument. No mask as it's a full 32 byte value.\n\n            // Call the token and store if it succeeded or not.\n            // We use 68 because the calldata length is 4 + 32 * 2.\n            callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0)\n        }\n\n        require(didLastOptionalReturnCallSucceed(callStatus), \"TRANSFER_FAILED\");\n    }\n\n    function safeApprove(\n        ERC20 token,\n        address to,\n        uint256 amount\n    ) internal {\n        bool callStatus;\n\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata to memory piece by piece:\n            mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) // Begin with the function selector.\n            mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 36), amount) // Finally append the \"amount\" argument. No mask as it's a full 32 byte value.\n\n            // Call the token and store if it succeeded or not.\n            // We use 68 because the calldata length is 4 + 32 * 2.\n            callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0)\n        }\n\n        require(didLastOptionalReturnCallSucceed(callStatus), \"APPROVE_FAILED\");\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                         INTERNAL HELPER LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function didLastOptionalReturnCallSucceed(bool callStatus) private pure returns (bool success) {\n        assembly {\n            // Get how many bytes the call returned.\n            let returnDataSize := returndatasize()\n\n            // If the call reverted:\n            if iszero(callStatus) {\n                // Copy the revert message into memory.\n                returndatacopy(0, 0, returnDataSize)\n\n                // Revert with the same message.\n                revert(0, returnDataSize)\n            }\n\n            switch returnDataSize\n            case 32 {\n                // Copy the return data into memory.\n                returndatacopy(0, 0, returnDataSize)\n\n                // Set success to whether it returned true.\n                success := iszero(iszero(mload(0)))\n            }\n            case 0 {\n                // There was no return data.\n                success := 1\n            }\n            default {\n                // It returned some malformed input.\n                success := 0\n            }\n        }\n    }\n}\n"
    },
    "contracts/src/bonding-curves/ICurve.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {CurveErrorCodes} from \"./CurveErrorCodes.sol\";\n\ninterface ICurve {\n    /**\n        @notice Validates if a delta value is valid for the curve. The criteria for\n        validity can be different for each type of curve, for instance ExponentialCurve\n        requires delta to be greater than 1.\n        @param delta The delta value to be validated\n        @return valid True if delta is valid, false otherwise\n     */\n    function validateDelta(uint128 delta) external pure returns (bool valid);\n\n    /**\n        @notice Validates if a new spot price is valid for the curve. Spot price is generally assumed to be the immediate sell price of 1 NFT to the pool, in units of the pool's paired token.\n        @param newSpotPrice The new spot price to be set\n        @return valid True if the new spot price is valid, false otherwise\n     */\n    function validateSpotPrice(uint128 newSpotPrice)\n        external\n        view\n        returns (bool valid);\n\n    /**\n        @notice Given the current state of the pair and the trade, computes how much the user\n        should pay to purchase an NFT from the pair, the new spot price, and other values.\n        @param spotPrice The current selling spot price of the pair, in tokens\n        @param delta The delta parameter of the pair, what it means depends on the curve\n        @param numItems The number of NFTs the user is buying from the pair\n        @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals\n        @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals\n        @return error Any math calculation errors, only Error.OK means the returned values are valid\n        @return newSpotPrice The updated selling spot price, in tokens\n        @return newDelta The updated delta, used to parameterize the bonding curve\n        @return inputValue The amount that the user should pay, in tokens\n        @return protocolFee The amount of fee to send to the protocol, in tokens\n     */\n    function getBuyInfo(\n        uint128 spotPrice,\n        uint128 delta,\n        uint256 numItems,\n        uint256 feeMultiplier,\n        uint256 protocolFeeMultiplier\n    )\n        external\n        view\n        returns (\n            CurveErrorCodes.Error error,\n            uint128 newSpotPrice,\n            uint128 newDelta,\n            uint256 inputValue,\n            uint256 protocolFee\n        );\n\n    /**\n        @notice Given the current state of the pair and the trade, computes how much the user\n        should receive when selling NFTs to the pair, the new spot price, and other values.\n        @param spotPrice The current selling spot price of the pair, in tokens\n        @param delta The delta parameter of the pair, what it means depends on the curve\n        @param numItems The number of NFTs the user is selling to the pair\n        @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals\n        @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals\n        @return error Any math calculation errors, only Error.OK means the returned values are valid\n        @return newSpotPrice The updated selling spot price, in tokens\n        @return newDelta The updated delta, used to parameterize the bonding curve\n        @return outputValue The amount that the user should receive, in tokens\n        @return protocolFee The amount of fee to send to the protocol, in tokens\n     */\n    function getSellInfo(\n        uint128 spotPrice,\n        uint128 delta,\n        uint256 numItems,\n        uint256 feeMultiplier,\n        uint256 protocolFeeMultiplier\n    )\n        external\n        view\n        returns (\n            CurveErrorCodes.Error error,\n            uint128 newSpotPrice,\n            uint128 newDelta,\n            uint256 outputValue,\n            uint256 protocolFee\n        );\n}\n"
    },
    "contracts/src/LSSVMPairFactory.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {ERC165Checker} from \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {IERC721Enumerable} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol\";\nimport {ReentrancyGuard} from \"./lib/ReentrancyGuard.sol\";\n\n// @dev Solmate's ERC20 is used instead of OZ's ERC20 so we can use safeTransferLib for cheaper safeTransfers for\n// ETH and ERC20 tokens\nimport {ERC20} from \"../lib/solmate/src/tokens/ERC20.sol\";\nimport {SafeTransferLib} from \"../lib/solmate/src/utils/SafeTransferLib.sol\";\n\nimport {LSSVMPair} from \"./LSSVMPair.sol\";\nimport {IRouter} from \"./IRouter.sol\";\nimport {ICurve} from \"./bonding-curves/ICurve.sol\";\nimport {LSSVMPairERC20} from \"./LSSVMPairERC20.sol\";\nimport {LSSVMPairCloner} from \"./lib/LSSVMPairCloner.sol\";\nimport {ILSSVMPairFactoryLike} from \"./ILSSVMPairFactoryLike.sol\";\nimport {LSSVMPairMissingEnumerableERC20} from \"./LSSVMPairMissingEnumerableERC20.sol\";\n\ncontract LSSVMPairFactory is Ownable, ILSSVMPairFactoryLike, ReentrancyGuard {\n    using LSSVMPairCloner for address;\n    using SafeTransferLib for address payable;\n    using SafeTransferLib for ERC20;\n\n    bytes4 private constant INTERFACE_ID_ERC721_ENUMERABLE =\n        type(IERC721Enumerable).interfaceId;\n\n    address immutable WETHaddress;\n\n    uint256 internal constant MAX_PROTOCOL_FEE = 0.10e18; // 10%, must <= 1 - MAX_FEE\n\n    LSSVMPairMissingEnumerableERC20\n        public missingEnumerableERC20Template;\n    address payable public override protocolFeeRecipient;\n\n    // Units are in base 1e18\n    uint256 public override protocolFeeMultiplier;\n\n    mapping(ICurve => bool) public bondingCurveAllowed;\n    mapping(address => bool) public override callAllowed;\n    struct RouterStatus {\n        bool allowed;\n        bool wasEverAllowed;\n    }\n    mapping(IRouter => RouterStatus) public override routerStatus;\n    mapping(address => uint256) public poolCount;\n    mapping(address => mapping(address => bool)) requestApprovees;\n    address payable public immutable override sisterFactory;\n\n    event NewPair(\n        address indexed msgSender,\n        address indexed nft,\n        LSSVMPair.PoolType indexed poolType,\n        address txOrigin,\n        address poolAddress\n    );\n\n    event TokenDeposit(address poolAddress);\n    event NFTDeposit(address poolAddress);\n    event ProtocolFeeRecipientUpdate(address recipientAddress);\n    event ProtocolFeeMultiplierUpdate(uint256 newMultiplier);\n    event BondingCurveStatusUpdate(ICurve bondingCurve, bool isAllowed);\n    event CallTargetStatusUpdate(address target, bool isAllowed);\n    event RouterStatusUpdate(IRouter router, bool isAllowed);\n\n    constructor(\n        LSSVMPairMissingEnumerableERC20 _missingEnumerableERC20Template,\n        address payable _protocolFeeRecipient,\n        uint256 _protocolFeeMultiplier,\n        address payable _sisterFactory,\n        address _WETHaddress\n    ) {\n        \n        missingEnumerableERC20Template = _missingEnumerableERC20Template;\n        protocolFeeRecipient = _protocolFeeRecipient;\n\n        require(_protocolFeeMultiplier <= MAX_PROTOCOL_FEE, \"Fee too large\");\n        protocolFeeMultiplier = _protocolFeeMultiplier;\n        sisterFactory = _sisterFactory;\n\n        WETHaddress = _WETHaddress;\n    }\n\n    function upgradeTemplate(LSSVMPairMissingEnumerableERC20 template) external onlyOwner {\n        missingEnumerableERC20Template = template;\n    }\n\n    /**\n     * External functions\n     */\n\n    /**\n        @notice Creates a pair contract using EIP-1167.\n        @param _nft The NFT contract of the collection the pair trades\n        @param _bondingCurve The bonding curve for the pair to price NFTs, must be whitelisted\n        @param _assetRecipient The address that will receive the assets traders give during trades.\n                              If set to address(0), assets will be sent to the pool address.\n                              Not available to TRADE pools. \n        @param _poolType TOKEN, NFT, or TRADE\n        @param _delta The delta value used by the bonding curve. The meaning of delta depends\n        on the specific curve.\n        @param _fee The fee taken by the LP in each trade. Can only be non-zero if _poolType is Trade.\n        @param _spotPrice The initial selling spot price\n        @param _initialNFTIDs The list of IDs of NFTs to transfer from the sender to the pair\n        @return pair The new pair\n     */\n    \n\n    /**\n        @notice Creates a pair contract using EIP-1167.\n        @param _nft The NFT contract of the collection the pair trades\n        @param _bondingCurve The bonding curve for the pair to price NFTs, must be whitelisted\n        @param _assetRecipient The address that will receive the assets traders give during trades.\n                                If set to address(0), assets will be sent to the pool address.\n                                Not available to TRADE pools.\n        @param _poolType TOKEN, NFT, or TRADE\n        @param _delta The delta value used by the bonding curve. The meaning of delta depends\n        on the specific curve.uint256[] memory x;\n        x[0]= 1;\n        x[1]= 2;\n        @param _fee The fee taken by the LP in each trade. Can only be non-zero if _poolType is Trade.\n        @param _spotPrice The initial selling spot price, in ETH\n        @param _initialNFTIDs The list of IDs of NFTs to transfer from the sender to the pair\n        @param _initialTokenBalance The initial token balance sent from the sender to the new pair\n        @return pair The new pair\n     */\n    struct CreateERC20PairParams {\n        ERC20 token;\n        IERC721 nft;\n        ICurve bondingCurve;\n        address payable assetRecipient;\n        LSSVMPair.PoolType poolType;\n        uint128 delta;\n        uint96 fee;\n        uint128 spotPrice;\n        uint256[] initialNFTIDs;\n        uint256 initialTokenBalance;\n    }\n\n    function getSalt() public view returns (bytes32){\n        return keccak256(abi.encode(msg.sender, poolCount[msg.sender]));\n    }\n\n    function createPairERC20(\n        CreateERC20PairParams calldata params,\n        address payable WETH,\n        bool createSudo\n    ) external nonReentrant payable returns (LSSVMPairERC20 pair) {\n        require(\n            bondingCurveAllowed[params.bondingCurve],\n            \"Bonding curve not whitelisted\"\n        );\n        if (address(WETH) != address(0)) {\n          require(address(WETH) == WETHaddress);\n          WETH.call{value: msg.value}(\"\");\n          ERC20(WETH).transfer(msg.sender, msg.value);\n        }\n        \n        address template;\n        \n        template = address(missingEnumerableERC20Template);\n\n\n        pair = LSSVMPairERC20(\n            payable(\n                template.cloneERC20Pair(\n                    this,\n                    params.bondingCurve,\n                    params.nft,\n                    uint8(params.poolType),\n                    params.token,\n                    keccak256(abi.encode(msg.sender, poolCount[msg.sender]))\n                )\n            )\n        );\n        requestApprovees[msg.sender][address(pair)] = true;\n\n        _initializePairERC20(\n            pair,\n            params.token,\n            params.nft,\n            params.assetRecipient,\n            params.delta,\n            params.fee,\n            params.spotPrice,\n            params.initialNFTIDs,\n            params.initialTokenBalance,\n            createSudo\n        );\n        poolCount[msg.sender] += 1;\n        emit NewPair(\n            msg.sender,\n            address(params.nft),\n            params.poolType,\n            tx.origin,\n            address(pair)\n        );\n    }\n\n    /**\n        @notice Checks if an address is a LSSVMPair. Uses the fact that the pairs are EIP-1167 minimal proxies.\n        @param potentialPair The address to check\n        @param variant The pair variant (NFT is enumerable or not, pair uses ETH or ERC20)\n        @return True if the address is the specified pair variant, false otherwise\n     */\n    function isPair(address potentialPair, PairVariant variant)\n        public\n        view\n        override\n        returns (bool)\n    {\n        // if (variant == PairVariant.ENUMERABLE_ERC20) {\n        //     return\n        //         LSSVMPairCloner.isERC20PairClone(\n        //             address(this),\n        //             address(enumerableERC20Template),\n        //             potentialPair\n        //         );\n        // } else\n        if (variant == PairVariant.MISSING_ENUMERABLE_ERC20) {\n            return\n                LSSVMPairCloner.isERC20PairClone(\n                    address(this),\n                    address(missingEnumerableERC20Template),\n                    potentialPair\n                );\n            \n        } else {\n            // invalid input\n            return false;\n        }\n    }\n\n    function createPairETH(\n        address _nft,\n        address _bondingCurve,\n        address payable _assetRecipient,\n        uint8 _poolType,\n        uint128 _delta,\n        uint96 _fee,\n        uint128 _spotPrice,\n        uint256[] calldata _initialNFTIDs\n    ) external override payable returns (address pair) {\n      revert(\"Not supported\");\n    }\n\n    /**\n        @notice Allows receiving ETH in order to receive protocol fees\n     */\n    receive() external payable {}\n\n    /**\n     * Admin functions\n     */\n\n    /**\n        @notice Withdraws the ETH balance to the protocol fee recipient.\n        Only callable by the owner.\n     */\n    function withdrawETHProtocolFees() external onlyOwner {\n        protocolFeeRecipient.safeTransferETH(address(this).balance);\n    }\n\n    /**\n        @notice Withdraws ERC20 tokens to the protocol fee recipient. Only callable by the owner.\n        @param token The token to transfer\n        @param amount The amount of tokens to transfer\n     */\n    function withdrawERC20ProtocolFees(ERC20 token, uint256 amount)\n        external\n        onlyOwner\n    {\n        token.safeTransfer(protocolFeeRecipient, amount);\n    }\n\n    /**\n        @notice Changes the protocol fee recipient address. Only callable by the owner.\n        @param _protocolFeeRecipient The new fee recipient\n     */\n    function changeProtocolFeeRecipient(address payable _protocolFeeRecipient)\n        external\n        onlyOwner\n    {\n        require(_protocolFeeRecipient != address(0), \"0 address\");\n        protocolFeeRecipient = _protocolFeeRecipient;\n        emit ProtocolFeeRecipientUpdate(_protocolFeeRecipient);\n    }\n\n    /**\n        @notice Changes the protocol fee multiplier. Only callable by the owner.\n        @param _protocolFeeMultiplier The new fee multiplier, 18 decimals\n     */\n    function changeProtocolFeeMultiplier(uint256 _protocolFeeMultiplier)\n        external\n        onlyOwner\n    {\n        require(_protocolFeeMultiplier <= MAX_PROTOCOL_FEE, \"Fee too large\");\n        protocolFeeMultiplier = _protocolFeeMultiplier;\n        emit ProtocolFeeMultiplierUpdate(_protocolFeeMultiplier);\n    }\n\n    /**\n        @notice Sets the whitelist status of a bonding curve contract. Only callable by the owner.\n        @param bondingCurve The bonding curve contract\n        @param isAllowed True to whitelist, false to remove from whitelist\n     */\n    function setBondingCurveAllowed(ICurve bondingCurve, bool isAllowed)\n        external\n        onlyOwner\n    {\n        bondingCurveAllowed[bondingCurve] = isAllowed;\n        emit BondingCurveStatusUpdate(bondingCurve, isAllowed);\n    }\n\n    /**\n        @notice Sets the whitelist status of a contract to be called arbitrarily by a pair.\n        Only callable by the owner.\n        @param target The target contract\n        @param isAllowed True to whitelist, false to remove from whitelist\n     */\n    function setCallAllowed(address payable target, bool isAllowed)\n        external\n        onlyOwner\n    {\n        // ensure target is not / was not ever a router\n        if (isAllowed) {\n            require(\n                !routerStatus[IRouter(target)].wasEverAllowed,\n                \"Can't call router\"\n            );\n        }\n\n        callAllowed[target] = isAllowed;\n        emit CallTargetStatusUpdate(target, isAllowed);\n    }\n\n    /**\n        @notice Updates the router whitelist. Only callable by the owner.\n        @param _router The router\n        @param isAllowed True to whitelist, false to remove from whitelist\n     */\n    function setRouterAllowed(IRouter _router, bool isAllowed)\n        external\n        onlyOwner\n    {\n        // ensure target is not arbitrarily callable by pairs\n        if (isAllowed) {\n            require(!callAllowed[address(_router)], \"Can't call router\");\n        }\n        routerStatus[_router] = RouterStatus({\n            allowed: isAllowed,\n            wasEverAllowed: true\n        });\n\n        emit RouterStatusUpdate(_router, isAllowed);\n    }\n\n    /**\n     * Internal functions\n     */\n\n\n    function _initializePairERC20(\n        LSSVMPairERC20 _pair,\n        ERC20 _token,\n        IERC721 _nft,\n        address payable _assetRecipient,\n        uint128 _delta,\n        uint96 _fee,\n        uint128 _spotPrice,\n        uint256[] calldata _initialNFTIDs,\n        uint256 _initialTokenBalance,\n        bool createSudo\n    ) internal {\n        // initialize pair\n        _pair.initialize(msg.sender, _assetRecipient, _delta, _fee, _spotPrice);\n\n        // transfer initial tokens to pair\n        _token.safeTransferFrom(\n            msg.sender,\n            address(_pair),\n            _initialTokenBalance\n        );\n\n        if (createSudo) {\n          LSSVMPairMissingEnumerableERC20(address(_pair)).createSudoPool(sisterFactory ,_assetRecipient);\n        }\n\n        \n        LSSVMPairMissingEnumerableERC20(address(_pair)).addNFTToPool(\n            _initialNFTIDs\n        );\n    }\n\n    function requestNFTTransferFrom(IERC721 _nft,address from, address recipient,\n        uint256 id) external override {\n        require(requestApprovees[from][msg.sender], \"Requester is not approved\");\n        _nft.safeTransferFrom(from, recipient, id);\n    }\n\n    /** \n      @dev Used to deposit NFTs into a pair after creation and emit an event for indexing (if recipient is indeed a pair)\n    */\n    function depositNFTs(\n        IERC721 _nft,\n        uint256[] calldata ids,\n        address recipient\n    ) nonReentrant external override {\n        // transfer NFTs from caller to recipient\n        uint256 numNFTs = ids.length;\n        for (uint256 i; i < numNFTs; ) {\n            _nft.safeTransferFrom(msg.sender, recipient, ids[i]);\n\n            unchecked {\n                ++i;\n            }\n        }\n        if (\n            isPair(recipient, PairVariant.ENUMERABLE_ERC20) ||\n            isPair(recipient, PairVariant.ENUMERABLE_ETH) ||\n            isPair(recipient, PairVariant.MISSING_ENUMERABLE_ERC20) ||\n            isPair(recipient, PairVariant.MISSING_ENUMERABLE_ETH)\n        ) {\n            emit NFTDeposit(recipient);\n        }\n    }\n\n    /**\n      @dev Used to deposit ERC20s into a pair after creation and emit an event for indexing (if recipient is indeed an ERC20 pair and the token matches)\n     */\n    function depositERC20(\n        ERC20 token,\n        address recipient,\n        uint256 amount\n    ) nonReentrant external {\n        token.safeTransferFrom(msg.sender, recipient, amount);\n        if (\n            isPair(recipient, PairVariant.ENUMERABLE_ERC20) ||\n            isPair(recipient, PairVariant.MISSING_ENUMERABLE_ERC20)\n        ) {\n            if (token == LSSVMPairERC20(recipient).token()) {\n                emit TokenDeposit(recipient);\n            }\n        }\n    }\n}\n"
    },
    "contracts/src/ILSSVMPairFactoryLike.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {IRouter} from \"./IRouter.sol\";\n\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\ninterface ILSSVMPairFactoryLike {\n    enum PairVariant {\n        ENUMERABLE_ETH,\n        MISSING_ENUMERABLE_ETH,\n        ENUMERABLE_ERC20,\n        MISSING_ENUMERABLE_ERC20\n    }\n\n    function protocolFeeMultiplier() external view returns (uint256);\n\n    function protocolFeeRecipient() external view returns (address payable);\n\n    function callAllowed(address target) external view returns (bool);\n\n    function routerStatus(IRouter router)\n        external\n        view\n        returns (bool allowed, bool wasEverAllowed);\n\n    function isPair(address potentialPair, PairVariant variant)\n        external\n        view\n        returns (bool);\n    \n    function createPairETH(\n        address _nft,\n        address _bondingCurve,\n        address payable _assetRecipient,\n        uint8 _poolType,\n        uint128 _delta,\n        uint96 _fee,\n        uint128 _spotPrice,\n        uint256[] calldata _initialNFTIDs\n    ) external payable returns (address pair);\n function sisterFactory() external returns (address payable);\n function depositNFTs(\n        IERC721 _nft,\n        uint256[] calldata ids,\n        address recipient\n    )  external;\n    function requestNFTTransferFrom(IERC721 _nft,address from, address recipient, uint256 id) external;\n}\n"
    },
    "contracts/lib/solmate/src/tokens/ERC20.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\nabstract contract ERC20 {\n    /*///////////////////////////////////////////////////////////////\n                                  EVENTS\n    //////////////////////////////////////////////////////////////*/\n\n    event Transfer(address indexed from, address indexed to, uint256 amount);\n\n    event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n    /*///////////////////////////////////////////////////////////////\n                             METADATA STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    string public name;\n\n    string public symbol;\n\n    uint8 public immutable decimals;\n\n    /*///////////////////////////////////////////////////////////////\n                              ERC20 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 public totalSupply;\n\n    mapping(address => uint256) public balanceOf;\n\n    mapping(address => mapping(address => uint256)) public allowance;\n\n    /*///////////////////////////////////////////////////////////////\n                           EIP-2612 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    bytes32 public constant PERMIT_TYPEHASH =\n        keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n    uint256 internal immutable INITIAL_CHAIN_ID;\n\n    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n    mapping(address => uint256) public nonces;\n\n    /*///////////////////////////////////////////////////////////////\n                               CONSTRUCTOR\n    //////////////////////////////////////////////////////////////*/\n\n    constructor(\n        string memory _name,\n        string memory _symbol,\n        uint8 _decimals\n    ) {\n        name = _name;\n        symbol = _symbol;\n        decimals = _decimals;\n\n        INITIAL_CHAIN_ID = block.chainid;\n        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                              ERC20 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function approve(address spender, uint256 amount) public virtual returns (bool) {\n        allowance[msg.sender][spender] = amount;\n\n        emit Approval(msg.sender, spender, amount);\n\n        return true;\n    }\n\n    function transfer(address to, uint256 amount) public virtual returns (bool) {\n        balanceOf[msg.sender] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(msg.sender, to, amount);\n\n        return true;\n    }\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public virtual returns (bool) {\n        if (allowance[from][msg.sender] != type(uint256).max) {\n            allowance[from][msg.sender] -= amount;\n        }\n\n        balanceOf[from] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(from, to, amount);\n\n        return true;\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                              EIP-2612 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public virtual {\n        require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n        // Unchecked because the only math done is incrementing\n        // the owner's nonce which cannot realistically overflow.\n        unchecked {\n            bytes32 digest = keccak256(\n                abi.encodePacked(\n                    \"\\x19\\x01\",\n                    DOMAIN_SEPARATOR(),\n                    keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))\n                )\n            );\n\n            address recoveredAddress = ecrecover(digest, v, r, s);\n            require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_PERMIT_SIGNATURE\");\n\n            allowance[recoveredAddress][spender] = value;\n        }\n\n        emit Approval(owner, spender, value);\n    }\n\n    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n    }\n\n    function computeDomainSeparator() internal view virtual returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n                    keccak256(bytes(name)),\n                    keccak256(bytes(\"1\")),\n                    block.chainid,\n                    address(this)\n                )\n            );\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                       INTERNAL MINT/BURN LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function _mint(address to, uint256 amount) internal virtual {\n        totalSupply += amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(address(0), to, amount);\n    }\n\n    function _burn(address from, uint256 amount) internal virtual {\n        balanceOf[from] -= amount;\n\n        // Cannot underflow because a user's balance\n        // will never be larger than the total supply.\n        unchecked {\n            totalSupply -= amount;\n        }\n\n        emit Transfer(from, address(0), amount);\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC1155/IERC1155.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155 is IERC165 {\n    /**\n     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n     */\n    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n    /**\n     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n     * transfers.\n     */\n    event TransferBatch(\n        address indexed operator,\n        address indexed from,\n        address indexed to,\n        uint256[] ids,\n        uint256[] values\n    );\n\n    /**\n     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n     * `approved`.\n     */\n    event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n    /**\n     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n     *\n     * If an {URI} event was emitted for `id`, the standard\n     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n     * returned by {IERC1155MetadataURI-uri}.\n     */\n    event URI(string value, uint256 indexed id);\n\n    /**\n     * @dev Returns the amount of tokens of token type `id` owned by `account`.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function balanceOf(address account, uint256 id) external view returns (uint256);\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n     *\n     * Requirements:\n     *\n     * - `accounts` and `ids` must have the same length.\n     */\n    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n        external\n        view\n        returns (uint256[] memory);\n\n    /**\n     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n     *\n     * Emits an {ApprovalForAll} event.\n     *\n     * Requirements:\n     *\n     * - `operator` cannot be the caller.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n     *\n     * See {setApprovalForAll}.\n     */\n    function isApprovedForAll(address account, address operator) external view returns (bool);\n\n    /**\n     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n     *\n     * Emits a {TransferSingle} event.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n     * - `from` must have a balance of tokens of type `id` of at least `amount`.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n     * acceptance magic value.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 id,\n        uint256 amount,\n        bytes calldata data\n    ) external;\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n     *\n     * Emits a {TransferBatch} event.\n     *\n     * Requirements:\n     *\n     * - `ids` and `amounts` must have the same length.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n     * acceptance magic value.\n     */\n    function safeBatchTransferFrom(\n        address from,\n        address to,\n        uint256[] calldata ids,\n        uint256[] calldata amounts,\n        bytes calldata data\n    ) external;\n}\n"
    },
    "contracts/src/LSSVMPair.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {ERC20} from \"../lib/solmate/src/tokens/ERC20.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {IERC1155} from \"@openzeppelin/contracts/token/ERC1155/IERC1155.sol\";\nimport {OwnableWithTransferCallback} from \"./lib/OwnableWithTransferCallback.sol\";\nimport {ReentrancyGuard} from \"./lib/ReentrancyGuard.sol\";\nimport {ICurve} from \"./bonding-curves/ICurve.sol\";\nimport \"./IRouter.sol\";\nimport {ILSSVMPairFactoryLike} from \"./ILSSVMPairFactoryLike.sol\";\nimport {CurveErrorCodes} from \"./bonding-curves/CurveErrorCodes.sol\";\nimport {ERC1155Holder} from \"@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol\";\n\n/// @title The base contract for an NFT/TOKEN AMM pair\n/// @author boredGenius and 0xmons\n/// @notice This implements the core swap logic from NFT to TOKEN\nabstract contract LSSVMPair is\n    OwnableWithTransferCallback,\n    ReentrancyGuard,\n    ERC1155Holder\n{\n    enum PoolType {\n        TOKEN,\n        NFT,\n        TRADE\n    }\n\n    // 90%, must <= 1 - MAX_PROTOCOL_FEE (set in LSSVMPairFactory)\n    uint256 internal constant MAX_FEE = 0.90e18;\n\n    // The current price of the NFT\n    // @dev This is generally used to mean the immediate sell price for the next marginal NFT.\n    // However, this should NOT be assumed, as future bonding curves may use spotPrice in different ways.\n    // Use getBuyNFTQuote and getSellNFTQuote for accurate pricing info.\n    uint128 public spotPrice;\n\n    // The parameter for the pair's bonding curve.\n    // Units and meaning are bonding curve dependent.\n    uint128 public delta;\n\n    // The spread between buy and sell prices, set to be a multiplier we apply to the buy price\n    // Fee is only relevant for TRADE pools\n    // Units are in base 1e18\n    uint96 public fee;\n\n    // If set to 0, NFTs/tokens sent by traders during trades will be sent to the pair.\n    // Otherwise, assets will be sent to the set address. Not available for TRADE pools.\n    address payable public assetRecipient;\n\n    // Events\n    event SwapNFTInPair();\n    event SwapNFTOutPair();\n    event SpotPriceUpdate(uint128 newSpotPrice);\n    event TokenDeposit(uint256 amount);\n    event TokenWithdrawal(uint256 amount);\n    event NFTWithdrawal();\n    event DeltaUpdate(uint128 newDelta);\n    event FeeUpdate(uint96 newFee);\n    event AssetRecipientChange(address a);\n\n    // Parameterized Errors\n    error BondingCurveError(CurveErrorCodes.Error error);\n\n    /**\n      @notice Called during pair creation to set initial parameters\n      @dev Only called once by factory to initialize.\n      We verify this by making sure that the current owner is address(0). \n      The Ownable library we use disallows setting the owner to be address(0), so this condition\n      should only be valid before the first initialize call. \n      @param _owner The owner of the pair\n      @param _assetRecipient The address that will receive the TOKEN or NFT sent to this pair during swaps. NOTE: If set to address(0), they will go to the pair itself.\n      @param _delta The initial delta of the bonding curve\n      @param _fee The initial % fee taken, if this is a trade pair \n      @param _spotPrice The initial price to sell an asset into the pair\n     */\n    function initialize(\n        address _owner,\n        address payable _assetRecipient,\n        uint128 _delta,\n        uint96 _fee,\n        uint128 _spotPrice\n    ) external payable {\n        require(owner() == address(0), \"Initialized\");\n        __Ownable_init(_owner);\n        __ReentrancyGuard_init();\n\n        ICurve _bondingCurve = bondingCurve();\n        PoolType _poolType = poolType();\n\n        if ((_poolType == PoolType.TOKEN) || (_poolType == PoolType.NFT)) {\n            require(_fee == 0, \"Only Trade Pools can have nonzero fee\");\n            assetRecipient = _assetRecipient;\n        } else if (_poolType == PoolType.TRADE) {\n            require(_fee < MAX_FEE, \"Trade fee must be less than 90%\");\n            require(\n                _assetRecipient == address(0),\n                \"Trade pools can't set asset recipient\"\n            );\n            fee = _fee;\n        }\n        require(_bondingCurve.validateDelta(_delta), \"Invalid delta for curve\");\n        require(\n            _bondingCurve.validateSpotPrice(_spotPrice),\n            \"Invalid new spot price for curve\"\n        );\n        delta = _delta;\n        spotPrice = _spotPrice;\n    }\n\n    /**\n     * External state-changing functions\n     */\n\n    /**\n        @notice Sends token to the pair in exchange for any `numNFTs` NFTs\n        @dev To compute the amount of token to send, call bondingCurve.getBuyInfo.\n        This swap function is meant for users who are ID agnostic\n        @param numNFTs The number of NFTs to purchase\n        @param maxExpectedTokenInput The maximum acceptable cost from the sender. If the actual\n        amount is greater than this value, the transaction will be reverted.\n        @param nftRecipient The recipient of the NFTs\n        @param isRouter True if calling from LSSVMRouter, false otherwise. Not used for\n        ETH pairs.\n        @param routerCaller If isRouter is true, ERC20 tokens will be transferred from this address. Not used for\n        ETH pairs.\n        @return inputAmount The amount of token used for purchase\n     */\n    function swapTokenForAnyNFTs(\n        uint256 numNFTs,\n        uint256 maxExpectedTokenInput,\n        address nftRecipient,\n        bool isRouter,\n        address routerCaller\n    ) external payable virtual nonReentrant returns (uint256 inputAmount) {\n        // Store locally to remove extra calls\n        ILSSVMPairFactoryLike _factory = factory();\n        ICurve _bondingCurve = bondingCurve();\n        IERC721 _nft = nft();\n\n        // Input validation\n        {\n            PoolType _poolType = poolType();\n            require(\n                _poolType == PoolType.NFT || _poolType == PoolType.TRADE,\n                \"Wrong Pool type\"\n            );\n            require(\n                (numNFTs > 0) && (numNFTs <= _nft.balanceOf(address(this))),\n                \"Ask for > 0 and <= balanceOf NFTs\"\n            );\n        }\n\n        // Call bonding curve for pricing information\n        uint256 protocolFee;\n        (protocolFee, inputAmount) = _calculateBuyInfoAndUpdatePoolParams(\n            numNFTs,\n            maxExpectedTokenInput,\n            _bondingCurve,\n            _factory\n        );\n\n        _pullTokenInputAndPayProtocolFee(\n            inputAmount,\n            isRouter,\n            routerCaller,\n            _factory,\n            protocolFee\n        );\n\n        _sendAnyNFTsToRecipient(_nft, nftRecipient, numNFTs);\n\n        _refundTokenToSender(inputAmount);\n\n        emit SwapNFTOutPair();\n    }\n\n    /**\n        @notice Sends token to the pair in exchange for a specific set of NFTs\n        @dev To compute the amount of token to send, call bondingCurve.getBuyInfo\n        This swap is meant for users who want specific IDs. Also higher chance of\n        reverting if some of the specified IDs leave the pool before the swap goes through.\n        @param nftIds The list of IDs of the NFTs to purchase\n        @param maxExpectedTokenInput The maximum acceptable cost from the sender. If the actual\n        amount is greater than this value, the transaction will be reverted.\n        @param nftRecipient The recipient of the NFTs\n        @param isRouter True if calling from LSSVMRouter, false otherwise. Not used for\n        ETH pairs.\n        @param routerCaller If isRouter is true, ERC20 tokens will be transferred from this address. Not used for\n        ETH pairs.\n        @return inputAmount The amount of token used for purchase\n     */\n    function swapTokenForSpecificNFTs(\n        uint256[] calldata nftIds,\n        uint256 maxExpectedTokenInput,\n        address nftRecipient,\n        bool isRouter,\n        address routerCaller\n    ) external payable virtual nonReentrant returns (uint256 inputAmount) {\n        // Store locally to remove extra calls\n        ILSSVMPairFactoryLike _factory = factory();\n        ICurve _bondingCurve = bondingCurve();\n\n        // Input validation\n        {\n            PoolType _poolType = poolType();\n            require(\n                _poolType == PoolType.NFT || _poolType == PoolType.TRADE,\n                \"Wrong Pool type\"\n            );\n            require((nftIds.length > 0), \"Must ask for > 0 NFTs\");\n        }\n\n        // Call bonding curve for pricing information\n        uint256 protocolFee;\n        (protocolFee, inputAmount) = _calculateBuyInfoAndUpdatePoolParams(\n            nftIds.length,\n            maxExpectedTokenInput,\n            _bondingCurve,\n            _factory\n        );\n\n        _pullTokenInputAndPayProtocolFee(\n            inputAmount,\n            isRouter,\n            routerCaller,\n            _factory,\n            protocolFee\n        );\n\n        _sendSpecificNFTsToRecipient(nft(), nftRecipient, nftIds);\n\n        _refundTokenToSender(inputAmount);\n\n        emit SwapNFTOutPair();\n    }\n\n    /**\n        @notice Sends a set of NFTs to the pair in exchange for token\n        @dev To compute the amount of token to that will be received, call bondingCurve.getSellInfo.\n        @param nftIds The list of IDs of the NFTs to sell to the pair\n        @param minExpectedTokenOutput The minimum acceptable token received by the sender. If the actual\n        amount is less than this value, the transaction will be reverted.\n        @param tokenRecipient The recipient of the token output\n        @param isRouter True if calling from LSSVMRouter, false otherwise. Not used for\n        ETH pairs.\n        @param routerCaller If isRouter is true, ERC20 tokens will be transferred from this address. Not used for\n        ETH pairs.\n        @return outputAmount The amount of token received\n     */\n    function swapNFTsForToken(\n        uint256[] calldata nftIds,\n        uint256 minExpectedTokenOutput,\n        address payable tokenRecipient,\n        bool isRouter,\n        address routerCaller\n    ) external virtual nonReentrant returns (uint256 outputAmount) {\n        // Store locally to remove extra calls\n        ILSSVMPairFactoryLike _factory = factory();\n        ICurve _bondingCurve = bondingCurve();\n\n        // Input validation\n        {\n            PoolType _poolType = poolType();\n            require(\n                _poolType == PoolType.TOKEN || _poolType == PoolType.TRADE,\n                \"Wrong Pool type\"\n            );\n            require(nftIds.length > 0, \"Must ask for > 0 NFTs\");\n        }\n\n        // Call bonding curve for pricing information\n        uint256 protocolFee;\n        (protocolFee, outputAmount) = _calculateSellInfoAndUpdatePoolParams(\n            nftIds.length,\n            minExpectedTokenOutput,\n            _bondingCurve,\n            _factory\n        );\n\n        _sendTokenOutput(tokenRecipient, outputAmount);\n\n        _payProtocolFeeFromPair(_factory, protocolFee);\n\n        _takeNFTsFromSender(nft(), nftIds, _factory, isRouter, routerCaller);\n\n        emit SwapNFTInPair();\n    }\n\n    /**\n     * View functions\n     */\n\n    /**\n        @dev Used as read function to query the bonding curve for buy pricing info\n        @param numNFTs The number of NFTs to buy from the pair\n     */\n    function getBuyNFTQuote(uint256 numNFTs)\n        external\n        view\n        returns (\n            CurveErrorCodes.Error error,\n            uint256 newSpotPrice,\n            uint256 newDelta,\n            uint256 inputAmount,\n            uint256 protocolFee\n        )\n    {\n        (\n            error,\n            newSpotPrice,\n            newDelta,\n            inputAmount,\n            protocolFee\n        ) = bondingCurve().getBuyInfo(\n            spotPrice,\n            delta,\n            numNFTs,\n            fee,\n            factory().protocolFeeMultiplier()\n        );\n    }\n\n    /**\n        @dev Used as read function to query the bonding curve for sell pricing info\n        @param numNFTs The number of NFTs to sell to the pair\n     */\n    function getSellNFTQuote(uint256 numNFTs)\n        external\n        view\n        returns (\n            CurveErrorCodes.Error error,\n            uint256 newSpotPrice,\n            uint256 newDelta,\n            uint256 outputAmount,\n            uint256 protocolFee\n        )\n    {\n        (\n            error,\n            newSpotPrice,\n            newDelta,\n            outputAmount,\n            protocolFee\n        ) = bondingCurve().getSellInfo(\n            spotPrice,\n            delta,\n            numNFTs,\n            fee,\n            factory().protocolFeeMultiplier()\n        );\n    }\n\n    /**\n        @notice Returns all NFT IDs held by the pool\n     */\n    function getAllHeldIds() external view virtual returns (uint256[] memory);\n\n    /**\n        @notice Returns the pair's variant (NFT is enumerable or not, pair uses ETH or ERC20)\n     */\n    function pairVariant() public pure virtual returns (IRouter.PairVariant);\n\n    function factory() public pure returns (ILSSVMPairFactoryLike _factory) {\n        uint256 paramsLength = _immutableParamsLength();\n        assembly {\n            _factory := shr(\n                0x60,\n                calldataload(sub(calldatasize(), paramsLength))\n            )\n        }\n    }\n\n    /**\n        @notice Returns the type of bonding curve that parameterizes the pair\n     */\n    function bondingCurve() public pure returns (ICurve _bondingCurve) {\n        uint256 paramsLength = _immutableParamsLength();\n        assembly {\n            _bondingCurve := shr(\n                0x60,\n                calldataload(add(sub(calldatasize(), paramsLength), 20))\n            )\n        }\n    }\n\n    /**\n        @notice Returns the NFT collection that parameterizes the pair\n     */\n    function nft() public pure returns (IERC721 _nft) {\n        uint256 paramsLength = _immutableParamsLength();\n        assembly {\n            _nft := shr(\n                0x60,\n                calldataload(add(sub(calldatasize(), paramsLength), 40))\n            )\n        }\n    }\n\n    /**\n        @notice Returns the pair's type (TOKEN/NFT/TRADE)\n     */\n    function poolType() public pure returns (PoolType _poolType) {\n        uint256 paramsLength = _immutableParamsLength();\n        assembly {\n            _poolType := shr(\n                0xf8,\n                calldataload(add(sub(calldatasize(), paramsLength), 60))\n            )\n        }\n    }\n\n    /**\n        @notice Returns the address that assets that receives assets when a swap is done with this pair\n        Can be set to another address by the owner, if set to address(0), defaults to the pair's own address\n     */\n    function getAssetRecipient()\n        public\n        view\n        returns (address payable _assetRecipient)\n    {\n        // If it's a TRADE pool, we know the recipient is 0 (TRADE pools can't set asset recipients)\n        // so just return address(this)\n        if (poolType() == PoolType.TRADE) {\n            return payable(address(this));\n        }\n\n        // Otherwise, we return the recipient if it's been set\n        // or replace it with address(this) if it's 0\n        _assetRecipient = assetRecipient;\n        if (_assetRecipient == address(0)) {\n            // Tokens will be transferred to address(this)\n            _assetRecipient = payable(address(this));\n        }\n    }\n\n    /**\n     * Internal functions\n     */\n\n    /**\n        @notice Calculates the amount needed to be sent into the pair for a buy and adjusts spot price or delta if necessary\n        @param numNFTs The amount of NFTs to purchase from the pair\n        @param maxExpectedTokenInput The maximum acceptable cost from the sender. If the actual\n        amount is greater than this value, the transaction will be reverted.\n        @param protocolFee The percentage of protocol fee to be taken, as a percentage\n        @return protocolFee The amount of tokens to send as protocol fee\n        @return inputAmount The amount of tokens total tokens receive\n     */\n    function _calculateBuyInfoAndUpdatePoolParams(\n        uint256 numNFTs,\n        uint256 maxExpectedTokenInput,\n        ICurve _bondingCurve,\n        ILSSVMPairFactoryLike _factory\n    ) internal returns (uint256 protocolFee, uint256 inputAmount) {\n        CurveErrorCodes.Error error;\n        // Save on 2 SLOADs by caching\n        uint128 currentSpotPrice = spotPrice;\n        uint128 newSpotPrice;\n        uint128 currentDelta = delta;\n        uint128 newDelta;\n        (\n            error,\n            newSpotPrice,\n            newDelta,\n            inputAmount,\n            protocolFee\n        ) = _bondingCurve.getBuyInfo(\n            currentSpotPrice,\n            currentDelta,\n            numNFTs,\n            fee,\n            _factory.protocolFeeMultiplier()\n        );\n\n        // Revert if bonding curve had an error\n        if (error != CurveErrorCodes.Error.OK) {\n            revert BondingCurveError(error);\n        }\n\n        // Revert if input is more than expected\n        require(inputAmount <= maxExpectedTokenInput, \"In too many tokens\");\n\n        // Consolidate writes to save gas\n        if (currentSpotPrice != newSpotPrice || currentDelta != newDelta) {\n            spotPrice = newSpotPrice;\n            delta = newDelta;\n        }\n\n        // Emit spot price update if it has been updated\n        if (currentSpotPrice != newSpotPrice) {\n            emit SpotPriceUpdate(newSpotPrice);\n        }\n\n        // Emit delta update if it has been updated\n        if (currentDelta != newDelta) {\n            emit DeltaUpdate(newDelta);\n        }\n    }\n\n    /**\n        @notice Calculates the amount needed to be sent by the pair for a sell and adjusts spot price or delta if necessary\n        @param numNFTs The amount of NFTs to send to the the pair\n        @param minExpectedTokenOutput The minimum acceptable token received by the sender. If the actual\n        amount is less than this value, the transaction will be reverted.\n        @param protocolFee The percentage of protocol fee to be taken, as a percentage\n        @return protocolFee The amount of tokens to send as protocol fee\n        @return outputAmount The amount of tokens total tokens receive\n     */\n    function _calculateSellInfoAndUpdatePoolParams(\n        uint256 numNFTs,\n        uint256 minExpectedTokenOutput,\n        ICurve _bondingCurve,\n        ILSSVMPairFactoryLike _factory\n    ) internal returns (uint256 protocolFee, uint256 outputAmount) {\n        CurveErrorCodes.Error error;\n        // Save on 2 SLOADs by caching\n        uint128 currentSpotPrice = spotPrice;\n        uint128 newSpotPrice;\n        uint128 currentDelta = delta;\n        uint128 newDelta;\n        (\n            error,\n            newSpotPrice,\n            newDelta,\n            outputAmount,\n            protocolFee\n        ) = _bondingCurve.getSellInfo(\n            currentSpotPrice,\n            currentDelta,\n            numNFTs,\n            fee,\n            _factory.protocolFeeMultiplier()\n        );\n\n        // Revert if bonding curve had an error\n        if (error != CurveErrorCodes.Error.OK) {\n            revert BondingCurveError(error);\n        }\n\n        // Revert if output is too little\n        require(\n            outputAmount >= minExpectedTokenOutput,\n            \"Out too little tokens\"\n        );\n\n        // Consolidate writes to save gas\n        if (currentSpotPrice != newSpotPrice || currentDelta != newDelta) {\n            spotPrice = newSpotPrice;\n            delta = newDelta;\n        }\n\n        // Emit spot price update if it has been updated\n        if (currentSpotPrice != newSpotPrice) {\n            emit SpotPriceUpdate(newSpotPrice);\n        }\n\n        // Emit delta update if it has been updated\n        if (currentDelta != newDelta) {\n            emit DeltaUpdate(newDelta);\n        }\n    }\n\n    /**\n        @notice Pulls the token input of a trade from the trader and pays the protocol fee.\n        @param inputAmount The amount of tokens to be sent\n        @param isRouter Whether or not the caller is LSSVMRouter\n        @param routerCaller If called from LSSVMRouter, store the original caller\n        @param _factory The LSSVMPairFactory which stores LSSVMRouter allowlist info\n        @param protocolFee The protocol fee to be paid\n     */\n    function _pullTokenInputAndPayProtocolFee(\n        uint256 inputAmount,\n        bool isRouter,\n        address routerCaller,\n        ILSSVMPairFactoryLike _factory,\n        uint256 protocolFee\n    ) internal virtual;\n\n    /**\n        @notice Sends excess tokens back to the caller (if applicable)\n        @dev We send ETH back to the caller even when called from LSSVMRouter because we do an aggregate slippage check for certain bulk swaps. (Instead of sending directly back to the router caller) \n        Excess ETH sent for one swap can then be used to help pay for the next swap.\n     */\n    function _refundTokenToSender(uint256 inputAmount) internal virtual;\n\n    /**\n        @notice Sends protocol fee (if it exists) back to the LSSVMPairFactory from the pair\n     */\n    function _payProtocolFeeFromPair(\n        ILSSVMPairFactoryLike _factory,\n        uint256 protocolFee\n    ) internal virtual;\n\n    /**\n        @notice Sends tokens to a recipient\n        @param tokenRecipient The address receiving the tokens\n        @param outputAmount The amount of tokens to send\n     */\n    function _sendTokenOutput(\n        address payable tokenRecipient,\n        uint256 outputAmount\n    ) internal virtual;\n\n    /**\n        @notice Sends some number of NFTs to a recipient address, ID agnostic\n        @dev Even though we specify the NFT address here, this internal function is only \n        used to send NFTs associated with this specific pool.\n        @param _nft The address of the NFT to send\n        @param nftRecipient The receiving address for the NFTs\n        @param numNFTs The number of NFTs to send  \n     */\n    function _sendAnyNFTsToRecipient(\n        IERC721 _nft,\n        address nftRecipient,\n        uint256 numNFTs\n    ) internal virtual;\n\n    /**\n        @notice Sends specific NFTs to a recipient address\n        @dev Even though we specify the NFT address here, this internal function is only \n        used to send NFTs associated with this specific pool.\n        @param _nft The address of the NFT to send\n        @param nftRecipient The receiving address for the NFTs\n        @param nftIds The specific IDs of NFTs to send  \n     */\n    function _sendSpecificNFTsToRecipient(\n        IERC721 _nft,\n        address nftRecipient,\n        uint256[] calldata nftIds\n    ) internal virtual;\n\n    /**\n        @notice Takes NFTs from the caller and sends them into the pair's asset recipient\n        @dev This is used by the LSSVMPair's swapNFTForToken function. \n        @param _nft The NFT collection to take from\n        @param nftIds The specific NFT IDs to take\n        @param isRouter True if calling from LSSVMRouter, false otherwise. Not used for\n        ETH pairs.\n        @param routerCaller If isRouter is true, ERC20 tokens will be transferred from this address. Not used for\n        ETH pairs.\n     */\n    function _takeNFTsFromSender(\n        IERC721 _nft,\n        uint256[] calldata nftIds,\n        ILSSVMPairFactoryLike _factory,\n        bool isRouter,\n        address routerCaller\n    ) internal virtual {\n        {\n            address _assetRecipient = getAssetRecipient();\n            uint256 numNFTs = nftIds.length;\n\n            if (isRouter) {\n                // Verify if router is allowed\n                IRouter router = IRouter(payable(msg.sender));\n                (bool routerAllowed, ) = _factory.routerStatus(router);\n                require(routerAllowed, \"Not router\");\n\n                // Call router to pull NFTs\n                // If more than 1 NFT is being transfered, we can do a balance check instead of an ownership check, as pools are indifferent between NFTs from the same collection\n                if (numNFTs > 1) {\n                    uint256 beforeBalance = _nft.balanceOf(_assetRecipient);\n                    for (uint256 i = 0; i < numNFTs; ) {\n                        router.pairTransferNFTFrom(\n                            _nft,\n                            routerCaller,\n                            _assetRecipient,\n                            nftIds[i],\n                            pairVariant()\n                        );\n\n                        unchecked {\n                            ++i;\n                        }\n                    }\n                    require(\n                        (_nft.balanceOf(_assetRecipient) - beforeBalance) ==\n                            numNFTs,\n                        \"NFTs not transferred\"\n                    );\n                } else {\n                    router.pairTransferNFTFrom(\n                        _nft,\n                        routerCaller,\n                        _assetRecipient,\n                        nftIds[0],\n                        pairVariant()\n                    );\n                    require(\n                        _nft.ownerOf(nftIds[0]) == _assetRecipient,\n                        \"NFT not transferred\"\n                    );\n                }\n            } else {\n                // Pull NFTs directly from sender\n                for (uint256 i; i < numNFTs; ) {\n                    _nft.safeTransferFrom(\n                        msg.sender,\n                        _assetRecipient,\n                        nftIds[i]\n                    );\n\n                    unchecked {\n                        ++i;\n                    }\n                }\n            }\n        }\n    }\n\n    /**\n        @dev Used internally to grab pair parameters from calldata, see LSSVMPairCloner for technical details\n     */\n    function _immutableParamsLength() internal pure virtual returns (uint256);\n\n    /**\n     * Owner functions\n     */\n\n    /**\n        @notice Rescues a specified set of NFTs owned by the pair to the owner address. (onlyOwnable modifier is in the implemented function)\n        @dev If the NFT is the pair's collection, we also remove it from the id tracking (if the NFT is missing enumerable).\n        @param a The NFT to transfer\n        @param nftIds The list of IDs of the NFTs to send to the owner\n     */\n    function withdrawERC721(IERC721 a, uint256[] calldata nftIds)\n        external\n        virtual;\n\n    /**\n        @notice Rescues ERC20 tokens from the pair to the owner. Only callable by the owner (onlyOwnable modifier is in the implemented function).\n        @param a The token to transfer\n        @param amount The amount of tokens to send to the owner\n     */\n    function withdrawERC20(ERC20 a, uint256 amount) external virtual;\n\n    /**\n        @notice Rescues ERC1155 tokens from the pair to the owner. Only callable by the owner.\n        @param a The NFT to transfer\n        @param ids The NFT ids to transfer\n        @param amounts The amounts of each id to transfer\n     */\n    function withdrawERC1155(\n        IERC1155 a,\n        uint256[] calldata ids,\n        uint256[] calldata amounts\n    ) external virtual;\n\n    /**\n        @notice Updates the selling spot price. Only callable by the owner.\n        @param newSpotPrice The new selling spot price value, in Token\n     */\n    function changeSpotPrice(uint128 newSpotPrice) external virtual;\n\n    /**\n        @notice Updates the delta parameter. Only callable by the owner.\n        @param newDelta The new delta parameter\n     */\n    function changeDelta(uint128 newDelta) external virtual;\n\n    /**\n        @notice Updates the fee taken by the LP. Only callable by the owner.\n        Only callable if the pool is a Trade pool. Reverts if the fee is >=\n        MAX_FEE.\n        @param newFee The new LP fee percentage, 18 decimals\n     */\n    function changeFee(uint96 newFee) external onlyOwner {\n        PoolType _poolType = poolType();\n        require(_poolType == PoolType.TRADE, \"Only for Trade pools\");\n        require(newFee < MAX_FEE, \"Trade fee must be less than 90%\");\n        if (fee != newFee) {\n            fee = newFee;\n            emit FeeUpdate(newFee);\n        }\n    }\n\n    /**\n        @notice Changes the address that will receive assets received from\n        trades. Only callable by the owner.\n        @param newRecipient The new asset recipient\n     */\n    function changeAssetRecipient(address payable newRecipient)\n        external\n        onlyOwner\n    {\n        PoolType _poolType = poolType();\n        require(_poolType != PoolType.TRADE, \"Not for Trade pools\");\n        if (assetRecipient != newRecipient) {\n            assetRecipient = newRecipient;\n            emit AssetRecipientChange(newRecipient);\n        }\n    }\n\n    /**\n        @notice Allows the pair to make arbitrary external calls to contracts\n        whitelisted by the protocol. Only callable by the owner.\n        @param target The contract to call\n        @param data The calldata to pass to the contract\n     */\n    function call(address payable target, bytes calldata data)\n        external\n        onlyOwner\n    {\n        ILSSVMPairFactoryLike _factory = factory();\n        require(_factory.callAllowed(target), \"Target must be whitelisted\");\n        (bool result, ) = target.call{value: 0}(data);\n        require(result, \"Call failed\");\n    }\n\n    /**\n        @notice Allows owner to batch multiple calls, forked from: https://github.com/boringcrypto/BoringSolidity/blob/master/contracts/BoringBatchable.sol \n        @dev Intended for withdrawing/altering pool pricing in one tx, only callable by owner, cannot change owner\n        @param calls The calldata for each call to make\n        @param revertOnFail Whether or not to revert the entire tx if any of the calls fail\n     */\n    function multicall(bytes[] calldata calls, bool revertOnFail)\n        external\n        onlyOwner\n    {\n        for (uint256 i; i < calls.length; ) {\n            (bool success, bytes memory result) = address(this).delegatecall(\n                calls[i]\n            );\n            if (!success && revertOnFail) {\n                revert(_getRevertMsg(result));\n            }\n\n            unchecked {\n                ++i;\n            }\n        }\n\n        // Prevent multicall from malicious frontend sneaking in ownership change\n        require(\n            owner() == msg.sender,\n            \"Ownership cannot be changed in multicall\"\n        );\n    }\n\n    /**\n      @param _returnData The data returned from a multicall result\n      @dev Used to grab the revert string from the underlying call\n     */\n    function _getRevertMsg(bytes memory _returnData)\n        internal\n        pure\n        returns (string memory)\n    {\n        // If the _res length is less than 68, then the transaction failed silently (without a revert message)\n        if (_returnData.length < 68) return \"Transaction reverted silently\";\n\n        assembly {\n            // Slice the sighash.\n            _returnData := add(_returnData, 0x04)\n        }\n        return abi.decode(_returnData, (string)); // All that remains is the revert string\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastValue = set._values[lastIndex];\n\n                // Move the last value to the index where the value to delete is\n                set._values[toDeleteIndex] = lastValue;\n                // Update the index for the moved value\n                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n            }\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        bytes32[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"
    },
    "@openzeppelin/contracts/token/ERC721/IERC721.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes calldata data\n    ) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the caller.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool _approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
    },
    "contracts/src/bonding-curves/CurveErrorCodes.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\ncontract CurveErrorCodes {\n    enum Error {\n        OK, // No error\n        INVALID_NUMITEMS, // The numItem value is 0\n        SPOT_PRICE_OVERFLOW // The updated spot price doesn't fit into 128 bits\n    }\n}\n"
    },
    "contracts/src/lib/LSSVMPairCloner.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\nimport {ERC20} from \"../../lib/solmate/src/tokens/ERC20.sol\";\n\nimport {ICurve} from \"../bonding-curves/ICurve.sol\";\nimport {ILSSVMPairFactoryLike} from \"../ILSSVMPairFactoryLike.sol\";\n\nlibrary LSSVMPairCloner {\n    /**\n     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n     *\n     * This function uses the create opcode, which should never revert.\n     *\n     * During the delegate call, extra data is copied into the calldata which can then be\n     * accessed by the implementation contract.\n     */\n    function cloneETHPair(\n        address implementation,\n        ILSSVMPairFactoryLike factory,\n        ICurve bondingCurve,\n        IERC721 nft,\n        uint8 poolType\n    ) internal returns (address instance) {\n        assembly {\n            let ptr := mload(0x40)\n\n            // -------------------------------------------------------------------------------------------------------------\n            // CREATION (9 bytes)\n            // -------------------------------------------------------------------------------------------------------------\n\n            // creation size = 09\n            // runtime size = 72\n            // 60 runtime  | PUSH1 runtime (r)     | r                       | –\n            // 3d          | RETURNDATASIZE        | 0 r                     | –\n            // 81          | DUP2                  | r 0 r                   | –\n            // 60 creation | PUSH1 creation (c)    | c r 0 r                 | –\n            // 3d          | RETURNDATASIZE        | 0 c r 0 r               | –\n            // 39          | CODECOPY              | 0 r                     | [0-runSize): runtime code\n            // f3          | RETURN                |                         | [0-runSize): runtime code\n\n            // -------------------------------------------------------------------------------------------------------------\n            // RUNTIME (53 bytes of code + 61 bytes of extra data = 114 bytes)\n            // -------------------------------------------------------------------------------------------------------------\n\n            // extra data size = 3d\n            // 3d          | RETURNDATASIZE        | 0                       | –\n            // 3d          | RETURNDATASIZE        | 0 0                     | –\n            // 3d          | RETURNDATASIZE        | 0 0 0                   | –\n            // 3d          | RETURNDATASIZE        | 0 0 0 0                 | –\n            // 36          | CALLDATASIZE          | cds 0 0 0 0             | –\n            // 3d          | RETURNDATASIZE        | 0 cds 0 0 0 0           | –\n            // 3d          | RETURNDATASIZE        | 0 0 cds 0 0 0 0         | –\n            // 37          | CALLDATACOPY          | 0 0 0 0                 | [0, cds) = calldata\n            // 60 extra    | PUSH1 extra           | extra 0 0 0 0           | [0, cds) = calldata\n            // 60 0x35     | PUSH1 0x35            | 0x35 extra 0 0 0 0      | [0, cds) = calldata // 0x35 (53) is runtime size - data\n            // 36          | CALLDATASIZE          | cds 0x35 extra 0 0 0 0  | [0, cds) = calldata\n            // 39          | CODECOPY              | 0 0 0 0                 | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 36          | CALLDATASIZE          | cds 0 0 0 0             | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 60 extra    | PUSH1 extra           | extra cds 0 0 0 0       | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 01          | ADD                   | cds+extra 0 0 0 0       | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 3d          | RETURNDATASIZE        | 0 cds 0 0 0 0           | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 73 addr     | PUSH20 0x123…         | addr 0 cds 0 0 0 0      | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            mstore(\n                ptr,\n                hex\"60_72_3d_81_60_09_3d_39_f3_3d_3d_3d_3d_36_3d_3d_37_60_3d_60_35_36_39_36_60_3d_01_3d_73_00_00_00\"\n            )\n            mstore(add(ptr, 0x1d), shl(0x60, implementation))\n\n            // 5a          | GAS                   | gas addr 0 cds 0 0 0 0  | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // f4          | DELEGATECALL          | success 0 0             | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 3d          | RETURNDATASIZE        | rds success 0 0         | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 3d          | RETURNDATASIZE        | rds rds success 0 0     | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 93          | SWAP4                 | 0 rds success 0 rds     | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 80          | DUP1                  | 0 0 rds success 0 rds   | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 3e          | RETURNDATACOPY        | success 0 rds           | [0, rds) = return data (there might be some irrelevant leftovers in memory [rds, cds+0x37) when rds < cds+0x37)\n            // 60 0x33     | PUSH1 0x33            | 0x33 sucess 0 rds       | [0, rds) = return data\n            // 57          | JUMPI                 | 0 rds                   | [0, rds) = return data\n            // fd          | REVERT                | –                       | [0, rds) = return data\n            // 5b          | JUMPDEST              | 0 rds                   | [0, rds) = return data\n            // f3          | RETURN                | –                       | [0, rds) = return data\n            mstore(\n                add(ptr, 0x31),\n                hex\"5a_f4_3d_3d_93_80_3e_60_33_57_fd_5b_f3_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00\"\n            )\n\n            // -------------------------------------------------------------------------------------------------------------\n            // EXTRA DATA (61 bytes)\n            // -------------------------------------------------------------------------------------------------------------\n\n            mstore(add(ptr, 0x3e), shl(0x60, factory))\n            mstore(add(ptr, 0x52), shl(0x60, bondingCurve))\n            mstore(add(ptr, 0x66), shl(0x60, nft))\n            mstore8(add(ptr, 0x7a), poolType)\n\n            instance := create(0, ptr, 0x7b)\n        }\n    }\n\n    /**\n     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n     *\n     * This function uses the create opcode, which should never revert.\n     *\n     * During the delegate call, extra data is copied into the calldata which can then be\n     * accessed by the implementation contract.\n     */\n    function cloneERC20Pair(\n        address implementation,\n        ILSSVMPairFactoryLike factory,\n        ICurve bondingCurve,\n        IERC721 nft,\n        uint8 poolType,\n        ERC20 token,\n        bytes32 salt\n    ) internal returns (address instance) {\n        assembly {\n            let ptr := mload(0x40)\n\n            // -------------------------------------------------------------------------------------------------------------\n            // CREATION (9 bytes)\n            // -------------------------------------------------------------------------------------------------------------\n\n            // creation size = 09\n            // runtime size = 86\n            // 60 runtime  | PUSH1 runtime (r)     | r                       | –\n            // 3d          | RETURNDATASIZE        | 0 r                     | –\n            // 81          | DUP2                  | r 0 r                   | –\n            // 60 creation | PUSH1 creation (c)    | c r 0 r                 | –\n            // 3d          | RETURNDATASIZE        | 0 c r 0 r               | –\n            // 39          | CODECOPY              | 0 r                     | [0-runSize): runtime code\n            // f3          | RETURN                |                         | [0-runSize): runtime code\n\n            // -------------------------------------------------------------------------------------------------------------\n            // RUNTIME (53 bytes of code + 81 bytes of extra data = 134 bytes)\n            // -------------------------------------------------------------------------------------------------------------\n\n            // extra data size = 51\n            // 3d          | RETURNDATASIZE        | 0                       | –\n            // 3d          | RETURNDATASIZE        | 0 0                     | –\n            // 3d          | RETURNDATASIZE        | 0 0 0                   | –\n            // 3d          | RETURNDATASIZE        | 0 0 0 0                 | –\n            // 36          | CALLDATASIZE          | cds 0 0 0 0             | –\n            // 3d          | RETURNDATASIZE        | 0 cds 0 0 0 0           | –\n            // 3d          | RETURNDATASIZE        | 0 0 cds 0 0 0 0         | –\n            // 37          | CALLDATACOPY          | 0 0 0 0                 | [0, cds) = calldata\n            // 60 extra    | PUSH1 extra           | extra 0 0 0 0           | [0, cds) = calldata\n            // 60 0x35     | PUSH1 0x35            | 0x35 extra 0 0 0 0      | [0, cds) = calldata // 0x35 (53) is runtime size - data\n            // 36          | CALLDATASIZE          | cds 0x35 extra 0 0 0 0  | [0, cds) = calldata\n            // 39          | CODECOPY              | 0 0 0 0                 | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 36          | CALLDATASIZE          | cds 0 0 0 0             | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 60 extra    | PUSH1 extra           | extra cds 0 0 0 0       | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 01          | ADD                   | cds+extra 0 0 0 0       | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 3d          | RETURNDATASIZE        | 0 cds 0 0 0 0           | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 73 addr     | PUSH20 0x123…         | addr 0 cds 0 0 0 0      | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            mstore(\n                ptr,\n                hex\"60_86_3d_81_60_09_3d_39_f3_3d_3d_3d_3d_36_3d_3d_37_60_51_60_35_36_39_36_60_51_01_3d_73_00_00_00\"\n            )\n            mstore(add(ptr, 0x1d), shl(0x60, implementation))\n\n            // 5a          | GAS                   | gas addr 0 cds 0 0 0 0  | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // f4          | DELEGATECALL          | success 0 0             | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 3d          | RETURNDATASIZE        | rds success 0 0         | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 3d          | RETURNDATASIZE        | rds rds success 0 0     | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 93          | SWAP4                 | 0 rds success 0 rds     | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 80          | DUP1                  | 0 0 rds success 0 rds   | [0, cds) = calldata, [cds, cds+0x35) = extraData\n            // 3e          | RETURNDATACOPY        | success 0 rds           | [0, rds) = return data (there might be some irrelevant leftovers in memory [rds, cds+0x37) when rds < cds+0x37)\n            // 60 0x33     | PUSH1 0x33            | 0x33 sucess 0 rds       | [0, rds) = return data\n            // 57          | JUMPI                 | 0 rds                   | [0, rds) = return data\n            // fd          | REVERT                | –                       | [0, rds) = return data\n            // 5b          | JUMPDEST              | 0 rds                   | [0, rds) = return data\n            // f3          | RETURN                | –                       | [0, rds) = return data\n            mstore(\n                add(ptr, 0x31),\n                hex\"5a_f4_3d_3d_93_80_3e_60_33_57_fd_5b_f3_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00\"\n            )\n\n            // -------------------------------------------------------------------------------------------------------------\n            // EXTRA DATA (81 bytes)\n            // -------------------------------------------------------------------------------------------------------------\n\n            mstore(add(ptr, 0x3e), shl(0x60, factory))\n            mstore(add(ptr, 0x52), shl(0x60, bondingCurve))\n            mstore(add(ptr, 0x66), shl(0x60, nft))\n            mstore8(add(ptr, 0x7a), poolType)\n            mstore(add(ptr, 0x7b), shl(0x60, token))\n\n            instance := create2(0, ptr, 0x8f, salt)\n        }\n    }\n\n    /**\n     * @notice Checks if a contract is a clone of a LSSVMPairETH.\n     * @dev Only checks the runtime bytecode, does not check the extra data.\n     * @param factory the factory that deployed the clone\n     * @param implementation the LSSVMPairETH implementation contract\n     * @param query the contract to check\n     * @return result True if the contract is a clone, false otherwise\n     */\n    function isETHPairClone(\n        address factory,\n        address implementation,\n        address query\n    ) internal view returns (bool result) {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(\n                ptr,\n                hex\"3d_3d_3d_3d_36_3d_3d_37_60_3d_60_35_36_39_36_60_3d_01_3d_73_00_00_00_00_00_00_00_00_00_00_00_00\"\n            )\n            mstore(add(ptr, 0x14), shl(0x60, implementation))\n            mstore(\n                add(ptr, 0x28),\n                hex\"5a_f4_3d_3d_93_80_3e_60_33_57_fd_5b_f3_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00\"\n            )\n            mstore(add(ptr, 0x35), shl(0x60, factory))\n\n            // compare expected bytecode with that of the queried contract\n            let other := add(ptr, 0x49)\n            extcodecopy(query, other, 0, 0x49)\n            result := and(\n                eq(mload(ptr), mload(other)),\n                and(\n                    eq(mload(add(ptr, 0x20)), mload(add(other, 0x20))),\n                    eq(mload(add(ptr, 0x29)), mload(add(other, 0x29)))\n                )\n            )\n        }\n    }\n\n    /**\n     * @notice Checks if a contract is a clone of a LSSVMPairERC20.\n     * @dev Only checks the runtime bytecode, does not check the extra data.\n     * @param implementation the LSSVMPairERC20 implementation contract\n     * @param query the contract to check\n     * @return result True if the contract is a clone, false otherwise\n     */\n    function isERC20PairClone(\n        address factory,\n        address implementation,\n        address query\n    ) internal view returns (bool result) {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(\n                ptr,\n                hex\"3d_3d_3d_3d_36_3d_3d_37_60_51_60_35_36_39_36_60_51_01_3d_73_00_00_00_00_00_00_00_00_00_00_00_00\"\n            )\n            mstore(add(ptr, 0x14), shl(0x60, implementation))\n            mstore(\n                add(ptr, 0x28),\n                hex\"5a_f4_3d_3d_93_80_3e_60_33_57_fd_5b_f3_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00\"\n            )\n            mstore(add(ptr, 0x35), shl(0x60, factory))\n\n            // compare expected bytecode with that of the queried contract\n            let other := add(ptr, 0x49)\n            extcodecopy(query, other, 0, 0x49)\n            result := and(\n                eq(mload(ptr), mload(other)),\n                and(\n                    eq(mload(add(ptr, 0x20)), mload(add(other, 0x20))),\n                    eq(mload(add(ptr, 0x29)), mload(add(other, 0x29)))\n                )\n            )\n        }\n    }\n}\n"
    },
    "contracts/src/lib/ReentrancyGuard.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// Forked from OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol), \n// removed initializer check as we already do that in our modified Ownable\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    function __ReentrancyGuard_init() internal {\n      _status = _NOT_ENTERED;\n    } \n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        // On the first call to nonReentrant, _notEntered will be true\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n\n        _;\n\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n    /**\n     * @dev Returns the total amount of tokens stored by the contract.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n     */\n    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n     * Use along with {totalSupply} to enumerate all tokens.\n     */\n    function tokenByIndex(uint256 index) external view returns (uint256);\n}\n"
    },
    "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
    },
    "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/introspection/ERC165Checker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Library used to query support of an interface declared via {IERC165}.\n *\n * Note that these functions return the actual result of the query: they do not\n * `revert` if an interface is not supported. It is up to the caller to decide\n * what to do in these cases.\n */\nlibrary ERC165Checker {\n    // As per the EIP-165 spec, no interface should ever match 0xffffffff\n    bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\n\n    /**\n     * @dev Returns true if `account` supports the {IERC165} interface.\n     */\n    function supportsERC165(address account) internal view returns (bool) {\n        // Any contract that implements ERC165 must explicitly indicate support of\n        // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\n        return\n            supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&\n            !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);\n    }\n\n    /**\n     * @dev Returns true if `account` supports the interface defined by\n     * `interfaceId`. Support for {IERC165} itself is queried automatically.\n     *\n     * See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\n        // query support of both ERC165 as per the spec and support of _interfaceId\n        return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);\n    }\n\n    /**\n     * @dev Returns a boolean array where each value corresponds to the\n     * interfaces passed in and whether they're supported or not. This allows\n     * you to batch check interfaces for a contract where your expectation\n     * is that some interfaces may not be supported.\n     *\n     * See {IERC165-supportsInterface}.\n     *\n     * _Available since v3.4._\n     */\n    function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)\n        internal\n        view\n        returns (bool[] memory)\n    {\n        // an array of booleans corresponding to interfaceIds and whether they're supported or not\n        bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\n\n        // query support of ERC165 itself\n        if (supportsERC165(account)) {\n            // query support of each interface in interfaceIds\n            for (uint256 i = 0; i < interfaceIds.length; i++) {\n                interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);\n            }\n        }\n\n        return interfaceIdsSupported;\n    }\n\n    /**\n     * @dev Returns true if `account` supports all the interfaces defined in\n     * `interfaceIds`. Support for {IERC165} itself is queried automatically.\n     *\n     * Batch-querying can lead to gas savings by skipping repeated checks for\n     * {IERC165} support.\n     *\n     * See {IERC165-supportsInterface}.\n     */\n    function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\n        // query support of ERC165 itself\n        if (!supportsERC165(account)) {\n            return false;\n        }\n\n        // query support of each interface in interfaceIds\n        for (uint256 i = 0; i < interfaceIds.length; i++) {\n            if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {\n                return false;\n            }\n        }\n\n        // all interfaces supported\n        return true;\n    }\n\n    /**\n     * @notice Query if a contract implements an interface, does not check ERC165 support\n     * @param account The address of the contract to query for support of an interface\n     * @param interfaceId The interface identifier, as specified in ERC-165\n     * @return true if the contract at account indicates support of the interface with\n     * identifier interfaceId, false otherwise\n     * @dev Assumes that account contains a contract that supports ERC165, otherwise\n     * the behavior of this method is undefined. This precondition can be checked\n     * with {supportsERC165}.\n     * Interface identification is specified in ERC-165.\n     */\n    function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {\n        // prepare call\n        bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\n\n        // perform static call\n        bool success;\n        uint256 returnSize;\n        uint256 returnValue;\n        assembly {\n            success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)\n            returnSize := returndatasize()\n            returnValue := mload(0x00)\n        }\n\n        return success && returnSize >= 0x20 && returnValue > 0;\n    }\n}\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ERC1155Receiver.sol\";\n\n/**\n * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.\n *\n * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be\n * stuck.\n *\n * @dev _Available since v3.1._\n */\ncontract ERC1155Holder is ERC1155Receiver {\n    function onERC1155Received(\n        address,\n        address,\n        uint256,\n        uint256,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155Received.selector;\n    }\n\n    function onERC1155BatchReceived(\n        address,\n        address,\n        uint256[] memory,\n        uint256[] memory,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155BatchReceived.selector;\n    }\n}\n"
    },
    "contracts/src/lib/OwnableWithTransferCallback.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\n\npragma solidity ^0.8.4;\n\nimport {ERC165Checker} from \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\nimport {IOwnershipTransferCallback} from \"./IOwnershipTransferCallback.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\n\nabstract contract OwnableWithTransferCallback {\n    using ERC165Checker for address;\n    using Address for address;\n\n    bytes4 constant TRANSFER_CALLBACK =\n        type(IOwnershipTransferCallback).interfaceId;\n\n    error Ownable_NotOwner();\n    error Ownable_NewOwnerZeroAddress();\n\n    address private _owner;\n\n    event OwnershipTransferred(address indexed newOwner);\n\n    /// @dev Initializes the contract setting the deployer as the initial owner.\n    function __Ownable_init(address initialOwner) internal {\n        _owner = initialOwner;\n    }\n\n    /// @dev Returns the address of the current owner.\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /// @dev Throws if called by any account other than the owner.\n    modifier onlyOwner() {\n        if (owner() != msg.sender) revert Ownable_NotOwner();\n        _;\n    }\n\n    /// @dev Transfers ownership of the contract to a new account (`newOwner`).\n    /// Disallows setting to the zero address as a way to more gas-efficiently avoid reinitialization\n    /// When ownership is transferred, if the new owner implements IOwnershipTransferCallback, we make a callback\n    /// Can only be called by the current owner.\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) revert Ownable_NewOwnerZeroAddress();\n        _transferOwnership(newOwner);\n\n        // Call the on ownership transfer callback if it exists\n        // @dev try/catch is around 5k gas cheaper than doing ERC165 checking\n        if (newOwner.isContract()) {\n            try\n                IOwnershipTransferCallback(newOwner).onOwnershipTransfer(msg.sender)\n            {} catch (bytes memory) {}\n        }\n    }\n\n    /// @dev Transfers ownership of the contract to a new account (`newOwner`).\n    /// Internal function without access restriction.\n    function _transferOwnership(address newOwner) internal virtual {\n        _owner = newOwner;\n        emit OwnershipTransferred(newOwner);\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"
    },
    "contracts/src/lib/IOwnershipTransferCallback.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0\n\npragma solidity ^0.8.4;\n\ninterface IOwnershipTransferCallback {\n  function onOwnershipTransfer(address oldOwner) external;\n}"
    },
    "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC1155Receiver.sol\";\nimport \"../../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155Receiver is ERC165, IERC1155Receiver {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/introspection/ERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n    /**\n     * @dev Handles the receipt of a single ERC1155 token type. This function is\n     * called at the end of a `safeTransferFrom` after the balance has been updated.\n     *\n     * NOTE: To accept the transfer, this must return\n     * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n     * (i.e. 0xf23a6e61, or its own function selector).\n     *\n     * @param operator The address which initiated the transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param id The ID of the token being transferred\n     * @param value The amount of tokens being transferred\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n     */\n    function onERC1155Received(\n        address operator,\n        address from,\n        uint256 id,\n        uint256 value,\n        bytes calldata data\n    ) external returns (bytes4);\n\n    /**\n     * @dev Handles the receipt of a multiple ERC1155 token types. This function\n     * is called at the end of a `safeBatchTransferFrom` after the balances have\n     * been updated.\n     *\n     * NOTE: To accept the transfer(s), this must return\n     * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n     * (i.e. 0xbc197c81, or its own function selector).\n     *\n     * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param ids An array containing ids of each token being transferred (order and length must match values array)\n     * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n     */\n    function onERC1155BatchReceived(\n        address operator,\n        address from,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    }
  }
}