The function _forceRepay is designed in a way where if the collateralBalance is smaller than the protocolFeeTotal, the account doesn't pay for the fee. This design makes the protocol lose on potential fees. The code could be changed in a way that if the account doesn't have enough, the code will attempt to decrease the fee to the account collateral, so at least a part of it is paid, making the most out of it.
Vulnerability Details
If the account doesn't have enough to pay for the fee, the fee is not deducted from account's collateral.
This behavior could be changed so the fee is then decreased at least to the colalteral balance so at least a part of the fee is taken.
Code snippet:
if(account.collateralBalance > protocolFeeTotal){ account.collateralBalance -= protocolFeeTotal;// Transfer the protocol fee to the protocol fee receiver TokenUtils.safeTransfer(myt, protocolFeeReceiver, protocolFeeTotal);}
This code could be changed into clamping the fee if its larger so at least minimum is taken. This could be the change:
Impact Details
The impact is that the protocol is losing on a potential profits that could be made if the account still has some collateral.
The protocol could take at least a part of the fee, if not the full amount.