Omniscia Sovryn Audit
Utils Manual Review Findings
Utils Manual Review Findings
UTI-01M: Invalid Function Argument
Type | Severity | Location |
---|---|---|
Logical Fault | Minor | Utils.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 pure99 returns(uint256 calculatedGranularity, uint256 formattedAmount) {100
101 if(decimals == 18) {102 //tokenAddress is a ERC20 with 18 decimals should have 1 granularity103 //tokenAddress is a ERC777 token we give the same granularity104 calculatedGranularity = granularity;105 formattedAmount = amount;106 } else {107 //tokenAddress is a ERC20 with other than 18 decimals108 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.