Omniscia 0xPhase Audit
VaultAccountingFacet Code Style Findings
VaultAccountingFacet Code Style Findings
VAF-01C: Ineffectual Usage of Safe Arithmetics
Type | Severity | Location |
---|---|---|
Language Specific | VaultAccountingFacet.sol:L84, L88, L194-L195 |
Description:
The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require
checks or if-else
constructs.
Example:
83if (info.deposit >= amount) {84 info.deposit -= amount;85} else {86 amount =87 info.deposit +88 _s.balancer.withdraw(_s.asset, user, amount - info.deposit);89
90 info.deposit = 0;91}
Recommendation:
Given that safe arithmetics are toggled on by default in pragma
versions of 0.8.X
, we advise the linked statements to be wrapped in unchecked
code blocks thereby optimizing their execution cost.
Alleviation (3dd3d7bf0c):
Both referenced statements have been wrapped in an unchecked
code block, however, the second block inadvertently also performs the addition in an unchecked
way. We advise the subtraction to be solely performed in an unchecked
code block as the addition could still theoretically overflow.
Alleviation (19668501f8):
The unchecked
code block was revised to solely perform the subtraction which is guaranteed to be safe, addressing this exhibit in full.