    function checkMaxShares(
        uint256 _nftId,
        address _tokenToPayback,
        uint256 _borrowETHTotal,
        uint256 _unweightedCollateralETH,
        uint256 _shareAmountToPay
    )
        public
        view
    {
        //@audit-ok => total borrowShares a position owns for a _tokenToPayback pool
        uint256 totalSharesUser = WISE_LENDING.getPositionBorrowShares(
            _nftId,
            _tokenToPayback
        );

        //@audit-info => If baddebt, maxShares that can be liquidated are the totalSharesUser
        //@audit-info => If not baddebt, maxShares can be 50% of the total borrowShares
        uint256 maxShares = checkBadDebtThreshold(_borrowETHTotal, _unweightedCollateralETH)
            ? totalSharesUser
            : totalSharesUser * MAX_LIQUIDATION_50 / PRECISION_FACTOR_E18;

        if (_shareAmountToPay <= maxShares) {
            return;
        }

        //@audit-issue => reverts if the amount of shares to be repaid exceeds maxShares!
        revert TooManyShares();
    }
    function checksLiquidation(
        ...
        uint256 _shareAmountToPay
    )
        external
        view
    +   returns (uint256)
    {
        ...


    -   checkMaxShares(
    +   return checkMaxShares( 
            _nftIdLiquidate,
            _tokenToPayback,
            borrowETHTotal,
            unweightedCollateralETH,
            _shareAmountToPay
        );
    }
function checkMaxShares(
    ...
    uint256 _shareAmountToPay
)
    public
    view
+   returns (uint256)    
{
    ...

    uint256 maxShares = checkBadDebtThreshold(_borrowETHTotal, _unweightedCollateralETH)
            ? totalSharesUser
            : totalSharesUser * MAX_LIQUIDATION_50 / PRECISION_FACTOR_E18;

    if (_shareAmountToPay <= maxShares) {
-       return;
+       return _shareAmountToPay;
+   } else {
+       return maxShares;
+   }

-   revert TooManyShares();
}
    function liquidatePartiallyFromTokens(
        ...
        uint256 _shareAmountToPay
    )
        ...
    {
        ...

    -   data.shareAmountToPay = _shareAmountToPay;

        ...

        //@audit-info => First, determine the maximum amount of liquidable shares
    +   data.shareAmountToPay = WISE_SECURITY.checksLiquidation(
    +     _nftId,
    +     _paybackToken,
    +     _shareAmountToPay
    +   );

        //@audit-info => Then, compute the exact amount of tokens required to liquidate the final amount of liquidable shares
        data.paybackAmount = paybackAmount(
            _paybackToken,
    -       _shareAmountToPay
    +       data.shareAmountToPay
        );

        ...

    -   WISE_SECURITY.checksLiquidation(
    -       _nftId,
    -       _paybackToken,
    -       _shareAmountToPay
    -   );

        ...
    }
