code-423n4 / 2021-08-yield-findings

1 stars 0 forks source link

Using parameters or local variables instead of state variables in event emits can save gas #44

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

0xRajeev

Vulnerability details

Impact

Event emits where there are equivalent local variables or parameters for state variables can save gas by using those instead of state variables because of the expensive SLOADs.

Proof of Concept

rewardsToken: https://github.com/code-423n4/2021-08-yield/blob/4dc46470e616dd0cbd9db9b4742e36c4d809e02c/contracts/utils/token/ERC20Rewards.sol#L97

delay: https://github.com/code-423n4/2021-08-yield/blob/4dc46470e616dd0cbd9db9b4742e36c4d809e02c/contracts/utils/TimeLock.sol#L51

Tools Used

Manual Analysis

Recommended Mitigation Steps

Use parameters or local variables instead of state variables in event emits

alcueca commented 3 years ago

Fix as part of making the rewards token immutable

alcueca commented 3 years ago

Timelock fix