Open code423n4 opened 3 years ago
Neat usage of ternary operator to simplify the code, I believe this will save gas on the deployment but not on the execution
A bigger "red flag" seems to be the usage of the same function as both public and private, the public function can already be used in the contract, rendering the private function superfluous
Handle
ye0lde
Vulnerability details
Impact
Removing unnecessary initializations and branches can result in gas savings and code clarity.
Proof of Concept
The function that can be rewritten is here: https://github.com/code-423n4/2021-10-union/blob/4176c366986e6d1a6b3f6ec0079ba547b040ac0f/contracts/user/UserManager.sol#L794-L814
Tools Used
Visual Studio Code, Remix
Recommended Mitigation Steps
I suggest changing getFrozenCoinAge as follows:
function getFrozenCoinAge(address staker, uint256 pastBlocks) public view override returns (uint256) { uint256 totalFrozenCoinAge;
}