{
    "Function": "withdrawLiquidity",
    "File": "contracts/Pool/Pool.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts/utils/ReentrancyGuard.sol",
        "contracts/interfaces/IPool.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20PausableUpgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"
    ],
    "High-Level Calls": [
        "SafeMathUpgradeable",
        "SafeMathUpgradeable",
        "SafeMathUpgradeable",
        "IERC20",
        "SafeMathUpgradeable",
        "SafeMathUpgradeable",
        "SavingsAccountUtil"
    ],
    "Internal Calls": [
        "totalSupply",
        "_withdrawRepayment",
        "nonReentrant",
        "totalSupply",
        "require(bool,string)",
        "isLender",
        "_burn",
        "balanceOf",
        "balance(address)"
    ],
    "Library Calls": [
        "div",
        "add",
        "div",
        "mul",
        "transferTokens",
        "mul"
    ],
    "Low-Level Calls": [],
    "Code": "function withdrawLiquidity() external isLender(msg.sender) nonReentrant {\n        LoanStatus _loanStatus = poolVariables.loanStatus;\n\n        require(\n            _loanStatus == LoanStatus.CLOSED ||\n                _loanStatus == LoanStatus.CANCELLED ||\n                _loanStatus == LoanStatus.DEFAULTED ||\n                _loanStatus == LoanStatus.TERMINATED,\n            'WL1'\n        );\n\n        //gets amount through liquidity shares\n        uint256 _actualBalance = balanceOf(msg.sender);\n        uint256 _toTransfer = _actualBalance;\n\n        if (_loanStatus == LoanStatus.DEFAULTED || _loanStatus == LoanStatus.TERMINATED) {\n            uint256 _totalAsset;\n            if (poolConstants.borrowAsset != address(0)) {\n                _totalAsset = IERC20(poolConstants.borrowAsset).balanceOf(address(this));\n            } else {\n                _totalAsset = address(this).balance;\n            }\n            //assuming their will be no tokens in pool in any case except liquidation (to be checked) or we should store the amount in liquidate()\n            _toTransfer = _toTransfer.mul(_totalAsset).div(totalSupply());\n        }\n\n        if (_loanStatus == LoanStatus.CANCELLED) {\n            _toTransfer = _toTransfer.add(_toTransfer.mul(poolVariables.penaltyLiquidityAmount).div(totalSupply()));\n        }\n\n        if (_loanStatus == LoanStatus.CLOSED) {\n            //transfer repayment\n            _withdrawRepayment(msg.sender);\n        }\n        //to add transfer if not included in above (can be transferred with liquidity)\n        _burn(msg.sender, _actualBalance);\n\n        //transfer liquidity provided\n        SavingsAccountUtil.transferTokens(poolConstants.borrowAsset, _toTransfer, address(this), msg.sender);\n\n        emit LiquidityWithdrawn(_toTransfer, msg.sender);\n    }"
}