```\nfunction clearRequest(\n    uint256 reqID_,\n    bool repayDirect_,\n    bool isCallback_\n) external returns (uint256 loanID) {\n    Request memory req = requests[reqID_];\n\n    // If necessary, ensure lender implements the CoolerCallback abstract.\n    if (isCallback_ && !CoolerCallback(msg.sender).isCoolerCallback()) revert NotCoolerCallback();\n\n    // Ensure loan request is active. \n    if (!req.active) revert Deactivated();\n\n    // Clear the loan request in memory.\n    req.active = false;\n\n    // Calculate and store loan terms.\n    uint256 interest = interestFor(req.amount, req.interest, req.duration);\n    uint256 collat = collateralFor(req.amount, req.loanToCollateral);\n    uint256 expiration = block.timestamp + req.duration;\n    loanID = loans.length;\n    loans.push(\n        Loan({\n            request: req,\n            amount: req.amount + interest,\n            unclaimed: 0,\n            collateral: collat,\n            expiry: expiration,\n            lender: msg.sender,\n            repayDirect: repayDirect_,\n            callback: isCallback_\n        })\n    );\n\n    // Clear the loan request storage.\n    requests[reqID_].active = false;\n\n    // Transfer debt tokens to the owner of the request.\n    debt().safeTransferFrom(msg.sender, owner(), req.amount);\n\n    // Log the event.\n    factory().newEvent(reqID_, CoolerFactory.Events.ClearRequest, 0);\n}\n```\n