```\n function deposit(uint256 _underlyingAmount, address _receiver)\n    external\n    override\n    whenNotPaused\n    nonReentrant\n  {\n    _deposit(_underlyingAmount, _receiver);\n  }\n\n  function _deposit(uint256 _underlyingAmount, address _receiver) internal {\n    /// Verify that the pool is not in OpenToBuyers phase\n    if (poolInfo.currentPhase == ProtectionPoolPhase.OpenToBuyers) {\n      revert ProtectionPoolInOpenToBuyersPhase();\n    }\n\n    uint256 _sTokenShares = convertToSToken(_underlyingAmount);\n    totalSTokenUnderlying += _underlyingAmount;\n    _safeMint(_receiver, _sTokenShares);\n    poolInfo.underlyingToken.safeTransferFrom(\n      msg.sender,\n      address(this),\n      _underlyingAmount\n    );\n\n    /// Verify leverage ratio only when total capital/sTokenUnderlying is higher than minimum capital requirement\n    if (_hasMinRequiredCapital()) {\n      /// calculate pool's current leverage ratio considering the new deposit\n      uint256 _leverageRatio = calculateLeverageRatio();\n\n      if (_leverageRatio > poolInfo.params.leverageRatioCeiling) {\n        revert ProtectionPoolLeverageRatioTooHigh(_leverageRatio);\n      }\n    }\n\n    emit ProtectionSold(_receiver, _underlyingAmount);\n }\n```\n