Omniscia Arcade XYZ Audit
PunksVerifier Code Style Findings
PunksVerifier Code Style Findings
PVR-01C: Loop Iterator Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | PunksVerifier.sol:L69 |
Description:
The linked for
loop increments / decrements the iterator "safely" due to Solidity's built-in safe arithmetics (post-0.8.X
).
Example:
69for (uint256 i = 0; i < tokenIds.length; i++) {
Recommendation:
We advise the increment / decrement operation to be performed in an unchecked
code block as the last statement within the for
loop to optimize its execution cost.
Alleviation (7a4e1dc948e94ded7385dbb74818bcf93ecc207c):
The loop iterator has been optimized as advised, relocating it to a dedicated unchecked
code block that optimizes its execution.
PVR-02C: Redundant Usage of SafeCast
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | PunksVerifier.sol:L23, L76 |
Description:
The referenced SafeCast::toUint256
operation is performed on a tokenId
value which is guaranteed to be non-negative by the preceding conditional. Given that int256
contains a smaller value range in comparison to uint256
, any non-negative int256
value will be successfully cast safely to the uint256
data type.
Example:
76else if (tokenId >= 0 && punks.punkIndexToAddress(tokenId.toUint256()) != vault) return false;
Recommendation:
As such, we advise the SafeCast
library to be omitted and the casting operation to be performed directly, optimizing the gas cost and bytecode size of the contract.
Alleviation (7a4e1dc948e94ded7385dbb74818bcf93ecc207c):
The Arcade XYZ team evaluated this exhibit and opted to retain the current behaviour of the codebase.
PVR-03C: Undocumented Predicate Feature
Type | Severity | Location |
---|---|---|
Code Style | ![]() | PunksVerifier.sol:L74 |
Description:
The referenced statement illustrates a special use-case of the tokenId
value in the negative range which is utilized as a sanity check of a non-zero punks
balance for the vault
.
Example:
74if (tokenId < 0 && punks.balanceOf(vault) == 0) return false;
Recommendation:
We advise this feature to be documented properly as documentation for it is absent.
Additionally, we advise the consideration of utilizing the tokenId
value in the negative range as an indicator of the minimum balance of punks
that the vault
should hold, further increasing the usability of the function.
Alleviation (7a4e1dc948e94ded7385dbb74818bcf93ecc207c):
The Arcade XYZ team evaluated this exhibit and opted to retain the current behaviour of the codebase.