StargateEthPoolStrategy deallocate function redeem weth using native token , however the amount of weth is less than expected , which can lead to Strategy balance is less than the amount needed revert.
Vulnerability Details
From the StargateEthPoolStrategy.sol::_deallocate()
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){emitStrategyDeallocationLoss("Strategy deallocation loss which includes rounding loss.", amount, ethRedeemed);}if(ethRedeemed + ethBalanceBefore >= amount){//@audit ? weth.deposit{value: ethRedeemed}();}require(TokenUtils.safeBalanceOf(address(weth),address(this))>= amount,"Strategy balance is less than the amount needed");
The value ethRedeemed is used to redeem WETH. However, the pool.redeem() function returns a smaller amount of native tokens than the input value due to rounding down.
Impact Details
1.the _deallocate function revert lead to assets become stuck in the contract
[PASS] test_POC_10() (gas: 380096)
Logs:
deallocateAmount: 2222222222123456789
weth redeemed: 2222222000000000000
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.07s (2.92ms CPU time)
Ran 1 test suite in 1.07s (1.07s CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)