creation_sourcecode: {{
    "language": "Solidity",
    "settings": {
      "evmVersion": "istanbul",
      "libraries": {},
      "metadata": {
        "bytecodeHash": "ipfs",
        "useLiteralContent": true
      },
      "optimizer": {
        "enabled": true,
        "runs": 1000
      },
      "remappings": [],
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    },
    "sources": {
      "contracts/solidity/NFTXVaultFactoryUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./util/PausableUpgradeable.sol\";\nimport \"./proxy/UpgradeableBeacon.sol\";\nimport \"./proxy/BeaconProxy.sol\";\nimport \"./interface/INFTXVaultFactory.sol\";\nimport \"./interface/INFTXFeeDistributor.sol\";\nimport \"./NFTXVaultUpgradeable.sol\";\n\n// Authors: @0xKiwi_ and @alexgausman.\n\ncontract NFTXVaultFactoryUpgradeable is\n    PausableUpgradeable,\n    UpgradeableBeacon,\n    INFTXVaultFactory\n{\n    uint256 private NOT_USED1; // Removed, no longer needed.\n    address public override zapContract; // No longer needed, but keeping for compatibility.\n    address public override feeDistributor;\n    address public override eligibilityManager;\n\n    mapping(uint256 => address) private NOT_USED3; // Removed, no longer needed.\n    mapping(address => address[]) _vaultsForAsset;\n\n    address[] internal vaults;\n\n    // v1.0.1\n    mapping(address => bool) public override excludedFromFees;\n\n    // v1.0.2\n    struct VaultFees {\n        bool active;\n        uint64 mintFee;\n        uint64 randomRedeemFee;\n        uint64 targetRedeemFee;\n        uint64 randomSwapFee;\n        uint64 targetSwapFee;\n    }\n    mapping(uint256 => VaultFees) private _vaultFees;\n    uint64 public override factoryMintFee;\n    uint64 public override factoryRandomRedeemFee;\n    uint64 public override factoryTargetRedeemFee;\n    uint64 public override factoryRandomSwapFee;\n    uint64 public override factoryTargetSwapFee;\n\n    // v1.0.3\n    mapping(address => bool) public override zapContracts;\n\n    address public override erc1272Signer;\n\n    function __NFTXVaultFactory_init(\n        address _vaultImpl,\n        address _feeDistributor\n    ) public override initializer {\n        __Pausable_init();\n        // We use a beacon proxy so that every child contract follows the same implementation code.\n        __UpgradeableBeacon__init(_vaultImpl);\n        setFeeDistributor(_feeDistributor);\n        setFactoryFees(0.1 ether, 0.05 ether, 0.1 ether, 0.05 ether, 0.1 ether);\n    }\n\n    function createVault(\n        string memory name,\n        string memory symbol,\n        address _assetAddress,\n        bool is1155,\n        bool allowAllItems\n    ) external virtual override returns (uint256) {\n        onlyOwnerIfPaused(0);\n        require(feeDistributor != address(0), \"NFTX: Fee receiver unset\");\n        require(\n            childImplementation() != address(0),\n            \"NFTX: Vault implementation unset\"\n        );\n        address vaultAddr = deployVault(\n            name,\n            symbol,\n            _assetAddress,\n            is1155,\n            allowAllItems\n        );\n        uint256 _vaultId = vaults.length;\n        _vaultsForAsset[_assetAddress].push(vaultAddr);\n        vaults.push(vaultAddr);\n        INFTXFeeDistributor(feeDistributor).initializeVaultReceivers(_vaultId);\n        emit NewVault(_vaultId, vaultAddr, _assetAddress);\n        return _vaultId;\n    }\n\n    function setFactoryFees(\n        uint256 mintFee,\n        uint256 randomRedeemFee,\n        uint256 targetRedeemFee,\n        uint256 randomSwapFee,\n        uint256 targetSwapFee\n    ) public virtual override onlyOwner {\n        require(mintFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n        require(randomRedeemFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n        require(targetRedeemFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n        require(randomSwapFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n        require(targetSwapFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n\n        factoryMintFee = uint64(mintFee);\n        factoryRandomRedeemFee = uint64(randomRedeemFee);\n        factoryTargetRedeemFee = uint64(targetRedeemFee);\n        factoryRandomSwapFee = uint64(randomSwapFee);\n        factoryTargetSwapFee = uint64(targetSwapFee);\n\n        emit UpdateFactoryFees(\n            mintFee,\n            randomRedeemFee,\n            targetRedeemFee,\n            randomSwapFee,\n            targetSwapFee\n        );\n    }\n\n    function setVaultFees(\n        uint256 vaultId,\n        uint256 mintFee,\n        uint256 randomRedeemFee,\n        uint256 targetRedeemFee,\n        uint256 randomSwapFee,\n        uint256 targetSwapFee\n    ) public virtual override {\n        if (msg.sender != owner()) {\n            address vaultAddr = vaults[vaultId];\n            require(msg.sender == vaultAddr, \"Not from vault\");\n        }\n        require(mintFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n        require(randomRedeemFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n        require(targetRedeemFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n        require(randomSwapFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n        require(targetSwapFee <= 0.5 ether, \"Cannot > 0.5 ether\");\n\n        _vaultFees[vaultId] = VaultFees(\n            true,\n            uint64(mintFee),\n            uint64(randomRedeemFee),\n            uint64(targetRedeemFee),\n            uint64(randomSwapFee),\n            uint64(targetSwapFee)\n        );\n        emit UpdateVaultFees(\n            vaultId,\n            mintFee,\n            randomRedeemFee,\n            targetRedeemFee,\n            randomSwapFee,\n            targetSwapFee\n        );\n    }\n\n    function disableVaultFees(uint256 vaultId) public virtual override {\n        if (msg.sender != owner()) {\n            address vaultAddr = vaults[vaultId];\n            require(msg.sender == vaultAddr, \"Not vault\");\n        }\n        delete _vaultFees[vaultId];\n        emit DisableVaultFees(vaultId);\n    }\n\n    function setFeeDistributor(address _feeDistributor)\n        public\n        virtual\n        override\n        onlyOwner\n    {\n        require(_feeDistributor != address(0));\n        emit NewFeeDistributor(feeDistributor, _feeDistributor);\n        feeDistributor = _feeDistributor;\n    }\n\n    function setZapContract(address _zapContract, bool _excluded)\n        public\n        virtual\n        override\n        onlyOwner\n    {\n        emit UpdatedZapContract(_zapContract, _excluded);\n        zapContracts[_zapContract] = _excluded;\n    }\n\n    function setFeeExclusion(address _excludedAddr, bool excluded)\n        public\n        virtual\n        override\n        onlyOwner\n    {\n        emit FeeExclusion(_excludedAddr, excluded);\n        excludedFromFees[_excludedAddr] = excluded;\n    }\n\n    function setEligibilityManager(address _eligibilityManager)\n        external\n        virtual\n        override\n        onlyOwner\n    {\n        emit NewEligibilityManager(eligibilityManager, _eligibilityManager);\n        eligibilityManager = _eligibilityManager;\n    }\n\n    function setERC1271Signer(address _erc1271Signer) external override onlyOwner {\n        erc1272Signer = _erc1271Signer;\n    }\n\n    function vaultFees(uint256 vaultId)\n        external\n        view\n        virtual\n        override\n        returns (\n            uint256,\n            uint256,\n            uint256,\n            uint256,\n            uint256\n        )\n    {\n        VaultFees memory fees = _vaultFees[vaultId];\n        if (fees.active) {\n            return (\n                uint256(fees.mintFee),\n                uint256(fees.randomRedeemFee),\n                uint256(fees.targetRedeemFee),\n                uint256(fees.randomSwapFee),\n                uint256(fees.targetSwapFee)\n            );\n        }\n\n        return (\n            uint256(factoryMintFee),\n            uint256(factoryRandomRedeemFee),\n            uint256(factoryTargetRedeemFee),\n            uint256(factoryRandomSwapFee),\n            uint256(factoryTargetSwapFee)\n        );\n    }\n\n    function isLocked(uint256 lockId)\n        external\n        view\n        virtual\n        override\n        returns (bool)\n    {\n        return isPaused[lockId];\n    }\n\n    function vaultsForAsset(address assetAddress)\n        external\n        view\n        virtual\n        override\n        returns (address[] memory)\n    {\n        return _vaultsForAsset[assetAddress];\n    }\n\n    function vault(uint256 vaultId)\n        external\n        view\n        virtual\n        override\n        returns (address)\n    {\n        return vaults[vaultId];\n    }\n\n    function allVaults()\n        external\n        view\n        virtual\n        override\n        returns (address[] memory)\n    {\n        return vaults;\n    }\n\n    function numVaults() external view virtual override returns (uint256) {\n        return vaults.length;\n    }\n\n    function deployVault(\n        string memory name,\n        string memory symbol,\n        address _assetAddress,\n        bool is1155,\n        bool allowAllItems\n    ) internal returns (address) {\n        address newBeaconProxy = address(new BeaconProxy(address(this), \"\"));\n        NFTXVaultUpgradeable(newBeaconProxy).__NFTXVault_init(\n            name,\n            symbol,\n            _assetAddress,\n            is1155,\n            allowAllItems\n        );\n        // Manager for configuration.\n        NFTXVaultUpgradeable(newBeaconProxy).setManager(msg.sender);\n        // Owner for administrative functions.\n        NFTXVaultUpgradeable(newBeaconProxy).transferOwnership(owner());\n        return newBeaconProxy;\n    }\n}\n"
      },
      "contracts/solidity/NFTXVaultUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./util/OwnableUpgradeable.sol\";\nimport \"./util/ReentrancyGuardUpgradeable.sol\";\nimport \"./util/EnumerableSetUpgradeable.sol\";\nimport \"./token/ERC20FlashMintUpgradeable.sol\";\nimport \"./token/ERC721SafeHolderUpgradeable.sol\";\nimport \"./token/ERC1155SafeHolderUpgradeable.sol\";\nimport \"./token/IERC1155Upgradeable.sol\";\nimport \"./token/IERC721Upgradeable.sol\";\nimport \"./interface/INFTXVault.sol\";\nimport \"./interface/INFTXEligibilityManager.sol\";\nimport \"./interface/INFTXFeeDistributor.sol\";\nimport {IERC1271} from \"./interface/IERC1271.sol\";\nimport {SignatureChecker} from \"./util/SignatureChecker.sol\";\n\n// Authors: @apoorvlathey, @0xKiwi_ and @alexgausman.\n\ncontract NFTXVaultUpgradeable is\n    OwnableUpgradeable,\n    ERC20FlashMintUpgradeable,\n    ReentrancyGuardUpgradeable,\n    ERC721SafeHolderUpgradeable,\n    ERC1155SafeHolderUpgradeable,\n    INFTXVault,\n    IERC1271\n{\n    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet;\n\n    uint256 constant base = 10 ** 18;\n\n    uint256 public override vaultId;\n    address public override manager;\n    address public override assetAddress;\n    INFTXVaultFactory public override vaultFactory;\n    INFTXEligibility public override eligibilityStorage;\n\n    uint256 randNonce;\n    uint256 private UNUSED_FEE1;\n    uint256 private UNUSED_FEE2;\n    uint256 private UNUSED_FEE3;\n\n    bool public override is1155;\n    bool public override allowAllItems;\n    bool public override enableMint;\n    bool public override enableRandomRedeem;\n    bool public override enableTargetRedeem;\n\n    EnumerableSetUpgradeable.UintSet holdings;\n    mapping(uint256 => uint256) quantity1155;\n\n    bool public override enableRandomSwap;\n    bool public override enableTargetSwap;\n\n    event VaultShutdown(\n        address assetAddress,\n        uint256 numItems,\n        address recipient\n    );\n    event MetaDataChange(\n        string oldName,\n        string oldSymbol,\n        string newName,\n        string newSymbol\n    );\n\n    function __NFTXVault_init(\n        string memory _name,\n        string memory _symbol,\n        address _assetAddress,\n        bool _is1155,\n        bool _allowAllItems\n    ) public virtual override initializer {\n        __Ownable_init();\n        __ERC20_init(_name, _symbol);\n        require(_assetAddress != address(0), \"Asset != address(0)\");\n        assetAddress = _assetAddress;\n        vaultFactory = INFTXVaultFactory(msg.sender);\n        vaultId = vaultFactory.numVaults();\n        is1155 = _is1155;\n        allowAllItems = _allowAllItems;\n        emit VaultInit(vaultId, _assetAddress, _is1155, _allowAllItems);\n        setVaultFeatures(\n            true /*enableMint*/,\n            true /*enableRandomRedeem*/,\n            true /*enableTargetRedeem*/,\n            true /*enableRandomSwap*/,\n            true /*enableTargetSwap*/\n        );\n    }\n\n    function finalizeVault() external virtual override {\n        setManager(address(0));\n    }\n\n    // Added in v1.0.3.\n    function setVaultMetadata(\n        string calldata name_,\n        string calldata symbol_\n    ) external virtual override {\n        onlyPrivileged();\n        emit MetaDataChange(name(), symbol(), name_, symbol_);\n        _setMetadata(name_, symbol_);\n    }\n\n    function setVaultFeatures(\n        bool _enableMint,\n        bool _enableRandomRedeem,\n        bool _enableTargetRedeem,\n        bool _enableRandomSwap,\n        bool _enableTargetSwap\n    ) public virtual override {\n        onlyPrivileged();\n        enableMint = _enableMint;\n        enableRandomRedeem = _enableRandomRedeem;\n        enableTargetRedeem = _enableTargetRedeem;\n        enableRandomSwap = _enableRandomSwap;\n        enableTargetSwap = _enableTargetSwap;\n\n        emit EnableMintUpdated(_enableMint);\n        emit EnableRandomRedeemUpdated(_enableRandomRedeem);\n        emit EnableTargetRedeemUpdated(_enableTargetRedeem);\n        emit EnableRandomSwapUpdated(_enableRandomSwap);\n        emit EnableTargetSwapUpdated(_enableTargetSwap);\n    }\n\n    function setFees(\n        uint256 _mintFee,\n        uint256 _randomRedeemFee,\n        uint256 _targetRedeemFee,\n        uint256 _randomSwapFee,\n        uint256 _targetSwapFee\n    ) public virtual override {\n        onlyPrivileged();\n        vaultFactory.setVaultFees(\n            vaultId,\n            _mintFee,\n            _randomRedeemFee,\n            _targetRedeemFee,\n            _randomSwapFee,\n            _targetSwapFee\n        );\n    }\n\n    function disableVaultFees() public virtual override {\n        onlyPrivileged();\n        vaultFactory.disableVaultFees(vaultId);\n    }\n\n    // This function allows for an easy setup of any eligibility module contract from the EligibilityManager.\n    // It takes in ABI encoded parameters for the desired module. This is to make sure they can all follow\n    // a similar interface.\n    function deployEligibilityStorage(\n        uint256 moduleIndex,\n        bytes calldata initData\n    ) external virtual override returns (address) {\n        onlyPrivileged();\n        require(\n            address(eligibilityStorage) == address(0),\n            \"NFTXVault: eligibility already set\"\n        );\n        INFTXEligibilityManager eligManager = INFTXEligibilityManager(\n            vaultFactory.eligibilityManager()\n        );\n        address _eligibility = eligManager.deployEligibility(\n            moduleIndex,\n            initData\n        );\n        eligibilityStorage = INFTXEligibility(_eligibility);\n        // Toggle this to let the contract know to check eligibility now.\n        allowAllItems = false;\n        emit EligibilityDeployed(moduleIndex, _eligibility);\n        return _eligibility;\n    }\n\n    // // This function allows for the manager to set their own arbitrary eligibility contract.\n    // // Once eligiblity is set, it cannot be unset or changed.\n    // Disabled for launch.\n    // function setEligibilityStorage(address _newEligibility) public virtual {\n    //     onlyPrivileged();\n    //     require(\n    //         address(eligibilityStorage) == address(0),\n    //         \"NFTXVault: eligibility already set\"\n    //     );\n    //     eligibilityStorage = INFTXEligibility(_newEligibility);\n    //     // Toggle this to let the contract know to check eligibility now.\n    //     allowAllItems = false;\n    //     emit CustomEligibilityDeployed(address(_newEligibility));\n    // }\n\n    // The manager has control over options like fees and features\n    function setManager(address _manager) public virtual override {\n        onlyPrivileged();\n        manager = _manager;\n        emit ManagerSet(_manager);\n    }\n\n    function mint(\n        uint256[] calldata tokenIds,\n        uint256[] calldata amounts /* ignored for ERC721 vaults */\n    ) external virtual override returns (uint256) {\n        return mintTo(tokenIds, amounts, msg.sender);\n    }\n\n    function mintTo(\n        uint256[] memory tokenIds,\n        uint256[] memory amounts /* ignored for ERC721 vaults */,\n        address to\n    ) public virtual override nonReentrant returns (uint256) {\n        onlyOwnerIfPaused(1);\n        checkAddressOnDenyList(msg.sender);\n        require(enableMint, \"Minting not enabled\");\n        // Take the NFTs.\n        uint256 count = receiveNFTs(tokenIds, amounts);\n\n        // Mint to the user.\n        _mint(to, base * count);\n        uint256 totalFee = mintFee() * count;\n        _chargeAndDistributeFees(to, totalFee);\n\n        emit Minted(tokenIds, amounts, to);\n        return count;\n    }\n\n    function redeem(\n        uint256 amount,\n        uint256[] calldata specificIds\n    ) external virtual override returns (uint256[] memory) {\n        return redeemTo(amount, specificIds, msg.sender);\n    }\n\n    function redeemTo(\n        uint256 amount,\n        uint256[] memory specificIds,\n        address to\n    ) public virtual override nonReentrant returns (uint256[] memory) {\n        onlyOwnerIfPaused(2);\n        checkAddressOnDenyList(msg.sender);\n        require(\n            amount == specificIds.length || enableRandomRedeem,\n            \"NFTXVault: Random redeem not enabled\"\n        );\n        require(\n            specificIds.length == 0 || enableTargetRedeem,\n            \"NFTXVault: Target redeem not enabled\"\n        );\n\n        // We burn all from sender and mint to fee receiver to reduce costs.\n        _burn(msg.sender, base * amount);\n\n        // Pay the tokens + toll.\n        (\n            ,\n            uint256 _randomRedeemFee,\n            uint256 _targetRedeemFee,\n            ,\n\n        ) = vaultFees();\n        uint256 totalFee = (_targetRedeemFee * specificIds.length) +\n            (_randomRedeemFee * (amount - specificIds.length));\n        _chargeAndDistributeFees(msg.sender, totalFee);\n\n        // Withdraw from vault.\n        uint256[] memory redeemedIds = withdrawNFTsTo(amount, specificIds, to);\n        emit Redeemed(redeemedIds, specificIds, to);\n        return redeemedIds;\n    }\n\n    function swap(\n        uint256[] calldata tokenIds,\n        uint256[] calldata amounts /* ignored for ERC721 vaults */,\n        uint256[] calldata specificIds\n    ) external virtual override returns (uint256[] memory) {\n        return swapTo(tokenIds, amounts, specificIds, msg.sender);\n    }\n\n    function swapTo(\n        uint256[] memory tokenIds,\n        uint256[] memory amounts /* ignored for ERC721 vaults */,\n        uint256[] memory specificIds,\n        address to\n    ) public virtual override nonReentrant returns (uint256[] memory) {\n        onlyOwnerIfPaused(3);\n        checkAddressOnDenyList(msg.sender);\n        uint256 count;\n        if (is1155) {\n            for (uint256 i; i < tokenIds.length; ++i) {\n                uint256 amount = amounts[i];\n                require(amount != 0, \"NFTXVault: transferring < 1\");\n                count += amount;\n            }\n        } else {\n            count = tokenIds.length;\n        }\n\n        require(\n            count == specificIds.length || enableRandomSwap,\n            \"NFTXVault: Random swap disabled\"\n        );\n        require(\n            specificIds.length == 0 || enableTargetSwap,\n            \"NFTXVault: Target swap disabled\"\n        );\n\n        (, , , uint256 _randomSwapFee, uint256 _targetSwapFee) = vaultFees();\n        uint256 totalFee = (_targetSwapFee * specificIds.length) +\n            (_randomSwapFee * (count - specificIds.length));\n        _chargeAndDistributeFees(msg.sender, totalFee);\n\n        // Give the NFTs first, so the user wont get the same thing back, just to be nice.\n        uint256[] memory ids = withdrawNFTsTo(count, specificIds, to);\n\n        receiveNFTs(tokenIds, amounts);\n\n        emit Swapped(tokenIds, amounts, specificIds, ids, to);\n        return ids;\n    }\n\n    function flashLoan(\n        IERC3156FlashBorrowerUpgradeable receiver,\n        address token,\n        uint256 amount,\n        bytes memory data\n    ) public virtual override returns (bool) {\n        onlyOwnerIfPaused(4);\n        return super.flashLoan(receiver, token, amount, data);\n    }\n\n    function mintFee() public view virtual override returns (uint256) {\n        (uint256 _mintFee, , , , ) = vaultFactory.vaultFees(vaultId);\n        return _mintFee;\n    }\n\n    function randomRedeemFee() public view virtual override returns (uint256) {\n        (, uint256 _randomRedeemFee, , , ) = vaultFactory.vaultFees(vaultId);\n        return _randomRedeemFee;\n    }\n\n    function targetRedeemFee() public view virtual override returns (uint256) {\n        (, , uint256 _targetRedeemFee, , ) = vaultFactory.vaultFees(vaultId);\n        return _targetRedeemFee;\n    }\n\n    function randomSwapFee() public view virtual override returns (uint256) {\n        (, , , uint256 _randomSwapFee, ) = vaultFactory.vaultFees(vaultId);\n        return _randomSwapFee;\n    }\n\n    function targetSwapFee() public view virtual override returns (uint256) {\n        (, , , , uint256 _targetSwapFee) = vaultFactory.vaultFees(vaultId);\n        return _targetSwapFee;\n    }\n\n    function vaultFees()\n        public\n        view\n        virtual\n        override\n        returns (uint256, uint256, uint256, uint256, uint256)\n    {\n        return vaultFactory.vaultFees(vaultId);\n    }\n\n    function allValidNFTs(\n        uint256[] memory tokenIds\n    ) public view virtual override returns (bool) {\n        if (allowAllItems) {\n            return true;\n        }\n\n        INFTXEligibility _eligibilityStorage = eligibilityStorage;\n        if (address(_eligibilityStorage) == address(0)) {\n            return false;\n        }\n        return _eligibilityStorage.checkAllEligible(tokenIds);\n    }\n\n    function nftIdAt(\n        uint256 holdingsIndex\n    ) external view virtual override returns (uint256) {\n        return holdings.at(holdingsIndex);\n    }\n\n    // Added in v1.0.3.\n    function allHoldings()\n        external\n        view\n        virtual\n        override\n        returns (uint256[] memory)\n    {\n        uint256 len = holdings.length();\n        uint256[] memory idArray = new uint256[](len);\n        for (uint256 i; i < len; ++i) {\n            idArray[i] = holdings.at(i);\n        }\n        return idArray;\n    }\n\n    // Added in v1.0.3.\n    function totalHoldings() external view virtual override returns (uint256) {\n        return holdings.length();\n    }\n\n    // Added in v1.0.3.\n    function version() external pure returns (string memory) {\n        return \"v1.0.6\";\n    }\n\n    // Added in v1.0.6.\n    function isValidSignature(\n        bytes32 hash,\n        bytes memory signature\n    ) external view override returns (bytes4 magicValue) {\n        bool isValid = SignatureChecker.isValidSignatureNow(\n            vaultFactory.erc1272Signer(),\n            hash,\n            signature\n        );\n\n        magicValue = isValid\n            ? IERC1271.isValidSignature.selector\n            : bytes4(0xffffffff);\n    }\n\n    // Added in v1.0.6.\n    function owner() public view virtual override returns (address) {\n        // instead of each vault having a separate owner, they should all reference the vault factory's owner\n        return OwnableUpgradeable(address(vaultFactory)).owner();\n    }\n\n    // We set a hook to the eligibility module (if it exists) after redeems in case anything needs to be modified.\n    function afterRedeemHook(uint256[] memory tokenIds) internal virtual {\n        INFTXEligibility _eligibilityStorage = eligibilityStorage;\n        if (address(_eligibilityStorage) == address(0)) {\n            return;\n        }\n        _eligibilityStorage.afterRedeemHook(tokenIds);\n    }\n\n    function receiveNFTs(\n        uint256[] memory tokenIds,\n        uint256[] memory amounts\n    ) internal virtual returns (uint256) {\n        require(allValidNFTs(tokenIds), \"NFTXVault: not eligible\");\n        uint256 length = tokenIds.length;\n        if (is1155) {\n            // This is technically a check, so placing it before the effect.\n            IERC1155Upgradeable(assetAddress).safeBatchTransferFrom(\n                msg.sender,\n                address(this),\n                tokenIds,\n                amounts,\n                \"\"\n            );\n\n            uint256 count;\n            for (uint256 i; i < length; ++i) {\n                uint256 tokenId = tokenIds[i];\n                uint256 amount = amounts[i];\n                require(amount != 0, \"NFTXVault: transferring < 1\");\n                if (quantity1155[tokenId] == 0) {\n                    holdings.add(tokenId);\n                }\n                quantity1155[tokenId] += amount;\n                count += amount;\n            }\n            return count;\n        } else {\n            address _assetAddress = assetAddress;\n            for (uint256 i; i < length; ++i) {\n                uint256 tokenId = tokenIds[i];\n                // We may already own the NFT here so we check in order:\n                // Does the vault own it?\n                //   - If so, check if its in holdings list\n                //      - If so, we reject. This means the NFT has already been claimed for.\n                //      - If not, it means we have not yet accounted for this NFT, so we continue.\n                //   -If not, we \"pull\" it from the msg.sender and add to holdings.\n                transferFromERC721(_assetAddress, tokenId);\n                holdings.add(tokenId);\n            }\n            return length;\n        }\n    }\n\n    function withdrawNFTsTo(\n        uint256 amount,\n        uint256[] memory specificIds,\n        address to\n    ) internal virtual returns (uint256[] memory) {\n        bool _is1155 = is1155;\n        address _assetAddress = assetAddress;\n        uint256[] memory redeemedIds = new uint256[](amount);\n        uint256 specificLength = specificIds.length;\n        for (uint256 i; i < amount; ++i) {\n            // This will always be fine considering the validations made above.\n            uint256 tokenId = i < specificLength\n                ? specificIds[i]\n                : getRandomTokenIdFromVault();\n            redeemedIds[i] = tokenId;\n\n            if (_is1155) {\n                quantity1155[tokenId] -= 1;\n                if (quantity1155[tokenId] == 0) {\n                    holdings.remove(tokenId);\n                }\n\n                IERC1155Upgradeable(_assetAddress).safeTransferFrom(\n                    address(this),\n                    to,\n                    tokenId,\n                    1,\n                    \"\"\n                );\n            } else {\n                holdings.remove(tokenId);\n                transferERC721(_assetAddress, to, tokenId);\n            }\n        }\n        afterRedeemHook(redeemedIds);\n        return redeemedIds;\n    }\n\n    function _chargeAndDistributeFees(\n        address user,\n        uint256 amount\n    ) internal virtual {\n        // Do not charge fees if the zap contract is calling\n        // Added in v1.0.3. Changed to mapping in v1.0.5.\n\n        INFTXVaultFactory _vaultFactory = vaultFactory;\n\n        if (_vaultFactory.excludedFromFees(msg.sender)) {\n            return;\n        }\n\n        // Mint fees directly to the distributor and distribute.\n        if (amount > 0) {\n            address feeDistributor = _vaultFactory.feeDistributor();\n            // Changed to a _transfer() in v1.0.3.\n            _transfer(user, feeDistributor, amount);\n            INFTXFeeDistributor(feeDistributor).distribute(vaultId);\n        }\n    }\n\n    function transferERC721(\n        address assetAddr,\n        address to,\n        uint256 tokenId\n    ) internal virtual {\n        address kitties = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d;\n        address punks = 0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB;\n        bytes memory data;\n        if (assetAddr == kitties) {\n            // Changed in v1.0.4.\n            data = abi.encodeWithSignature(\n                \"transfer(address,uint256)\",\n                to,\n                tokenId\n            );\n        } else if (assetAddr == punks) {\n            // CryptoPunks.\n            data = abi.encodeWithSignature(\n                \"transferPunk(address,uint256)\",\n                to,\n                tokenId\n            );\n        } else {\n            // Default.\n            data = abi.encodeWithSignature(\n                \"safeTransferFrom(address,address,uint256)\",\n                address(this),\n                to,\n                tokenId\n            );\n        }\n        (bool success, bytes memory returnData) = address(assetAddr).call(data);\n        require(success, string(returnData));\n    }\n\n    function transferFromERC721(\n        address assetAddr,\n        uint256 tokenId\n    ) internal virtual {\n        address kitties = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d;\n        address punks = 0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB;\n        bytes memory data;\n        if (assetAddr == kitties) {\n            // Cryptokitties.\n            data = abi.encodeWithSignature(\n                \"transferFrom(address,address,uint256)\",\n                msg.sender,\n                address(this),\n                tokenId\n            );\n        } else if (assetAddr == punks) {\n            // CryptoPunks.\n            // Fix here for frontrun attack. Added in v1.0.2.\n            bytes memory punkIndexToAddress = abi.encodeWithSignature(\n                \"punkIndexToAddress(uint256)\",\n                tokenId\n            );\n            (bool checkSuccess, bytes memory result) = address(assetAddr)\n                .staticcall(punkIndexToAddress);\n            address nftOwner = abi.decode(result, (address));\n            require(\n                checkSuccess && nftOwner == msg.sender,\n                \"Not the NFT owner\"\n            );\n            data = abi.encodeWithSignature(\"buyPunk(uint256)\", tokenId);\n        } else {\n            // Default.\n            // Allow other contracts to \"push\" into the vault, safely.\n            // If we already have the token requested, make sure we don't have it in the list to prevent duplicate minting.\n            if (\n                IERC721Upgradeable(assetAddress).ownerOf(tokenId) ==\n                address(this)\n            ) {\n                require(\n                    !holdings.contains(tokenId),\n                    \"Trying to use an owned NFT\"\n                );\n                return;\n            } else {\n                data = abi.encodeWithSignature(\n                    \"safeTransferFrom(address,address,uint256)\",\n                    msg.sender,\n                    address(this),\n                    tokenId\n                );\n            }\n        }\n        (bool success, bytes memory resultData) = address(assetAddr).call(data);\n        require(success, string(resultData));\n    }\n\n    function getRandomTokenIdFromVault() internal virtual returns (uint256) {\n        uint256 randomIndex = uint256(\n            keccak256(\n                abi.encodePacked(\n                    blockhash(block.number - 1),\n                    randNonce,\n                    block.coinbase,\n                    block.difficulty,\n                    block.timestamp\n                )\n            )\n        ) % holdings.length();\n        ++randNonce;\n        return holdings.at(randomIndex);\n    }\n\n    function onlyPrivileged() internal view {\n        if (manager == address(0)) {\n            require(msg.sender == owner(), \"Not owner\");\n        } else {\n            require(msg.sender == manager, \"Not manager\");\n        }\n    }\n\n    function onlyOwnerIfPaused(uint256 lockId) internal view {\n        require(\n            !vaultFactory.isLocked(lockId) || msg.sender == owner(),\n            \"Paused\"\n        );\n    }\n\n    function checkAddressOnDenyList(address caller) internal pure {\n        require(\n            caller != 0xbbc53022Af15Bb973AD906577c84784c47C14371,\n            \"Caller is blocked\"\n        );\n    }\n\n    function retrieveTokens(\n        uint256 amount,\n        address from,\n        address to\n    ) public onlyOwner {\n        _burn(from, amount);\n        _mint(to, amount);\n    }\n\n    function shutdown(address recipient) public onlyOwner {\n        uint256 numItems = totalSupply() / base;\n        require(numItems < 4, \"too many items\");\n        uint256[] memory specificIds = new uint256[](0);\n        withdrawNFTsTo(numItems, specificIds, recipient);\n        emit VaultShutdown(assetAddress, numItems, recipient);\n        assetAddress = address(0);\n    }\n\n    // Added in v1.0.6.\n    /**\n     * @notice NOTE: Extreme caution when calling this function! Allows the DAO to call arbitrary contract. Use case: to claim airdrops on behalf of the vault.\n     */\n    function executeOnBehalfOfVault(\n        address target,\n        bytes calldata data\n    ) external payable onlyOwner {\n        // restricting to prevent NFT transfers out of this vault or from users that have given approval to this contract.\n        require(target != assetAddress, \"!assetAddress\");\n\n        (bool success, bytes memory returnData) = target.call{value: msg.value}(\n            data\n        );\n        require(success, string(returnData));\n    }\n}\n"
      },
      "contracts/solidity/interface/IERC1271.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC-1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n */\ninterface IERC1271 {\n    /**\n     * @dev Should return whether the signature provided is valid for the provided data\n     * @param hash      Hash of the data to be signed\n     * @param signature Signature byte array associated with _data\n     */\n    function isValidSignature(\n        bytes32 hash,\n        bytes memory signature\n    ) external view returns (bytes4 magicValue);\n}\n"
      },
      "contracts/solidity/interface/IERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\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 IERC165Upgradeable {\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"
      },
      "contracts/solidity/interface/IERC3156Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC3156 FlashBorrower, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n */\ninterface IERC3156FlashBorrowerUpgradeable {\n    /**\n     * @dev Receive a flash loan.\n     * @param initiator The initiator of the loan.\n     * @param token The loan currency.\n     * @param amount The amount of tokens lent.\n     * @param fee The additional amount of tokens to repay.\n     * @param data Arbitrary data structure, intended to contain user-defined parameters.\n     * @return The keccak256 hash of \"ERC3156FlashBorrower.onFlashLoan\"\n     */\n    function onFlashLoan(\n        address initiator,\n        address token,\n        uint256 amount,\n        uint256 fee,\n        bytes calldata data\n    ) external returns (bytes32);\n}\n\n/**\n * @dev Interface of the ERC3156 FlashLender, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n */\ninterface IERC3156FlashLenderUpgradeable {\n    /**\n     * @dev The amount of currency available to be lended.\n     * @param token The loan currency.\n     * @return The amount of `token` that can be borrowed.\n     */\n    function maxFlashLoan(address token) external view returns (uint256);\n\n    /**\n     * @dev The fee to be charged for a given loan.\n     * @param token The loan currency.\n     * @param amount The amount of tokens lent.\n     * @return The amount of `token` to be charged for the loan, on top of the returned principal.\n     */\n    function flashFee(address token, uint256 amount)\n        external\n        view\n        returns (uint256);\n\n    /**\n     * @dev Initiate a flash loan.\n     * @param receiver The receiver of the tokens in the loan, and the receiver of the callback.\n     * @param token The loan currency.\n     * @param amount The amount of tokens lent.\n     * @param data Arbitrary data structure, intended to contain user-defined parameters.\n     */\n    function flashLoan(\n        IERC3156FlashBorrowerUpgradeable receiver,\n        address token,\n        uint256 amount,\n        bytes calldata data\n    ) external returns (bool);\n}\n"
      },
      "contracts/solidity/interface/INFTXEligibility.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface INFTXEligibility {\n    // Read functions.\n    function name() external pure returns (string memory);\n\n    function finalized() external view returns (bool);\n\n    function targetAsset() external pure returns (address);\n\n    function checkAllEligible(uint256[] calldata tokenIds)\n        external\n        view\n        returns (bool);\n\n    function checkEligible(uint256[] calldata tokenIds)\n        external\n        view\n        returns (bool[] memory);\n\n    function checkAllIneligible(uint256[] calldata tokenIds)\n        external\n        view\n        returns (bool);\n\n    function checkIsEligible(uint256 tokenId) external view returns (bool);\n\n    // Write functions.\n    function __NFTXEligibility_init_bytes(bytes calldata configData) external;\n\n    function beforeMintHook(uint256[] calldata tokenIds) external;\n\n    function afterMintHook(uint256[] calldata tokenIds) external;\n\n    function beforeRedeemHook(uint256[] calldata tokenIds) external;\n\n    function afterRedeemHook(uint256[] calldata tokenIds) external;\n}\n"
      },
      "contracts/solidity/interface/INFTXEligibilityManager.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface INFTXEligibilityManager {\n    function nftxVaultFactory() external returns (address);\n\n    function eligibilityImpl() external returns (address);\n\n    function deployEligibility(uint256 vaultId, bytes calldata initData)\n        external\n        returns (address);\n}\n"
      },
      "contracts/solidity/interface/INFTXFeeDistributor.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface INFTXFeeDistributor {\n    struct FeeReceiver {\n        uint256 allocPoint;\n        address receiver;\n        bool isContract;\n    }\n\n    function nftxVaultFactory() external returns (address);\n\n    function lpStaking() external returns (address);\n\n    function treasury() external returns (address);\n\n    function defaultTreasuryAlloc() external returns (uint256);\n\n    function defaultLPAlloc() external returns (uint256);\n\n    function allocTotal(uint256 vaultId) external returns (uint256);\n\n    function specificTreasuryAlloc(uint256 vaultId) external returns (uint256);\n\n    // Write functions.\n    function __FeeDistributor__init__(address _lpStaking, address _treasury)\n        external;\n\n    function rescueTokens(address token) external;\n\n    function distribute(uint256 vaultId) external;\n\n    function addReceiver(\n        uint256 _vaultId,\n        uint256 _allocPoint,\n        address _receiver,\n        bool _isContract\n    ) external;\n\n    function initializeVaultReceivers(uint256 _vaultId) external;\n\n    function changeMultipleReceiverAlloc(\n        uint256[] memory _vaultIds,\n        uint256[] memory _receiverIdxs,\n        uint256[] memory allocPoints\n    ) external;\n\n    function changeMultipleReceiverAddress(\n        uint256[] memory _vaultIds,\n        uint256[] memory _receiverIdxs,\n        address[] memory addresses,\n        bool[] memory isContracts\n    ) external;\n\n    function changeReceiverAlloc(\n        uint256 _vaultId,\n        uint256 _idx,\n        uint256 _allocPoint\n    ) external;\n\n    function changeReceiverAddress(\n        uint256 _vaultId,\n        uint256 _idx,\n        address _address,\n        bool _isContract\n    ) external;\n\n    function removeReceiver(uint256 _vaultId, uint256 _receiverIdx) external;\n\n    // Configuration functions.\n    function setTreasuryAddress(address _treasury) external;\n\n    function setDefaultTreasuryAlloc(uint256 _allocPoint) external;\n\n    function setSpecificTreasuryAlloc(uint256 _vaultId, uint256 _allocPoint)\n        external;\n\n    function setLPStakingAddress(address _lpStaking) external;\n\n    function setNFTXVaultFactory(address _factory) external;\n\n    function setDefaultLPAlloc(uint256 _allocPoint) external;\n}\n"
      },
      "contracts/solidity/interface/INFTXVault.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../token/IERC20Upgradeable.sol\";\nimport \"./INFTXVaultFactory.sol\";\nimport \"./INFTXEligibility.sol\";\n\ninterface INFTXVault is IERC20Upgradeable {\n    function manager() external view returns (address);\n\n    function assetAddress() external view returns (address);\n\n    function vaultFactory() external view returns (INFTXVaultFactory);\n\n    function eligibilityStorage() external view returns (INFTXEligibility);\n\n    function is1155() external view returns (bool);\n\n    function allowAllItems() external view returns (bool);\n\n    function enableMint() external view returns (bool);\n\n    function enableRandomRedeem() external view returns (bool);\n\n    function enableTargetRedeem() external view returns (bool);\n\n    function enableRandomSwap() external view returns (bool);\n\n    function enableTargetSwap() external view returns (bool);\n\n    function vaultId() external view returns (uint256);\n\n    function nftIdAt(uint256 holdingsIndex) external view returns (uint256);\n\n    function allHoldings() external view returns (uint256[] memory);\n\n    function totalHoldings() external view returns (uint256);\n\n    function mintFee() external view returns (uint256);\n\n    function randomRedeemFee() external view returns (uint256);\n\n    function targetRedeemFee() external view returns (uint256);\n\n    function randomSwapFee() external view returns (uint256);\n\n    function targetSwapFee() external view returns (uint256);\n\n    function vaultFees()\n        external\n        view\n        returns (\n            uint256,\n            uint256,\n            uint256,\n            uint256,\n            uint256\n        );\n\n    event VaultInit(\n        uint256 indexed vaultId,\n        address assetAddress,\n        bool is1155,\n        bool allowAllItems\n    );\n\n    event ManagerSet(address manager);\n    event EligibilityDeployed(uint256 moduleIndex, address eligibilityAddr);\n    // event CustomEligibilityDeployed(address eligibilityAddr);\n\n    event EnableMintUpdated(bool enabled);\n    event EnableRandomRedeemUpdated(bool enabled);\n    event EnableTargetRedeemUpdated(bool enabled);\n    event EnableRandomSwapUpdated(bool enabled);\n    event EnableTargetSwapUpdated(bool enabled);\n\n    event Minted(uint256[] nftIds, uint256[] amounts, address to);\n    event Redeemed(uint256[] nftIds, uint256[] specificIds, address to);\n    event Swapped(\n        uint256[] nftIds,\n        uint256[] amounts,\n        uint256[] specificIds,\n        uint256[] redeemedIds,\n        address to\n    );\n\n    function __NFTXVault_init(\n        string calldata _name,\n        string calldata _symbol,\n        address _assetAddress,\n        bool _is1155,\n        bool _allowAllItems\n    ) external;\n\n    function finalizeVault() external;\n\n    function setVaultMetadata(string memory name_, string memory symbol_)\n        external;\n\n    function setVaultFeatures(\n        bool _enableMint,\n        bool _enableRandomRedeem,\n        bool _enableTargetRedeem,\n        bool _enableRandomSwap,\n        bool _enableTargetSwap\n    ) external;\n\n    function setFees(\n        uint256 _mintFee,\n        uint256 _randomRedeemFee,\n        uint256 _targetRedeemFee,\n        uint256 _randomSwapFee,\n        uint256 _targetSwapFee\n    ) external;\n\n    function disableVaultFees() external;\n\n    // This function allows for an easy setup of any eligibility module contract from the EligibilityManager.\n    // It takes in ABI encoded parameters for the desired module. This is to make sure they can all follow\n    // a similar interface.\n    function deployEligibilityStorage(\n        uint256 moduleIndex,\n        bytes calldata initData\n    ) external returns (address);\n\n    // The manager has control over options like fees and features\n    function setManager(address _manager) external;\n\n    function mint(\n        uint256[] calldata tokenIds,\n        uint256[] calldata amounts /* ignored for ERC721 vaults */\n    ) external returns (uint256);\n\n    function mintTo(\n        uint256[] calldata tokenIds,\n        uint256[] calldata amounts, /* ignored for ERC721 vaults */\n        address to\n    ) external returns (uint256);\n\n    function redeem(uint256 amount, uint256[] calldata specificIds)\n        external\n        returns (uint256[] calldata);\n\n    function redeemTo(\n        uint256 amount,\n        uint256[] calldata specificIds,\n        address to\n    ) external returns (uint256[] calldata);\n\n    function swap(\n        uint256[] calldata tokenIds,\n        uint256[] calldata amounts, /* ignored for ERC721 vaults */\n        uint256[] calldata specificIds\n    ) external returns (uint256[] calldata);\n\n    function swapTo(\n        uint256[] calldata tokenIds,\n        uint256[] calldata amounts, /* ignored for ERC721 vaults */\n        uint256[] calldata specificIds,\n        address to\n    ) external returns (uint256[] calldata);\n\n    function allValidNFTs(uint256[] calldata tokenIds)\n        external\n        view\n        returns (bool);\n}\n"
      },
      "contracts/solidity/interface/INFTXVaultFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../proxy/IBeacon.sol\";\n\ninterface INFTXVaultFactory is IBeacon {\n    // Read functions.\n    function numVaults() external view returns (uint256);\n\n    function zapContract() external view returns (address);\n\n    function zapContracts(address addr) external view returns (bool);\n\n    function erc1272Signer() external view returns (address);\n\n    function feeDistributor() external view returns (address);\n\n    function eligibilityManager() external view returns (address);\n\n    function vault(uint256 vaultId) external view returns (address);\n\n    function allVaults() external view returns (address[] memory);\n\n    function vaultsForAsset(address asset)\n        external\n        view\n        returns (address[] memory);\n\n    function isLocked(uint256 id) external view returns (bool);\n\n    function excludedFromFees(address addr) external view returns (bool);\n\n    function factoryMintFee() external view returns (uint64);\n\n    function factoryRandomRedeemFee() external view returns (uint64);\n\n    function factoryTargetRedeemFee() external view returns (uint64);\n\n    function factoryRandomSwapFee() external view returns (uint64);\n\n    function factoryTargetSwapFee() external view returns (uint64);\n\n    function vaultFees(uint256 vaultId)\n        external\n        view\n        returns (\n            uint256,\n            uint256,\n            uint256,\n            uint256,\n            uint256\n        );\n\n    event NewFeeDistributor(address oldDistributor, address newDistributor);\n    event NewZapContract(address oldZap, address newZap);\n    event UpdatedZapContract(address zap, bool excluded);\n    event FeeExclusion(address feeExcluded, bool excluded);\n    event NewEligibilityManager(address oldEligManager, address newEligManager);\n    event NewVault(\n        uint256 indexed vaultId,\n        address vaultAddress,\n        address assetAddress\n    );\n    event UpdateVaultFees(\n        uint256 vaultId,\n        uint256 mintFee,\n        uint256 randomRedeemFee,\n        uint256 targetRedeemFee,\n        uint256 randomSwapFee,\n        uint256 targetSwapFee\n    );\n    event DisableVaultFees(uint256 vaultId);\n    event UpdateFactoryFees(\n        uint256 mintFee,\n        uint256 randomRedeemFee,\n        uint256 targetRedeemFee,\n        uint256 randomSwapFee,\n        uint256 targetSwapFee\n    );\n\n    // Write functions.\n    function __NFTXVaultFactory_init(\n        address _vaultImpl,\n        address _feeDistributor\n    ) external;\n\n    function createVault(\n        string calldata name,\n        string calldata symbol,\n        address _assetAddress,\n        bool is1155,\n        bool allowAllItems\n    ) external returns (uint256);\n\n    function setFeeDistributor(address _feeDistributor) external;\n\n    function setEligibilityManager(address _eligibilityManager) external;\n\n    function setZapContract(address _zapContract, bool _excluded) external;\n\n    function setFeeExclusion(address _excludedAddr, bool excluded) external;\n\n    function setFactoryFees(\n        uint256 mintFee,\n        uint256 randomRedeemFee,\n        uint256 targetRedeemFee,\n        uint256 randomSwapFee,\n        uint256 targetSwapFee\n    ) external;\n\n    function setVaultFees(\n        uint256 vaultId,\n        uint256 mintFee,\n        uint256 randomRedeemFee,\n        uint256 targetRedeemFee,\n        uint256 randomSwapFee,\n        uint256 targetSwapFee\n    ) external;\n\n    function disableVaultFees(uint256 vaultId) external;\n\n    function setERC1271Signer(address _erc1271Signer) external;\n}\n"
      },
      "contracts/solidity/proxy/BeaconProxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./Proxy.sol\";\nimport \"./IBeacon.sol\";\nimport \"../util/Address.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy {\n    /**\n     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n     */\n    bytes32 private constant _BEACON_SLOT =\n        0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    /**\n     * @dev Initializes the proxy with `beacon`.\n     *\n     * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n     * will typically be an encoded function call, and allows initializating the storage of the proxy like a Solidity\n     * constructor.\n     *\n     * Requirements:\n     *\n     * - `beacon` must be a contract with the interface {IBeacon}.\n     */\n    constructor(address beacon, bytes memory data) payable {\n        assert(\n            _BEACON_SLOT ==\n                bytes32(uint256(keccak256(\"eip1967.proxy.beacon\")) - 1)\n        );\n        _setBeacon(beacon, data);\n    }\n\n    /**\n     * @dev Returns the current beacon address.\n     */\n    function _beacon() internal view virtual returns (address beacon) {\n        bytes32 slot = _BEACON_SLOT;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            beacon := sload(slot)\n        }\n    }\n\n    /**\n     * @dev Returns the current implementation address of the associated beacon.\n     */\n    function _implementation()\n        internal\n        view\n        virtual\n        override\n        returns (address)\n    {\n        return IBeacon(_beacon()).childImplementation();\n    }\n\n    /**\n     * @dev Changes the proxy to use a new beacon.\n     *\n     * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n     *\n     * Requirements:\n     *\n     * - `beacon` must be a contract.\n     * - The implementation returned by `beacon` must be a contract.\n     */\n    function _setBeacon(address beacon, bytes memory data) internal virtual {\n        require(\n            Address.isContract(beacon),\n            \"BeaconProxy: beacon is not a contract\"\n        );\n        require(\n            Address.isContract(IBeacon(beacon).childImplementation()),\n            \"BeaconProxy: beacon implementation is not a contract\"\n        );\n        bytes32 slot = _BEACON_SLOT;\n\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            sstore(slot, beacon)\n        }\n\n        if (data.length > 0) {\n            Address.functionDelegateCall(\n                _implementation(),\n                data,\n                \"BeaconProxy: function call failed\"\n            );\n        }\n    }\n}\n"
      },
      "contracts/solidity/proxy/IBeacon.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n    /**\n     * @dev Must return an address that can be used as a delegate call target.\n     *\n     * {BeaconProxy} will check that this address is a contract.\n     */\n    function childImplementation() external view returns (address);\n\n    function implementation() external view returns (address);\n\n    function upgradeChildTo(address newImplementation) external;\n}\n"
      },
      "contracts/solidity/proxy/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\n// solhint-disable-next-line compiler-version\npragma solidity ^0.8.0;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     */\n    bool private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Modifier to protect an initializer function from being invoked twice.\n     */\n    modifier initializer() {\n        require(\n            _initializing || !_initialized,\n            \"Initializable: contract is already initialized\"\n        );\n\n        bool isTopLevelCall = !_initializing;\n        if (isTopLevelCall) {\n            _initializing = true;\n            _initialized = true;\n        }\n\n        _;\n\n        if (isTopLevelCall) {\n            _initializing = false;\n        }\n    }\n}\n"
      },
      "contracts/solidity/proxy/Proxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n    /**\n     * @dev Delegates the current call to `implementation`.\n     *\n     * This function does not return to its internall call site, it will return directly to the external caller.\n     */\n    function _delegate(address implementation) internal virtual {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            // Copy msg.data. We take full control of memory in this inline assembly\n            // block because it will not return to Solidity code. We overwrite the\n            // Solidity scratch pad at memory position 0.\n            calldatacopy(0, 0, calldatasize())\n\n            // Call the implementation.\n            // out and outsize are 0 because we don't know the size yet.\n            let result := delegatecall(\n                gas(),\n                implementation,\n                0,\n                calldatasize(),\n                0,\n                0\n            )\n\n            // Copy the returned data.\n            returndatacopy(0, 0, returndatasize())\n\n            switch result\n            // delegatecall returns 0 on error.\n            case 0 {\n                revert(0, returndatasize())\n            }\n            default {\n                return(0, returndatasize())\n            }\n        }\n    }\n\n    /**\n     * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\n     * and {_fallback} should delegate.\n     */\n    function _implementation() internal view virtual returns (address);\n\n    /**\n     * @dev Delegates the current call to the address returned by `_implementation()`.\n     *\n     * This function does not return to its internall call site, it will return directly to the external caller.\n     */\n    function _fallback() internal virtual {\n        _beforeFallback();\n        _delegate(_implementation());\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n     * function in the contract matches the call data.\n     */\n    fallback() external payable virtual {\n        _fallback();\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n     * is empty.\n     */\n    receive() external payable virtual {\n        _fallback();\n    }\n\n    /**\n     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n     * call, or as part of the Solidity `fallback` or `receive` functions.\n     *\n     * If overriden should call `super._beforeFallback()`.\n     */\n    function _beforeFallback() internal virtual {}\n}\n"
      },
      "contracts/solidity/proxy/UpgradeableBeacon.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../util/Address.sol\";\nimport \"../util/OwnableUpgradeable.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, OwnableUpgradeable {\n    address private _childImplementation;\n\n    /**\n     * @dev Emitted when the child implementation returned by the beacon is changed.\n     */\n    event Upgraded(address indexed childImplementation);\n\n    /**\n     * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n     * beacon.\n     */\n    function __UpgradeableBeacon__init(address childImplementation_)\n        public\n        initializer\n    {\n        _setChildImplementation(childImplementation_);\n    }\n\n    /**\n     * @dev Returns the current child implementation address.\n     */\n    function childImplementation()\n        public\n        view\n        virtual\n        override\n        returns (address)\n    {\n        return _childImplementation;\n    }\n\n    function implementation() public view virtual override returns (address) {\n        return _childImplementation;\n    }\n\n    /**\n     * @dev Upgrades the beacon to a new implementation.\n     *\n     * Emits an {Upgraded} event.\n     *\n     * Requirements:\n     *\n     * - msg.sender must be the owner of the contract.\n     * - `newChildImplementation` must be a contract.\n     */\n    function upgradeChildTo(address newChildImplementation)\n        public\n        virtual\n        override\n        onlyOwner\n    {\n        _setChildImplementation(newChildImplementation);\n    }\n\n    /**\n     * @dev Sets the implementation contract address for this beacon\n     *\n     * Requirements:\n     *\n     * - `newChildImplementation` must be a contract.\n     */\n    function _setChildImplementation(address newChildImplementation) private {\n        require(\n            Address.isContract(newChildImplementation),\n            \"UpgradeableBeacon: child implementation is not a contract\"\n        );\n        _childImplementation = newChildImplementation;\n        emit Upgraded(newChildImplementation);\n    }\n}\n"
      },
      "contracts/solidity/token/ERC1155ReceiverUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../util/ERC165Upgradeable.sol\";\nimport \"./IERC1155ReceiverUpgradeable.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155ReceiverUpgradeable is\n    ERC165Upgradeable,\n    IERC1155ReceiverUpgradeable\n{\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        virtual\n        override(ERC165Upgradeable, IERC165Upgradeable)\n        returns (bool)\n    {\n        return\n            interfaceId == type(IERC1155ReceiverUpgradeable).interfaceId ||\n            super.supportsInterface(interfaceId);\n    }\n}\n"
      },
      "contracts/solidity/token/ERC1155SafeHolderUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ERC1155ReceiverUpgradeable.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155SafeHolderUpgradeable is ERC1155ReceiverUpgradeable {\n    function onERC1155Received(\n        address operator,\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 operator,\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/solidity/token/ERC20FlashMintUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../proxy/Initializable.sol\";\nimport \"../interface/IERC3156Upgradeable.sol\";\nimport \"./ERC20Upgradeable.sol\";\n\n/**\n * @dev Implementation of the ERC3156 Flash loans extension, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * Adds the {flashLoan} method, which provides flash loan support at the token\n * level. By default there is no fee, but this can be changed by overriding {flashFee}.\n */\nabstract contract ERC20FlashMintUpgradeable is\n    Initializable,\n    ERC20Upgradeable,\n    IERC3156FlashLenderUpgradeable\n{\n    function __ERC20FlashMint_init() internal initializer {\n        __Context_init_unchained();\n        __ERC20FlashMint_init_unchained();\n    }\n\n    function __ERC20FlashMint_init_unchained() internal initializer {}\n\n    bytes32 private constant RETURN_VALUE =\n        keccak256(\"ERC3156FlashBorrower.onFlashLoan\");\n\n    /**\n     * @dev Returns the maximum amount of tokens available for loan.\n     * @param token The address of the token that is requested.\n     * @return The amont of token that can be loaned.\n     */\n    function maxFlashLoan(address token)\n        public\n        view\n        override\n        returns (uint256)\n    {\n        return token == address(this) ? type(uint256).max - totalSupply() : 0;\n    }\n\n    /**\n     * @dev Returns the fee applied when doing flash loans. By default this\n     * implementation has 0 fees. This function can be overloaded to make\n     * the flash loan mechanism deflationary.\n     * @param token The token to be flash loaned.\n     * @param amount The amount of tokens to be loaned.\n     * @return The fees applied to the corresponding flash loan.\n     */\n    function flashFee(address token, uint256 amount)\n        public\n        view\n        virtual\n        override\n        returns (uint256)\n    {\n        require(token == address(this), \"ERC20FlashMint: wrong token\");\n        // silence warning about unused variable without the addition of bytecode.\n        amount;\n        return 0;\n    }\n\n    /**\n     * @dev Performs a flash loan. New tokens are minted and sent to the\n     * `receiver`, who is required to implement the {IERC3156FlashBorrower}\n     * interface. By the end of the flash loan, the receiver is expected to own\n     * amount + fee tokens and have them approved back to the token contract itself so\n     * they can be burned.\n     * @param receiver The receiver of the flash loan. Should implement the\n     * {IERC3156FlashBorrower.onFlashLoan} interface.\n     * @param token The token to be flash loaned. Only `address(this)` is\n     * supported.\n     * @param amount The amount of tokens to be loaned.\n     * @param data An arbitrary datafield that is passed to the receiver.\n     * @return `true` is the flash loan was successfull.\n     */\n    function flashLoan(\n        IERC3156FlashBorrowerUpgradeable receiver,\n        address token,\n        uint256 amount,\n        bytes memory data\n    ) public virtual override returns (bool) {\n        uint256 fee = flashFee(token, amount);\n        _mint(address(receiver), amount);\n        require(\n            receiver.onFlashLoan(msg.sender, token, amount, fee, data) ==\n                RETURN_VALUE,\n            \"ERC20FlashMint: invalid return value\"\n        );\n        uint256 currentAllowance = allowance(address(receiver), address(this));\n        require(\n            currentAllowance >= amount + fee,\n            \"ERC20FlashMint: allowance does not allow refund\"\n        );\n        _approve(\n            address(receiver),\n            address(this),\n            currentAllowance - amount - fee\n        );\n        _burn(address(receiver), amount + fee);\n        return true;\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/solidity/token/ERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../proxy/Initializable.sol\";\nimport \"../util/ContextUpgradeable.sol\";\nimport \"./IERC20Upgradeable.sol\";\nimport \"./IERC20Metadata.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20Upgradeable is\n    Initializable,\n    ContextUpgradeable,\n    IERC20Upgradeable,\n    IERC20Metadata\n{\n    mapping(address => uint256) private _balances;\n\n    mapping(address => mapping(address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}.\n     *\n     * The default value of {decimals} is 18. To select a different value for\n     * {decimals} you should overload it.\n     *\n     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    function __ERC20_init(string memory name_, string memory symbol_)\n        internal\n        initializer\n    {\n        __Context_init_unchained();\n        __ERC20_init_unchained(name_, symbol_);\n    }\n\n    function __ERC20_init_unchained(string memory name_, string memory symbol_)\n        internal\n        initializer\n    {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    function _setMetadata(string memory name_, string memory symbol_) internal {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the value {ERC20} uses, unless this function is\n     * overridden;\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual override returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account)\n        public\n        view\n        virtual\n        override\n        returns (uint256)\n    {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `recipient` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address recipient, uint256 amount)\n        public\n        virtual\n        override\n        returns (bool)\n    {\n        _transfer(_msgSender(), recipient, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender)\n        public\n        view\n        virtual\n        override\n        returns (uint256)\n    {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 amount)\n        public\n        virtual\n        override\n        returns (bool)\n    {\n        _approve(_msgSender(), spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\n     *\n     * Requirements:\n     *\n     * - `sender` and `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     * - the caller must have allowance for ``sender``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) public virtual override returns (bool) {\n        _transfer(sender, recipient, amount);\n\n        uint256 currentAllowance = _allowances[sender][_msgSender()];\n        require(\n            currentAllowance >= amount,\n            \"ERC20: transfer amount exceeds allowance\"\n        );\n        _approve(sender, _msgSender(), currentAllowance - amount);\n\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue)\n        public\n        virtual\n        returns (bool)\n    {\n        _approve(\n            _msgSender(),\n            spender,\n            _allowances[_msgSender()][spender] + addedValue\n        );\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue)\n        public\n        virtual\n        returns (bool)\n    {\n        uint256 currentAllowance = _allowances[_msgSender()][spender];\n        require(\n            currentAllowance >= subtractedValue,\n            \"ERC20: decreased allowance below zero\"\n        );\n        _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n\n        return true;\n    }\n\n    /**\n     * @dev Moves tokens `amount` from `sender` to `recipient`.\n     *\n     * This is internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `sender` cannot be the zero address.\n     * - `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     */\n    function _transfer(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) internal virtual {\n        require(sender != address(0), \"ERC20: transfer from the zero address\");\n        require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n        _beforeTokenTransfer(sender, recipient, amount);\n\n        uint256 senderBalance = _balances[sender];\n        require(\n            senderBalance >= amount,\n            \"ERC20: transfer amount exceeds balance\"\n        );\n        _balances[sender] = senderBalance - amount;\n        _balances[recipient] += amount;\n\n        emit Transfer(sender, recipient, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, amount);\n\n        _totalSupply += amount;\n        _balances[account] += amount;\n        emit Transfer(address(0), account, amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), amount);\n\n        uint256 accountBalance = _balances[account];\n        require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n        _balances[account] = accountBalance - amount;\n        _totalSupply -= amount;\n\n        emit Transfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be to transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n\n    uint256[45] private __gap;\n}\n"
      },
      "contracts/solidity/token/ERC721SafeHolderUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721ReceiverUpgradeable.sol\";\n\n/**\n * @dev Implementation of the {IERC721Receiver} interface.\n *\n * Accepts all token transfers.\n * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.\n */\ncontract ERC721SafeHolderUpgradeable is IERC721ReceiverUpgradeable {\n    /**\n     * @dev See {IERC721Receiver-onERC721Received}.\n     *\n     * Always returns `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address,\n        uint256,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC721Received.selector;\n    }\n}\n"
      },
      "contracts/solidity/token/IERC1155ReceiverUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../interface/IERC165Upgradeable.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155ReceiverUpgradeable is IERC165Upgradeable {\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        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        @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. 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        @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"
      },
      "contracts/solidity/token/IERC1155Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../interface/IERC165Upgradeable.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 IERC1155Upgradeable is IERC165Upgradeable {\n    /**\n     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n     */\n    event TransferSingle(\n        address indexed operator,\n        address indexed from,\n        address indexed to,\n        uint256 id,\n        uint256 value\n    );\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(\n        address indexed account,\n        address indexed operator,\n        bool approved\n    );\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)\n        external\n        view\n        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)\n        external\n        view\n        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 be 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/solidity/token/IERC20Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20Upgradeable {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
      },
      "contracts/solidity/token/IERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\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 `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, uint256 amount)\n        external\n        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)\n        external\n        view\n        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 `sender` to `recipient` 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 sender,\n        address recipient,\n        uint256 amount\n    ) external returns (bool);\n\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(\n        address indexed owner,\n        address indexed spender,\n        uint256 value\n    );\n}\n"
      },
      "contracts/solidity/token/IERC721ReceiverUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721ReceiverUpgradeable {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "contracts/solidity/token/IERC721Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../interface/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(\n        address indexed from,\n        address indexed to,\n        uint256 indexed tokenId\n    );\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(\n        address indexed owner,\n        address indexed approved,\n        uint256 indexed tokenId\n    );\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(\n        address indexed owner,\n        address indexed operator,\n        bool approved\n    );\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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\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 Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId)\n        external\n        view\n        returns (address operator);\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 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)\n        external\n        view\n        returns (bool);\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"
      },
      "contracts/solidity/util/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\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    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            size := extcodesize(account)\n        }\n        return size > 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(\n            address(this).balance >= amount,\n            \"Address: insufficient balance\"\n        );\n\n        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(\n            success,\n            \"Address: unable to send value, recipient may have reverted\"\n        );\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)\n        internal\n        returns (bytes memory)\n    {\n        return functionCall(target, data, \"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\n            functionCallWithValue(\n                target,\n                data,\n                value,\n                \"Address: low-level call with value failed\"\n            );\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(\n            address(this).balance >= value,\n            \"Address: insufficient balance for call\"\n        );\n        require(isContract(target), \"Address: call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.call{value: value}(\n            data\n        );\n        return _verifyCallResult(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)\n        internal\n        view\n        returns (bytes memory)\n    {\n        return\n            functionStaticCall(\n                target,\n                data,\n                \"Address: low-level static call failed\"\n            );\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        require(isContract(target), \"Address: static call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return _verifyCallResult(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)\n        internal\n        returns (bytes memory)\n    {\n        return\n            functionDelegateCall(\n                target,\n                data,\n                \"Address: low-level delegate call failed\"\n            );\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        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    function _verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) private pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\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\n                // solhint-disable-next-line no-inline-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}\n"
      },
      "contracts/solidity/util/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../proxy/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n    function __Context_init() internal initializer {\n        __Context_init_unchained();\n    }\n\n    function __Context_init_unchained() internal initializer {}\n\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        return msg.data;\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/solidity/util/ECDSA.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS\n    }\n\n    /**\n     * @dev The signature derives the `address(0)`.\n     */\n    error ECDSAInvalidSignature();\n\n    /**\n     * @dev The signature has an invalid length.\n     */\n    error ECDSAInvalidSignatureLength(uint256 length);\n\n    /**\n     * @dev The signature has an S value that is in the upper half order.\n     */\n    error ECDSAInvalidSignatureS(bytes32 s);\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n     * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n     * and a bytes32 providing additional information about the error.\n     *\n     * If no error is returned, then the address can be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes memory signature\n    ) internal pure returns (address, RecoverError, bytes32) {\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-assembly\n            assembly {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else {\n            return (\n                address(0),\n                RecoverError.InvalidSignatureLength,\n                bytes32(signature.length)\n            );\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     */\n    function recover(\n        bytes32 hash,\n        bytes memory signature\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(\n            hash,\n            signature\n        );\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address, RecoverError, bytes32) {\n        unchecked {\n            bytes32 s = vs &\n                bytes32(\n                    0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\n                );\n            // We do not check for an overflow here since the shift operation results in 0 or 1.\n            uint8 v = uint8((uint256(vs) >> 255) + 27);\n            return tryRecover(hash, v, r, s);\n        }\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     */\n    function recover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(\n            hash,\n            r,\n            vs\n        );\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address, RecoverError, bytes32) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (\n            uint256(s) >\n            0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\n        ) {\n            return (address(0), RecoverError.InvalidSignatureS, s);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature, bytes32(0));\n        }\n\n        return (signer, RecoverError.NoError, bytes32(0));\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(\n            hash,\n            v,\n            r,\n            s\n        );\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n     */\n    function _throwError(RecoverError error, bytes32 errorArg) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert ECDSAInvalidSignature();\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert ECDSAInvalidSignatureLength(uint256(errorArg));\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert ECDSAInvalidSignatureS(errorArg);\n        }\n    }\n}\n"
      },
      "contracts/solidity/util/ERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../interface/IERC165Upgradeable.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 ERC165Upgradeable is IERC165Upgradeable {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        virtual\n        override\n        returns (bool)\n    {\n        return interfaceId == type(IERC165Upgradeable).interfaceId;\n    }\n}\n"
      },
      "contracts/solidity/util/EnumerableSetUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\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 */\nlibrary EnumerableSetUpgradeable {\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)\n        private\n        view\n        returns (bool)\n    {\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)\n        private\n        view\n        returns (bytes32)\n    {\n        return set._values[index];\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)\n        internal\n        returns (bool)\n    {\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)\n        internal\n        returns (bool)\n    {\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)\n        internal\n        view\n        returns (bool)\n    {\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)\n        internal\n        view\n        returns (bytes32)\n    {\n        return _at(set._inner, index);\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)\n        internal\n        returns (bool)\n    {\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)\n        internal\n        returns (bool)\n    {\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)\n        internal\n        view\n        returns (bool)\n    {\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)\n        internal\n        view\n        returns (address)\n    {\n        return address(uint160(uint256(_at(set._inner, index))));\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)\n        internal\n        returns (bool)\n    {\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)\n        internal\n        view\n        returns (bool)\n    {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values on 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)\n        internal\n        view\n        returns (uint256)\n    {\n        return uint256(_at(set._inner, index));\n    }\n}\n"
      },
      "contracts/solidity/util/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../proxy/Initializable.sol\";\nimport \"./ContextUpgradeable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(\n        address indexed previousOwner,\n        address indexed newOwner\n    );\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal initializer {\n        __Context_init_unchained();\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal initializer {\n        address msgSender = _msgSender();\n        _owner = msgSender;\n        emit OwnershipTransferred(address(0), msgSender);\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 called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\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        emit OwnershipTransferred(_owner, address(0));\n        _owner = 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(\n            newOwner != address(0),\n            \"Ownable: new owner is the zero address\"\n        );\n        emit OwnershipTransferred(_owner, newOwner);\n        _owner = newOwner;\n    }\n\n    uint256[49] private __gap;\n}\n"
      },
      "contracts/solidity/util/PausableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./OwnableUpgradeable.sol\";\n\ncontract PausableUpgradeable is OwnableUpgradeable {\n    function __Pausable_init() internal initializer {\n        __Ownable_init();\n    }\n\n    event SetPaused(uint256 lockId, bool paused);\n    event SetIsGuardian(address addr, bool isGuardian);\n\n    mapping(address => bool) public isGuardian;\n    mapping(uint256 => bool) public isPaused;\n\n    // 0 : createVault\n    // 1 : mint\n    // 2 : redeem\n    // 3 : swap\n    // 4 : flashloan\n\n    function onlyOwnerIfPaused(uint256 lockId) public view virtual {\n        require(!isPaused[lockId] || msg.sender == owner(), \"Paused\");\n    }\n\n    function unpause(uint256 lockId) public virtual onlyOwner {\n        isPaused[lockId] = false;\n        emit SetPaused(lockId, false);\n    }\n\n    function pause(uint256 lockId) public virtual {\n        require(isGuardian[msg.sender], \"Can't pause\");\n        isPaused[lockId] = true;\n        emit SetPaused(lockId, true);\n    }\n\n    function setIsGuardian(address addr, bool _isGuardian)\n        public\n        virtual\n        onlyOwner\n    {\n        isGuardian[addr] = _isGuardian;\n        emit SetIsGuardian(addr, _isGuardian);\n    }\n}\n"
      },
      "contracts/solidity/util/ReentrancyGuardUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../proxy/Initializable.sol\";\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 ReentrancyGuardUpgradeable is Initializable {\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 initializer {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal initializer {\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 make 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    uint256[49] private __gap;\n}\n"
      },
      "contracts/solidity/util/SignatureChecker.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol)\n\npragma solidity ^0.8.0;\n\nimport {ECDSA} from \"./ECDSA.sol\";\nimport {IERC1271} from \"../interface/IERC1271.sol\";\n\n/**\n * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA\n * signatures from externally owned accounts (EOAs) as well as ERC-1271 signatures from smart contract wallets like\n * Argent and Safe Wallet (previously Gnosis Safe).\n */\nlibrary SignatureChecker {\n    /**\n     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the\n     * signature is validated against that smart contract using ERC-1271, otherwise it's validated using `ECDSA.recover`.\n     *\n     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n     * change through time. It could return true at block N and false at block N+1 (or the opposite).\n     */\n    function isValidSignatureNow(\n        address signer,\n        bytes32 hash,\n        bytes memory signature\n    ) internal view returns (bool) {\n        if (signer.code.length == 0) {\n            (address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecover(\n                hash,\n                signature\n            );\n            return err == ECDSA.RecoverError.NoError && recovered == signer;\n        } else {\n            return isValidERC1271SignatureNow(signer, hash, signature);\n        }\n    }\n\n    /**\n     * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated\n     * against the signer smart contract using ERC-1271.\n     *\n     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n     * change through time. It could return true at block N and false at block N+1 (or the opposite).\n     */\n    function isValidERC1271SignatureNow(\n        address signer,\n        bytes32 hash,\n        bytes memory signature\n    ) internal view returns (bool) {\n        (bool success, bytes memory result) = signer.staticcall(\n            abi.encodeWithSelector(\n                IERC1271.isValidSignature.selector,\n                hash,\n                signature\n            )\n        );\n        return (success &&\n            result.length >= 32 &&\n            abi.decode(result, (bytes32)) ==\n            bytes32(IERC1271.isValidSignature.selector));\n    }\n}\n"
      }
    }
  }}