getCalculatedFee computes the fee in two steps: first valueOfBorrowedToken = (amount * price) / feePrecision, then fee = (valueOfBorrowedToken * flashLoanFee) / feePrecision. The first division loses precision before the second multiplication, so for inputs where amount * price < feePrecision, the intermediate valueOfBorrowedToken rounds to 0 and the final fee is 0.
A flash loaner can request a tiny amount (e.g. 1 wei of an 18-decimal token) and the fee will be 0. The pool transfers the loaner the tokens for free; the loaner only needs to return what was borrowed. While the absolute amount per call is microscopic, the issue indicates a precision flaw in the fee calculation that may also produce undercharge for non-trivial loans with low-priced tokens.
Likelihood:
Any caller can request a flash loan of 1 wei and receive a zero fee.
The precision-loss arithmetic also undercharges for genuinely-low-value tokens or for borrowers who fragment their loans into small parallel calls.
Impact:
Direct revenue loss for LPs on small loans.
The bug is bounded in size for each individual call (only large enough to consume gas), but reflects a systemic mis-ordering of arithmetic operations that should be fixed for correctness across the wider input domain.
Output: fee for 1 wei of token: 0. A flash loan of 1 wei costs nothing.
Reorder to multiply before dividing, eliminating the intermediate truncation:
Optionally, enforce a minimum fee of 1 wei to guarantee non-zero billing for all positive-amount loans:
## 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.