code-423n4 / 2022-01-trader-joe-findings

2 stars 0 forks source link

Change unnecessary storage variables to constants can save gas #239

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

https://github.com/code-423n4/2022-01-trader-joe/blob/a1579f6453bc4bf9fb0db9c627beaa41135438ed/contracts/RocketJoeStaking.sol#L39-L39

uint256 private PRECISION;

https://github.com/code-423n4/2022-01-trader-joe/blob/a1579f6453bc4bf9fb0db9c627beaa41135438ed/contracts/RocketJoeStaking.sol#L57-L76

function initialize(
    IERC20Upgradeable _joe,
    RocketJoeToken _rJoe,
    uint256 _rJoePerSec,
    uint256 _startTime
) public initializer {
    // ...
    PRECISION = 1e18;
    // ...
}

Some storage variables include PRECISION will never be changed and they should not be.

Changing them to constant can save gas.

cryptofish7 commented 2 years ago

Can’t have constants in proxy contracts

dmvt commented 2 years ago

Per sponsor, this is invalid because the contract in question is proxied.