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.
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.
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.
Later, the user attempts to remove liquidity by calling removeLiquidity
with _positionTokenAmount = 100
.
The contract calls _redeemWTokenPrivate
to burn 100 wUSDC and withdraw 100 USDC from Aave.
However, _redeemWTokenPrivate
attempts to burn wUSDC from the caller's balance (msg.sender
), not the contract's balance.
Since the caller does not hold any wUSDC, the transaction reverts, and the user cannot remove their liquidity.
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.
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.