Omniscia Sovryn Audit

BasketManager Code Style Findings

BasketManager Code Style Findings

BMR-01C: Redundant Mapping

TypeSeverityLocation
Gas OptimizationInformationalBasketManager.sol:L11, L16, L30

Description:

The bassetsMap mapping is solely utilized to guarantee no duplicate bassets are set during the contract's constructor.

Example:

contracts/masset/BasketManager.sol
20constructor(address[] memory _bassets, int256[] memory _factors, address[] memory _bridges) public {
21 require(_bassets.length > 0, "some basset required");
22 require(_bassets.length == _factors.length, "factor array length mismatch");
23 require(_bridges.length == _factors.length, "bridge array length mismatch");
24
25 bassetsArray = _bassets;
26 for(uint i=0; i<bassetsArray.length; i++) {
27 address basset = bassetsArray[i];
28 require(basset != address(0), "invalid basset address");
29 require(!bassetsMap[basset], "basset not unique");
30 bassetsMap[basset] = true;
31 require(_factors[i] != 0, "invalid factor");
32 factorMap[basset] = _factors[i];
33 if(_bridges[i] != address(0)) {
34 bridgeMap[basset] = _bridges[i];
35 }
36 }
37}

Recommendation:

We advise the mapping to be omitted and non-zero values of factorMap to be utilized instead as a "flag" of whether a basset has already been set.

Alleviation:

The development team has acknowledged this exhibit but decided to not apply its remediation in the current version of the codebase.

BMR-02C: Unutilized Quantity Values

TypeSeverityLocation
Code StyleInformationalBasketManager.sol:L43-L49

Description:

The checkBasketBalanceForDeposit and checkBasketBalanceForWithdrawal functions do not utilize the "quantity" arguments during their validation.

Example:

contracts/masset/BasketManager.sol
43function checkBasketBalanceForDeposit(address _basset, uint256 _bassetQuantity) external view returns(bool) {
44 return _isValidBasset(_basset);
45}
46
47function checkBasketBalanceForWithdrawal(address _basset, uint256 _bassetQuantity) external view returns(bool) {
48 return _isValidBasset(_basset);
49}

Recommendation:

As the current implementation is meant to be the first phase, we assume that the functions are declared as such to comply to a future upgrade that will utilize the quantities. In any case, we still recommend the names of the variables to be omitted thus producing the same signature but reducing the gas cost of the functions.

Alleviation:

The development team has acknowledged this exhibit but decided to not apply its remediation in the current version of the codebase.