Omniscia rain protocol Audit

TierwiseCombine Code Style Findings

TierwiseCombine Code Style Findings

TCE-01C: Potential User-Defined Value Type

Description:

Given that the "report" type is a special purpose uint256 value, the legibility of the codebase and library usages can be optimized by defining a custom user-value type.

Example:

contracts/tier/libraries/TierwiseCombine.sol
39uint256 newerBlock_ = TierReport.tierBlock(newerReport_, tier_);
40uint256 olderBlock_ = TierReport.tierBlock(olderReport_, tier_);
41uint256 diff_ = newerBlock_.saturatingSub(olderBlock_);
42ret_ = TierReport.updateBlockAtTier(ret_, tier_ - 1, diff_);

Recommendation:

We advise one to be defined for the "report" data type (i.e. type Report is uint256;) to optimize library usages and permit statements such as using TierReport for Report; without affecting the functions exposed by the "basic" data types (i.e. avoid using TierReport for uint256;). This finding will not be replicated across the codebase, however, it is applicable to many instances.

Alleviation:

The Rain Protocol team stated that they will experiment with a user-defined value type in place of the tiers and make the relevant changes in the main branch if deemed optimal. As a result, we consider this exhibit acknowledged.