Omniscia Swisscoast Audit
LiquityBase Static Analysis Findings
LiquityBase Static Analysis Findings
LBE-01S: Illegible Numeric Value Representations
Type | Severity | Location |
---|---|---|
Code Style | LiquityBase.sol:L19, L22, L25 |
Description:
The linked representations of numeric literals are sub-optimally represented decreasing the legibility of the codebase.
Example:
19uint constant public _100pct = 100000000; // 1e8 == 100%
Recommendation:
To properly illustrate each value's purpose, we advise the following guidelines to be followed.
For values meant to depict fractions with a base of 1e18
, we advise fractions to be utilized directly (i.e. 1e17
becomes 0.1e18
) as they are supported.
For values meant to represent a percentage base, we advise each value to utilize the underscore (_
) separator to discern the percentage decimal (i.e. 10000
becomes 100_00
, 300
becomes 3_00
and so on).
Finally, for large numeric values we simply advise the underscore character to be utilized again to represent them (i.e. 1000000
becomes 1_000_000
).
Alleviation (04618e407b):
While the numeric separator has been introduced for all declarations, it has been improperly done so. As the exhibit's original recommendation clarifies, the 100%
of a particular value should be represented with the underscore at the decimal point, rendering _100pct
to be 100_000000
instead of 100_000_000
under this convention.
Alleviation (30f7253f63):
The numeric separator has been corrected to properly reflect the decimal point of the percentage denomination, addressing this exhibit in full.