Omniscia Sovryn Audit

BasketManager Manual Review Findings

BasketManager Manual Review Findings

BMR-01M: Unaccounted Truncation of Quantity

Description:

The conversion methods between a b-asset and m-asset quantity do not factor in that truncation may occur, leading to dust remaining permanently locked in the contract and accumulating.

Example:

contracts/masset/BasketManager.sol
51function convertBassetToMassetQuantity(address _basset, uint256 _bassetQuantity) external view returns(uint256) {
52 require(_isValidBasset(_basset), "invalid basset");
53 int256 factor = factorMap[_basset];
54 if(factor > 0) {
55 return _bassetQuantity.div(uint256(factor));
56 }
57 return _bassetQuantity.mul(uint256(-factor));
58}
59
60function convertMassetToBassetQuantity(address _basset, uint256 _massetQuantity) external view returns(uint256) {
61 require(_isValidBasset(_basset), "invalid basset");
62 int256 factor = factorMap[_basset];
63 if(factor > 0) {
64 return _massetQuantity.mul(uint256(factor));
65 }
66 return _massetQuantity.div(uint256(-factor));
67}

Recommendation:

We advise the remainder to be factored in by either returning it or mandating the division to be whole (i.e. a modulo % operation with the factor yields 0).

Alleviation:

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