Omniscia Beanstalk Audit
SiloExit Code Style Findings
SiloExit Code Style Findings
SET-01C: Lock Cleanup Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | SiloExit.sol:L190-L200 |
Description:
Based on the logical guarantees of the VotingBooth
contract, the state whereby a user has a non-zero lockedUntil
value and no active BIPs have been voted on is final.
Example:
190function locked(address account) public view returns (bool) {191 if (s.a[account].lockedUntil >= season()) {192 for (uint256 i = 0; i < s.g.activeBips.length; i++) {193 uint32 activeBip = s.g.activeBips[i];194 if (s.g.voted[activeBip][account]) {195 return true;196 }197 }198 }199 return false;200}
Recommendation:
We advise this to be represented by the code whereby the lockedUntil
value is reset to zero to prevent consequent lock lookups from consuming as much gas.
Alleviation:
After deliberation with the Beanstalk team, we concluded that the gas optimization achieved by this change is negligible and potentially inexistent in certain edge cases and as such the code should remain us is. In light of this, we consider the exhibit nullified.
SET-02C: Redundant Usage of SafeMath
Type | Severity | Location |
---|---|---|
Gas Optimization | SiloExit.sol:L78, L93 |
Description:
The linked SafeMath
operations are guaranteed to be performed safely by their surrounding if
clauses and general logical constraints.
Example:
92if (stalk <= s.a[account].s.stalk) return 0;93beans = stalk.sub(s.a[account].s.stalk).div(C.getStalkPerBean());
Recommendation:
We advise them to be performed without the usage of SafeMath
to optimise the code.
Alleviation:
The redundant usage of SafeMath
has been properly omitted from the codebase.