Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: high
Invalid

Redundant depositing would break the logic and cause user loss of money

## Description

The logic within the deposit function transfers tokens from the user to the contract address (address(this)) and then calls the _deposit function. The flow of token deposits is as follows:

  • Tokens will be deposited into the withdrawal pool if there are queued withdrawals.

  • If there is available space, tokens will be deposited into the staking pool.

  • Any remaining tokens will be queued if _shouldQueue is set to true; otherwise, they will be returned to the sender.

This means that calling deposit() results in two transfer transactions, but one of these transactions does not get accounted for, leading to potential user loss of funds.

function deposit(uint256 _amount, bool _shouldQueue, bytes[] calldata _data) external {
if (_amount == 0) revert InvalidAmount();
//redundant depositing
token.safeTransferFrom(msg.sender, address(this), _amount);
_deposit(msg.sender, _amount, _shouldQueue, _data);
}
...
function _deposit(
address _account,
uint256 _amount,
bool _shouldQueue,
bytes[] memory _data
) internal {
.....
if (toDeposit != 0) {
if (_shouldQueue) {
_requireNotPaused();
if (accountIndexes[_account] == 0) {
accounts.push(_account);
accountIndexes[_account] = accounts.length - 1;
}
accountQueuedTokens[_account] += toDeposit;
totalQueued += toDeposit;
} else {
// bug redundant
token.safeTransfer(_account, toDeposit);
}
}
emit Deposit(_account, _amount - toDeposit, _shouldQueue ? toDeposit : 0);
}

Recommendations

remove this line token.safeTransferFrom(msg.sender, address(this), _amount); to avoid user loss of money

function deposit(uint256 _amount, bool _shouldQueue, bytes[] calldata _data) external {
if (_amount == 0) revert InvalidAmount();
//redundant depositing
-- token.safeTransferFrom(msg.sender, address(this), _amount); //remove this line
_deposit(msg.sender, _amount, _shouldQueue, _data);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Appeal created

4nonx Submitter
11 months ago
inallhonesty Lead Judge
10 months ago
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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