Omniscia Pirex Audit
PirexCvx Code Style Findings
PirexCvx Code Style Findings
PCV-01C: Illegible Numeric Value Representation
Type | Severity | Location |
---|---|---|
Code Style | PirexCvx.sol:L73 |
Description:
The linked representation of a numeric literal is sub-optimally represented decreasing the legibility of the codebase.
Example:
73uint32 public constant FEE_DENOMINATOR = 1000000;
Recommendation:
To properly illustrate the value's purpose, we advise the following guidelines to be followed.
For values meant to depict fractions with a base of 1e18
, we advise fractions to be utilized directly (i.e. 1e17
becomes 0.1e18
) as they are supported.
For values meant to represent a percentage base, we advise each value to utilize the underscore (_
) separator to discern the percentage decimal (i.e. 10000
becomes 100_00
, 300
becomes 3_00
and so on).
Finally, for large numeric values we simply advise the underscore character to be utilized again to represent them (i.e. 1000000
becomes 1_000_000
).
Alleviation:
The underscore denominator is now utilized in the codebase. While our original suggestion was the usage of the numeric separator to differentiate the "percentage" of the denominator (i.e. 1000000
should have become 100_0000
), the Pirex team opted to use the separator solely for where commas would normally go and this is an adequate resolution to this exhibit.
PCV-02C: Inefficient Storage Value Reads
Type | Severity | Location |
---|---|---|
Gas Optimization | PirexCvx.sol:L280, L283, L284 |
Description:
The unionPirex
member from storage is read three times redundantly as it only needs to be read once.
Example:
280if (address(unionPirex) != address(0)) {281 pxCvx.approve(address(unionPirex), 0);282}283unionPirex = UnionPirexVault(contractAddress);284pxCvx.approve(address(unionPirex), type(uint256).max);
Recommendation:
We advise it to be read and stored to a local variable for the first two utilizations and for the last utilization we advise the contractAddress
argument to be utilized directly instead, optimizing the function's gas cost. Similar optimizations are applicable throughout the contract such as for the emergencyMigrateTokens
function, however, they will not be listed for the sake of brevity.
Alleviation:
The first optimization was applied as advised and the secondary optimization was deemed as increasing the gas cost of the contract and thus is not applied in the codebase. As a result, we consider this exhibit alleviated.
PCV-03C: Suboptimal Numeric Representation
Type | Severity | Location |
---|---|---|
Code Style | PirexCvx.sol:L70, L76 |
Description:
The linked numeric literal representations are meant to showcase 2 weeks and 17 weeks respectively, however, they are represented by a raw literal.
Example:
69// Seconds between Convex voting rounds (2 weeks)70uint32 public constant EPOCH_DURATION = 1209600;71
72// Fee denominator73uint32 public constant FEE_DENOMINATOR = 1000000;74
75// Maximum wait time (seconds) for a CVX redemption (17 weeks)76uint32 public constant MAX_REDEMPTION_TIME = 10281600;
Recommendation:
We advise the weeks
numeric specifier to be utilized instead, greatly increasing the legibility of the codebase.
Alleviation:
The readability of the codebase has been significantly increased by utilizing the weeks
value denominator.