ThunderLoan.deposit() updates the asset token exchange rate using a fee calculated from the deposited amount.
However, due to integer division truncation in getCalculatedFee(), deposits below a certain threshold result in a zero fee.
When a zero fee is passed to updateExchangeRate():
The exchange rate does not increase, breaking protocol assumptions, or
The transaction reverts, depending on the strictness of the exchange-rate check
This creates inconsistent behavior for small deposits and allows fee evasion via deposit splitting.
getCalculatedFee() performs two integer divisions using s_feePrecision, which causes the fee to round down to zero for small values:
Likelihood
if valueOfBorrowedToken < s_feePrecision / s_flashLoanFee
Impact:
then fee == 0
assetToken.updateExchangeRate(calculatedFee) will revert ;
## Description getCalculatedFee can be as low as 0 ## Vulnerability Details Any value up to 333 for "amount" can result in 0 fee based on calculation ``` function testFuzzGetCalculatedFee() public { AssetToken asset = thunderLoan.getAssetFromToken(tokenA); uint256 calculatedFee = thunderLoan.getCalculatedFee( tokenA, 333 ); assertEq(calculatedFee ,0); console.log(calculatedFee); } ``` ## Impact Low as this amount is really small ## Recommendations A minimum fee can be used to offset the calculation, though it is not that important.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.