Omniscia Steer Protocol Audit

WhitelistRegistry Code Style Findings

WhitelistRegistry Code Style Findings

WRY-01C: Improper Emission of Events

TypeSeverityLocation
Code StyleWhitelistRegistry.sol:L41-L44

Description:

The registerWhitelistManager function permits the overwrite of a previously set whitelistManagers with a new one.

Example:

contracts/WhitelistRegistry.sol
41function registerWhitelistManager(address manager) external {
42 whitelistManagers[msg.sender] = manager;
43 emit ManagerAdded(msg.sender, manager);
44}

Recommendation:

We advise an event to be emitted if the entry was non-zero to ensure that off-chain software can properly detect a replacement rather than an inclusion action.

Alleviation (200f275c40cbd4798f4a416c044ea726755d4741):

The Steer Protocol team opted to retain the current behaviour in place, acknowledging this exhibit.

WRY-02C: Inefficient mapping Lookups

TypeSeverityLocation
Gas OptimizationWhitelistRegistry.sol:L31, L61

Description:

The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.

Example:

contracts/WhitelistRegistry.sol
51function revokePermissions(
52 address _vaultAddress,
53 address[] calldata _addresses
54) external {
55 // Make sure caller is authorized
56 require(msg.sender == whitelistManagers[_vaultAddress]);
57
58 // Remove permissions
59 uint256 addressCount = _addresses.length;
60 for (uint256 i; i != addressCount; ++i) {
61 permissions[_vaultAddress][_addresses[i]] = 0;
62 }
63 emit PermissionsRemoved(msg.sender, _vaultAddress, _addresses);
64}

Recommendation:

As the lookups internally perform an expensive keccak256 operation, we advise the lookups to be cached wherever possible to a single local declaration that either holds the value of the mapping in case of primitive types or holds a storage pointer to the struct contained.

Alleviation (200f275c40cbd4798f4a416c044ea726755d4741):

The permissions lookups of both loops have been optimized to cache the interim permissions[_vaultAddress] lookup, greatly reducing their gas cost.

WRY-03C: Inexistent Error Message

TypeSeverityLocation
Code StyleWhitelistRegistry.sol:L56

Description:

The linked require check has no error message explicitly defined.

Example:

contracts/WhitelistRegistry.sol
56require(msg.sender == whitelistManagers[_vaultAddress]);

Recommendation:

We advise one to be set so to increase the legibility of the codebase and aid in validating the require check's condition.

Alleviation (200f275c40cbd4798f4a416c044ea726755d4741):

An error message has been adequately introduced to the referenced require check.