{
    "Function": "withdraw",
    "File": "contracts/NestedFactory.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts/utils/Multicall.sol",
        "contracts/MixinOperatorResolver.sol",
        "node_modules/@openzeppelin/contracts/access/Ownable.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol",
        "node_modules/@openzeppelin/contracts/security/ReentrancyGuard.sol",
        "contracts/interfaces/INestedFactory.sol"
    ],
    "High-Level Calls": [
        "NestedRecords",
        "NestedReserve",
        "NestedRecords",
        "NestedRecords",
        "NestedRecords"
    ],
    "Internal Calls": [
        "onlyTokenOwner",
        "require(bool,string)",
        "_safeTransferWithFees",
        "nonReentrant",
        "require(bool,string)",
        "isUnlocked",
        "_msgSender"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function withdraw(uint256 _nftId, uint256 _tokenIndex)\n        external\n        override\n        nonReentrant\n        onlyTokenOwner(_nftId)\n        isUnlocked(_nftId)\n    {\n        uint256 assetTokensLength = nestedRecords.getAssetTokensLength(_nftId);\n        require(assetTokensLength > _tokenIndex, \"NestedFactory::withdraw: Invalid token index\");\n        // Use destroy instead if NFT has a single holding\n        require(assetTokensLength > 1, \"NestedFactory::withdraw: Can't withdraw the last asset\");\n\n        NestedRecords.Holding memory holding = nestedRecords.getAssetHolding(\n            _nftId,\n            nestedRecords.getAssetTokens(_nftId)[_tokenIndex]\n        );\n        reserve.withdraw(IERC20(holding.token), holding.amount);\n        _safeTransferWithFees(IERC20(holding.token), holding.amount, _msgSender(), _nftId);\n\n        nestedRecords.deleteAsset(_nftId, _tokenIndex);\n\n        emit NftUpdated(_nftId);\n    }"
}