{
    "Function": "close",
    "File": "tokenomics/contracts/Depository.sol",
    "Parent Contracts": [
        "tokenomics/contracts/interfaces/IErrorsTokenomics.sol"
    ],
    "High-Level Calls": [
        "ITokenomics"
    ],
    "Internal Calls": [
        "revert OwnerOnly(address,address)"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function close(uint256[] memory productIds) external returns (uint256[] memory closedProductIds) {\n        // Check for the contract ownership\n        if (msg.sender != owner) {\n            revert OwnerOnly(msg.sender, owner);\n        }\n\n        // Calculate the number of closed products\n        uint256 numProducts = productIds.length;\n        uint256[] memory ids = new uint256[](numProducts);\n        uint256 numClosedProducts;\n        // Traverse to close all possible products\n        for (uint256 i = 0; i < numProducts; ++i) {\n            uint256 productId = productIds[i];\n            // Check if the product is still open by getting its supply amount\n            uint256 supply = mapBondProducts[productId].supply;\n            // The supply is greater than zero only if the product is active, otherwise it is already closed\n            if (supply > 0) {\n                // Refund unused OLAS supply from the product if it was not used by the product completely\n                ITokenomics(tokenomics).refundFromBondProgram(supply);\n                address token = mapBondProducts[productId].token;\n                delete mapBondProducts[productId];\n\n                ids[numClosedProducts] = productIds[i];\n                ++numClosedProducts;\n                emit CloseProduct(token, productId, supply);\n            }\n        }\n\n        // Get the correct array size of closed product Ids\n        closedProductIds = new uint256[](numClosedProducts);\n        for (uint256 i = 0; i < numClosedProducts; ++i) {\n            closedProductIds[i] = ids[i];\n        }\n    }"
}