In AssetToken::updateExchangeRate(), accrued fees from flash loans are meant to increase the exchange rate so that liquidity providers earn yield proportional to pool activity.
The formula s_exchangeRate = s_exchangeRate + (fee * s_exchangeRatePrecision) / totalSupply() suffers from integer division truncation in Solidity. When (fee * s_exchangeRatePrecision) < totalSupply(), the fee increment truncates to zero, effectively burning the fee without updating the exchange rate.
Likelihood:
Occurs whenever flash loan fees generated by a transaction are small relative to the total share supply.
Occurs with high frequency in deep liquidity pools where totalSupply() is large.
Impact:
Permanent loss of yield for liquidity providers due to fee burn.
Flash loans revert unexpectedly when newExchangeRate <= s_exchangeRate, causing Denial of Service.
The exploit operates through the following steps:
Pool has a large liquidity supply (e.g., 10,000e18 shares).
A borrower takes a flash loan that generates a small fee (e.g., 1 wei).
(1 * 1e18) / 10,000e18 evaluates to 0 due to integer division truncation.
newExchangeRate <= s_exchangeRate triggers, reverting the flash loan and burning the fee.
Track accrued fees in an accumulator variable or scale s_exchangeRatePrecision to 1e27 ray precision to prevent precision loss.
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.