Omniscia Sovryn Audit

Utils Manual Review Findings

Utils Manual Review Findings

UTI-01M: Invalid Function Argument

TypeSeverityLocation
Logical FaultMinorUtils.sol:L98-L111

Description:

The calculateGranularityAndAmount contains a granularity argument which should not exist given that the granularity is meant to be calculated and is done so in all cases apart from decimals == 18, in which case it is 1.

Example:

sovryn-token-bridge/bridge/contracts/Utils.sol
98function calculateGranularityAndAmount(uint8 decimals, uint256 granularity, uint256 amount) external pure
99 returns(uint256 calculatedGranularity, uint256 formattedAmount) {
100
101 if(decimals == 18) {
102 //tokenAddress is a ERC20 with 18 decimals should have 1 granularity
103 //tokenAddress is a ERC777 token we give the same granularity
104 calculatedGranularity = granularity;
105 formattedAmount = amount;
106 } else {
107 //tokenAddress is a ERC20 with other than 18 decimals
108 calculatedGranularity = decimalsToGranularity(decimals);
109 formattedAmount = amount.mul(calculatedGranularity);
110 }
111}

Recommendation:

We advise it to be omitted from the function signature and the assignment within the first if block to be replaced by an assignment of 1.

Alleviation:

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