Omniscia Maverick Protocol Audit

HistoricalBalance Code Style Findings

HistoricalBalance Code Style Findings

HBE-01C: Redundant Safe Casting

Description:

The referenced SafeCast::toUint48 operation is redundant as the if conditional that precedes it ensures the timepoint is less than the currentTimepoint which in turn is a uint48 variable.

Example:

v2-rewards/contracts/votingescrowbase/HistoricalBalance.sol
29/// @inheritdoc IHistoricalBalance
30function getPastBalanceOf(address account, uint256 timepoint) public view returns (uint256 balance) {
31 uint48 currentTimepoint = clock();
32 if (timepoint >= currentTimepoint) {
33 revert ERC5805FutureLookup(timepoint, currentTimepoint);
34 }
35 return _balanceOfCheckpoints[account].upperLookupRecent(SafeCast.toUint48(timepoint));
36}

Recommendation:

We advise the safe casting operation to be omitted, optimizing the gas cost of the function.

Alleviation (07ad29f773f16bdfbae3d97d3a7c2f9d64866093):

The redundant safe casting operation has been omitted, optimizing the code's gas cost.