The contract allows users to specify an amount for redemption. If a user inputs type(uint256).max, the system correctly defaults to withdrawing their full balance. However, if the user enters a very large number close to uint256.max but higher than their actual balance, the transaction will fail due to insufficient balance. This results in a poor user experience, wasted gas fees, and unnecessary transaction failures.
Affected code in AaveDIVAWrapperCore:
The logic correctly handles the type(uint256).max case by setting _positionTokenAmountToRedeem = _userBalance.
However, when a user enters a very large number less than type(uint256).max but greater than _userBalance, the contract proceeds with the entered number without checking if the balance is sufficient.
This leads to a transaction failure (revert) when the contract attempts to transfer more tokens than the user owns.
Failed transactions: If a user unknowingly enters a large number, they will experience failed transactions and lose gas fees.
Poor user experience: Users may assume they are redeeming all tokens but will face unnecessary reverts.
Gas inefficiency: The revert will cost gas, which could have been avoided with a proper check.
Manuel Review
Modify the logic to automatically cap the input to the user’s balance if the entered value exceeds the available balance.
| Condition | Old Behavior | New Behavior |
|---|---|---|
| User enters type(uint256).max | Withdraws all tokens (correct) | Withdraws all tokens (correct) |
| User enters a number greater than their balance | Transaction reverts | Withdraws max available balance |
| User enters a valid amount within balance | Works fine | Works fine |
This change ensures a smooth user experience, prevents unnecessary transaction failures, and reduces wasted gas fees.
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.