TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: medium
Invalid

Users are going to waste gas fees when migrating stakes to a new staking contract

Summary

When a new staking contract is available users can migrate to them by calling migrateWithdraw, to move their stake index to the new contract. However if a user have a large stake migrating them one by one will cost more gas for the user.

Vulnerability Details

https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol%2Fcontracts%2Ftemplegold%2FTempleGoldStaking.sol#L168

function migrateWithdraw(address staker, uint256 index) external override onlyMigrator returns (uint256) {
if (staker == address(0)) { revert CommonEventsAndErrors.InvalidAddress(); }
StakeInfo storage _stakeInfo = _stakeInfos[staker][index];
uint256 stakerBalance = _stakeInfo.amount;
_withdrawFor(_stakeInfo, staker, msg.sender, index, _stakeInfo.amount, true, staker);
return stakerBalance;
}

Users only have the capacity to migrate one index at a time this might lead to loss of opportunity for staker if the new staking contract offers more rewards.

Impact

High gas fees to migrate large indexes and loss of opportunity.

Tools Used

Manual Review

Recommendations

Allow users migrate in batches

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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