The calculateOpenParams function computes the flash loan amount and borrow amount needed to achieve a desired leverage. It performs multiple sequential integer divisions: first to compute the flash loan amount, then collateral value in USD, then borrow value in USD, then borrow amount in token units. Each division truncates the fractional remainder.
With tokens that have few decimals (e.g., USDC with 6, WBTC with 8, or exotic tokens with 2-4), the truncation from sequential integer divisions compounds. In the worst case, the flash loan fee calculation (flashLoanAmount * flashLoanFeeBps) / FLASHLOAN_FEE_PREC can truncate to zero, effectively providing a fee-free flash loan.
Likelihood:
The protocol is designed to work with USDC (6 decimals) and potentially other low-decimal tokens. With small position sizes in low-decimal tokens, each division truncates a proportionally larger amount.
The flashLoanFeeBps is 9 (0.09%), meaning flash loan amounts below ~1111 raw units result in a fee of zero: (1111 * 9) / 10000 = 0.
Impact:
Compounding rounding errors across five sequential divisions can cause borrowValueInCollateral to fall below minRequiredAfterSwap, making certain leverage ratios and position sizes impossible to execute despite being mathematically valid.
The zero-fee flash loan edge case means Aave does not receive its protocol fee for small positions, and the minRequiredAfterSwap check becomes less strict than intended.
The following arithmetic walkthrough shows that for a token with only 2 decimals, the flash loan fee formula (flashLoanAmount * 9) / 10000 truncates to zero when the raw amount is less than 1112 units. This effectively grants a fee-free flash loan. Even with 6-decimal USDC, very small positions experience proportionally significant truncation across the five sequential divisions.
Round the flash loan amount up instead of down so the fee calculation never truncates to zero, and add an explicit check that the flash loan fee is nonzero whenever a flash loan is taken. This prevents the fee-free edge case while preserving the existing calculation flow.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.