Beginner FriendlyFoundryDeFiOracle
100 EXP
View results
Submission Details
Severity: high
Invalid

Missing return value in `ThunderLoan:getCalculatedFee()` & `ThunderLoanUpgraded:getCalculatedFee()` functions

Summary

Missing return value in ThunderLoan:getCalculatedFee() function.

Vulnerability Details

There is no value returned by the ThunderLoan:getCalculatedFee() function. As a result, the default return value from the getCalculatedFee() function will be 0. which means that the liquidity provides will not receive any kind of fee against their staked assets.

Lines of Code

https://github.com/Cyfrin/2023-11-Thunder-Loan/blob/main/src/protocol/ThunderLoan.sol#L246

Impact

As a result, the default return value from the getCalculatedFee() function will be 0. which means that the liquidity provides will not receive any kind of fee against their staked assets and the protocol exchange fee i.e. s_exchangeRate will be set to 0.

Tools Used

Manual review

Recommendations

// before
function getCalculatedFee(IERC20 token, uint256 amount) public view returns (uint256 fee) {
//slither-disable-next-line divide-before-multiply
uint256 valueOfBorrowedToken = (amount * getPriceInWeth(address(token))) / s_feePrecision;
//slither-disable-next-line divide-before-multiply
fee = (valueOfBorrowedToken * s_flashLoanFee) / s_feePrecision;
}
// after
function getCalculatedFee(IERC20 token, uint256 amount) public view returns (uint256 fee) {
[...]
fee = (valueOfBorrowedToken * s_flashLoanFee) / s_feePrecision;
return fee;
}
Updates

Lead Judging Commences

0xnevi Lead Judge
almost 2 years ago
0xnevi Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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