TempleGold

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

Batch Migration for migrateWithdraw Function

Summary

The current implementation of the migrateWithdraw() function of the TempleGoldStaking.sol contract processes withdrawals for individual stakers one at a time. This design can lead to high gas costs, network congestion, and a poor user experience when there are many stakers. By adding a batch migration feature, the function can process multiple withdrawals in a single transaction, optimizing efficiency and reducing overall costs.

Vulnerability Details

The migrateWithdraw() function is designed to handle withdrawals for individual stakers:

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;
}

This approach has several drawbacks: Each transaction incurs gas fees, which can become prohibitive when many stakers are involved and multiple simultaneous transactions can congest the network.

Impact

The individual processing of withdrawals can significantly impact the overall efficiency and cost-effectiveness of the contract.

Tools Used

Manual review.

Recommendations

Add a batch migration feature to the migrateWithdraw function:

function batchMigrateWithdraw(address[] calldata stakers, uint256[] calldata indices) external override onlyMigrator returns (uint256) {
[...]
Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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