veToken Finance contest - ElKu's results

Lock more veAsset permanently.

General Information

Platform: Code4rena

Start Date: 26/05/2022

Pot Size: $75,000 USDT

Total HM: 31

Participants: 71

Period: 7 days

Judge: GalloDaSballo

Total Solo HM: 18

Id: 126

League: ETH

veToken Finance

Findings Distribution

Researcher Performance

Rank: 51/71

Findings: 2

Award: $151.99

🌟 Selected for report: 0

🚀 Solo Findings: 0

  1. In function https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DLocker.sol#L206, we could avoid extra storage reads by declaring the following in memory

rewardData[_rewardsToken].ve3Token, rewardData[_rewardsToken].ve3TokenStaking, rewardData[_rewardsToken].veAssetDeposits. Since the calls are made inside a for loop, this saves around 3100-32*3=282 gas per iteration.

  1. Very similar to the above point, in the function, https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L275 , the following state variables can be stored in memory before accessing them. rewardTokenInfo[_rewardToken].veAssetDeposits, rewardTokenInfo[_rewardToken].ve3Token, rewardTokenInfo[_rewardToken].ve3TokenRewards

They are all called inside a for loop, so this will save a lot of gas.

  1. The if statement here, https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/ExtraRewardStashV3.sol#L87 is redundant. You could simply assign tokenCount to i and save 100 gas.

  2. There is some redundancy in the claimRewards function. https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/ExtraRewardStashV1.sol#L77 to line 81 could be rewritten as:

    if (tokenInfo.token == address(0)) { setToken(); } else address tic = tokenInfo.token; address st = staker; uint256 before = IERC20(tic).balanceOf(st);

Thus replacing the two state variable reads to memory reads. It saves gas and increases code readability.

#0 - GalloDaSballo

2022-07-14T01:59:12Z

Less than 500 gas saved

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter