Vulnerability: On liquidation, if netPnLE36 <= 0, the premium paid by the liquidator is locked in the contract.
Severity: high

Description:
When liquidating a position, the liquidator is required to pay premium to Lender, which is accumulated in sharingProfitTokenAmts together with Lender's profit and paid to Lender in `_shareProfitsAndRepayAllDebts()`.\\n```\\n        (\\n        netPnLE36,\\n             lenderProfitUSDValueE36,\\n                 borrowTotalUSDValueE36,\\n                     positionOpenUSDValueE36,\\n                      sharingProfitTokenAmts ) = calcProfitInfo(_positionManager, _user, _posId);\\n        // 2. add liquidation premium to the shared profit amounts\\n                            uint lenderLiquidatationPremiumBPS = IConfig(config).lenderLiquidatePremiumBPS();\\n                         for (uint i; i < sharingProfitTokenAmts.length; ) {\\n                    sharingProfitTokenAmts[i] +=\\n                (pos.openTokenInfos[i].borrowAmt * lenderLiquidatationPremiumBPS) / BPS;\\n        unchecked {\\n        ++i;\\n        }\\n        }\\n```\\n\\nHowever, if netPnLE36 <= 0, `_shareProfitsAndRepayAllDebts()` will not pay any profit to Lender and the premium in sharingProfitTokenAmts will also not be paid to Lender, which means that the premium paid by the liquidator will be locked in the contract.\\n```\\n            function _shareProfitsAndRepayAllDebts( address _positionManager, address _posOwner, uint _posId,\\n                    int _netPnLE36, uint[] memory _shareProfitAmts, address[] memory _tokens,\\n                         OpenTokenInfo[] memory _openTokenInfos\\n                              ) internal {\\n                    // 0. load states\\n            address _lendingProxy = lendingProxy;\\n                    // 1. if net pnl is positive, share profits to lending proxy\\n                 if (_netPnLE36 > 0) {\\n            for (uint i; i < _shareProfitAmts.length; ) {\\n                if (_shareProfitAmts[i] > 0) {\\n                    ILendingProxy(_lendingProxy).shareProfit(_tokens[i], _shareProfitAmts[i]);\\n                 }\\n                     unchecked {\\n                         ++i;\\n                      }\\n                  }\\n            emit ProfitShared(_posOwner, _posId, _tokens, _shareProfitAmts);\\n            }\\n```\\n\\nAlso, when the position is closed, the tokens in the contract will be sent to the caller, so the next person who closes the position will get the locked tokens.\\n```\\n            underlyingAmts = new uint[](underlyingTokens.length);\\n                    for (uint i; i < underlyingTokens.length; ) {\\n                        underlyingAmts[i] = IERC20(underlyingTokens[i]).balanceOf(address(this));\\n                             if (underlyingAmts[i] < _params.minUnderlyingAmts[i]) {\\n                                 revert TokenAmountLessThanExpected(\\n                         underlyingTokens[i],\\n                      underlyingAmts[i],\\n                 _params.minUnderlyingAmts[i]\\n              );\\n            }\\n            _doRefund(underlyingTokens[i], underlyingAmts[i]);\\n                 unchecked {\\n                      ++i;\\n                  }\\n```\\n

Impact:

Recommended mitigation:
Modify `shareProfitsAndRepayAllDebts()` as follows:\\n```\\n            function _shareProfitsAndRepayAllDebts(\\n                     address _positionManager,\\n                         address _posOwner,\\n                            uint _posId,\\n                            int _netPnLE36,\\n                             uint[] memory _shareProfitAmts,\\n                            address[] memory _tokens,\\n                        OpenTokenInfo[] memory _openTokenInfos\\n                      ) internal {\\n                  // 0. load states\\n                 address _lendingProxy = lendingProxy;\\n                // 1. if net pnl is positive, share profits to lending proxy\\n            - if (_netPnLE36 > 0) {\\n                for (uint i; i < _shareProfitAmts.length; ) {\\n            if (_shareProfitAmts[i] > 0) {\\n                ILendingProxy(_lendingProxy).shareProfit(_tokens[i], _shareProfitAmts[i]);\\n            }\\n            unchecked {\\n            ++i;\\n            }\\n            }\\n            emit ProfitShared(_posOwner, _posId, _tokens, _shareProfitAmts);\\n            - }\\n```\\n