{
    "Function": "_repayInterest",
    "File": "contracts/Pool/Repayments.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts/utils/ReentrancyGuard.sol",
        "contracts/interfaces/IRepayment.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"
    ],
    "High-Level Calls": [
        "SafeMath",
        "SafeMath",
        "SafeMath"
    ],
    "Internal Calls": [
        "getInterestPerSecond",
        "getInterestLeft",
        "require(bool,string)"
    ],
    "Library Calls": [
        "add",
        "div",
        "mul"
    ],
    "Low-Level Calls": [],
    "Code": "function _repayInterest(\n        address _poolID,\n        uint256 _amount,\n        bool _isLastRepayment\n    ) internal returns (uint256) {\n        uint256 _interestLeft = getInterestLeft(_poolID);\n        require((_amount < _interestLeft) != _isLastRepayment, 'Repayments::repay complete interest must be repaid along with principal');\n\n        if (_amount < _interestLeft) {\n            uint256 _interestPerSecond = getInterestPerSecond(_poolID);\n            uint256 _newDurationRepaid = _amount.mul(10**30).div(_interestPerSecond); // dividing exponents\n            repayVariables[_poolID].loanDurationCovered = repayVariables[_poolID].loanDurationCovered.add(_newDurationRepaid);\n            emit InterestRepaid(_poolID, _amount);\n            return _amount;\n        } else {\n            repayVariables[_poolID].loanDurationCovered = repayConstants[_poolID].loanDuration; // full interest repaid\n            emit InterestRepaymentComplete(_poolID, _interestLeft);\n            return _interestLeft;\n        }\n    }"
}