HardhatDeFi
15,000 USDC
View results
Submission Details
Severity: medium
Invalid

`_redeemWTokenPrivate` attempts to burn wTokens from the caller's balance (msg.sender), not the contract's balance

The functions _removeLiquidity and _redeemPositionToken call _redeemWTokenPrivate to withdraw collateral from Aave and burn wTokens. However, there is a critical flaw in how the _redeemWTokenPrivate function is used in these contexts. Specifically, the _redeemWTokenPrivate function burns wTokens from the caller's balance, but in _removeLiquidity and _redeemPositionToken, the wTokens are owned by the contract itself, not the caller. This mismatch can lead to unintended behavior and potential loss of funds.
In _removeLiquidity and _redeemPositionToken, the wTokens are minted to the contract's address when liquidity is added or position tokens are redeemed. However, when _redeemWTokenPrivate is called, it attempts to burn wTokens from the caller's balance (msg.sender), not the contract's balance. This will fail if the caller does not hold the required wTokens, leading to a revert.

Impact:

  • The functions _removeLiquidity and _redeemPositionToken will fail to execute if the caller does not hold the required wTokens. This prevents users from removing liquidity or redeeming position tokens, effectively locking their funds in the contract.

Example Scenario:

  1. A user adds liquidity to a DIVA pool by supplying 100 USDC. The contract mints 100 wUSDC to itself and supplies the 100 USDC to Aave.

  2. Later, the user attempts to remove liquidity by calling removeLiquidity with _positionTokenAmount = 100.

  3. The contract calls _redeemWTokenPrivate to burn 100 wUSDC and withdraw 100 USDC from Aave.

  4. However, _redeemWTokenPrivate attempts to burn wUSDC from the caller's balance (msg.sender), not the contract's balance.

  5. Since the caller does not hold any wUSDC, the transaction reverts, and the user cannot remove their liquidity.

Fix:

The _redeemWTokenPrivate function should burn wTokens from the contract's balance, not the caller's balance, when called by _removeLiquidity and _redeemPositionToken. This can be achieved by passing the contract's address (address(this)) as the _burnFrom parameter in these functions.

Updates

Lead Judging Commences

bube Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.