20,000 USDC
View results
Submission Details
Severity: medium
Valid

If borrower / lender fee is zero, tokens that revert on zero-value transfer will not work as intended

Summary

There are certain ERC20 tokens which revert on zero value transfers (e.g. LEND). If borrower fee is zero, nobody will be able to borrow as the transaction will always revert. If lender fee is zero, functions such as repay, buyloan, giveLoan will not work as transaction will always revert when transferring 0 tokens to the feeReceiver

Vulnerability Details

The protocol intends to use any type of ERC20 tokens. There are some ERC20 tokens that revert on zero-value transfer. The owner of the protocol can set the lender/borrower fee, and they may set it to be zero to attract users to use their protocol.

function setLenderFee(uint256 _fee) external onlyOwner {
if (_fee > 5000) revert FeeTooHigh();
lenderFee = _fee;
}
function setBorrowerFee(uint256 _fee) external onlyOwner {
if (_fee > 500) revert FeeTooHigh();
borrowerFee = _fee;
}

Some ERC20 tokens, like LEND, will revert on zero-value transfer. If LEND is used as a loan token and borrower fee is zero, the zero value will still be transferred to the feeReceiver. This will break the borrow() function.

// calculate the fees
uint256 fees = (debt * borrowerFee) / 10000;
// transfer fees
IERC20(loan.loanToken).transfer(feeReceiver, fees);
// transfer the loan tokens from the pool to the borrower

Similarly, if lenderFee is zero, then protocolInterest will be zero. Zero-value will be transferred to the feeReceiver, which will break repay().

// transfer the protocol fee to the fee receiver
IERC20(loan.loanToken).transferFrom(
msg.sender,
feeReceiver,
protocolInterest
);

Impact

Tokens that revert on zero-value transfer will not work in the protocol.

Tools Used

Manual Review

Recommendations

Address ERC20 tokens which revert on 0 value transfers. Check if there is any fees incurred before transferring the fee to the fee receiver. For example,

// calculate the fees
uint256 fees = (debt * borrowerFee) / 10000;
// transfer fees
+ if(fees > 0){
IERC20(loan.loanToken).transfer(feeReceiver, fees);
}

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.