58115 sc medium incorrect weth deposit amount prevents deposited eth through receive function to cover strategy loss
Description
Brief/Intro
function _deallocate(uint256 amount) internal override returns (uint256) {
// Compute LP needed ∝ TVL to withdraw `amount` underlying
// For Stargate, LP tokens are 1:1 with underlying
// So we can just redeem the amount directly
uint256 lpBalance = lp.balanceOf(address(this));
uint256 lpNeeded = amount; // 1:1 ratio
// Cap at available LP balance
if (lpNeeded > lpBalance) {
lpNeeded = lpBalance;
}
// Redeem LP to native ETH, then wrap back to WETH
lp.approve(address(pool), lpNeeded);
uint256 ethBalanceBefore = address(this).balance;
pool.redeem(lpNeeded, address(this));
uint256 ethBalanceAfter = address(this).balance;
uint256 ethRedeemed = ethBalanceAfter - ethBalanceBefore;
if (ethRedeemed < amount) {
emit StrategyDeallocationLoss("Strategy deallocation loss which includes rounding loss.", amount, ethRedeemed);
}
if (ethRedeemed + ethBalanceBefore >= amount) {
weth.deposit{value: ethRedeemed}();
}
require(TokenUtils.safeBalanceOf(address(weth), address(this)) >= amount, "Strategy balance is less than the amount needed");
TokenUtils.safeApprove(address(weth), msg.sender, amount);
return amount;
}Vulnerability Details
Impact Details
Proof of Concept
Proof of Concept
Previous57036 sc high unconditional debt reduction before protocol fee check in force repayment Next56873 sc medium incorrect eth wrapping condition in moonwellwethstrategy deallocate leads to temporary freezing of funds
Was this helpful?