The calculateDustAmount
function in the RToken
contract is supposed to identify extra tokens (dust) in the contract that are not accounted for by the total RToken supply
. This dust calculation is used by the protocol owner to withdraw fees. However, the function incorrectly depends on the contract’s own ERC20 balance, ignoring assets that could be held in a Curve vault or removed due to borrow actions. As a result, the calculated dust amount may stay at zero, preventing the owner from withdrawing fees.
Vault Deposits Ignored: If some assets are deposited in a Curve vault, the RToken contract no longer holds them directly. Thus, using IERC20(_assetAddress).balanceOf(address(this))
underestimates the protocol’s total assets.
Borrowed Assets Not Reflected: When a user borrows tokens, the protocol’s total supply might not decrease accordingly, and this mismatch skews the dust calculation.
Incorrect Dust Logic: The function calculates dust by comparing contractBalance and totalRealBalance. But if contractBalance is less than expected due to external vaults or borrowing, the function returns zero dust, effectively blocking fee withdrawals.
Additionally, the calculateDustAmount function is incorrectly implemented. However, this is not relevant to the vulnerability in the current report, so I'll cover it in another report.
Because the dust always appears to be zero in some scenarios, the owner cannot withdraw protocol fees. This can lead to fee revenue getting stuck in the protocol without any easy mechanism to claim it, reducing the protocol’s ability to properly allocate funds.
Manual Code Review and Foundry
Include All Assets in the Calculation
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.