/**
* @dev Process user deposit, mints liquid tokens and increase the pool buffer
* @param _referral address of referral.
* @return amount of StETH shares generated
*/
function _submit(address _referral) internal returns (uint256) {
require(msg.value != 0, "ZERO_DEPOSIT");
StakeLimitState.Data memory stakeLimitData = STAKING_STATE_POSITION.getStorageStakeLimitStruct();
// There is an invariant that protocol pause also implies staking pause.
// Thus, no need to check protocol pause explicitly.
require(!stakeLimitData.isStakingPaused(), "STAKING_PAUSED");
if (stakeLimitData.isStakingLimitSet()) {
uint256 currentStakeLimit = stakeLimitData.calculateCurrentStakeLimit();
require(msg.value <= currentStakeLimit, "STAKE_LIMIT");
STAKING_STATE_POSITION.setStorageStakeLimitStruct(stakeLimitData.updatePrevStakeLimit(currentStakeLimit - msg.value));
}
uint256 sharesAmount = getSharesByPooledEth(msg.value);
_mintShares(msg.sender, sharesAmount);
_setBufferedEther(_getBufferedEther().add(msg.value));
emit Submitted(msg.sender, msg.value, _referral);
_emitTransferAfterMintingShares(msg.sender, sharesAmount);
@> return sharesAmount;
}
So yieldAmount is wrong, and the returned stETH.shares should be converted to stETH.assets via IStETH.getPooledEthByShares()
Impact
yieldAmount is wrong it will be small, causing yieldShare to be small as well, and the corresponding nft's gain will be smaller
Corresponding to a vault managing all nft earnings uniformly will cause nft rewards to be distributed incorrectly.
Lines of code
https://github.com/code-423n4/2024-07-benddao/blob/117ef61967d4b318fc65170061c9577e674fffa1/src/yield/lido/YieldEthStakingLido.sol#L77
Vulnerability details
Vulnerability details
in
YieldEthStakingLido.sol
whenstake()
, we need to computeyieldShare
Step one:
totalYieldBeforeDeposit = stETH.balanceOf(account) = in stETH.sol => getPooledEthByShares()
stETH is rebase ,
totalYieldBeforeDeposit = stETH.balanceOf()
isstETH.assets
, notstETH.shares
.But in the second step,
protocolDeposit()
returnsstETH.shares
, notstETH.assets
.https://github.com/lidofinance/lido-dao/blob/5fcedc6e9a9f3ec154e69cff47c2b9e25503a78a/contracts/0.4.24/Lido.sol#L922
protocolDeposit()
->StETH.submit
So
yieldAmount
is wrong, and the returnedstETH.shares
should be converted tostETH.assets
viaIStETH.getPooledEthByShares()
Impact
yieldAmount
is wrong it will be small, causingyieldShare
to be small as well, and the corresponding nft's gain will be smaller Corresponding to a vault managing all nft earnings uniformly will cause nft rewards to be distributed incorrectly.Recommended Mitigation
Assessed type
Context