BlueBundlesV1::blueBundlesV1RepayAndWithdrawCollateral() may transfer a null leftover
Summary
The leftover transfer in BlueBundlesV1::blueBundlesV1RepayAndWithdrawCollateral() is not skipped when null, unlike the referral fee transfer above it (and on the rest of the codebase).
Vulnerability Detail
maxRepayAssets - repayAssets - referralFeeAssets is 0 whenever maxRepayAssets exactly covers the repaid assets plus the fee, which is the natural sizing on an exact assets repay with a null referral fee (maxRepayAssets == repayAssets).
Impact
Tokens reverting on 0 transfer are not supported, so the only impact is consistency throughout the codebase.
Code Snippet
SafeTransferLib.safeTransfer(
marketParams.loanToken, msg.sender, maxRepayAssets - repayAssets - referralFeeAssets
);Tool Used
Manual Review
Recommendation
Skip the transfer when the amount is null, consistent with the rest of the codebase.