Omniscia Alliance Block Audit
LockScheme Code Style Findings
LockScheme Code Style Findings
LSE-01C: Ambiguous Event
Type | Severity | Location |
---|---|---|
Indeterminate Code | Informational | LockScheme.sol:L98 |
Description:
The Exit
event is emitted during an exit
regardless of whether the rewards were forfeited or not.
Example:
86bonus = PercentageCalculator.div(user.accruedReward,bonusPercent);87uint userLockEnd = user.lockInitialStakeBlock.add(lockPeriod);8889if(block.number < userLockEnd) {90 forfeitedBonuses = forfeitedBonuses.add(bonus);91 bonus = 0;92}9394user.accruedReward = 0;95user.balance = 0;96user.lockInitialStakeBlock = 0;9798emit Exit(_userAddress, bonus);
Recommendation:
We advise that a seperate event or a bool
accompanying the `Exit event is instead emitted to ensure clarity to off-chain processes that monitor with the blockchain.
Alleviation:
The Exit
event was adjusted to contain another bool
variable at the end that designates whether the bonus
was forfeited or not. We should add that the event
declaration contains a typo on the last argument that we advise be fixed.
LSE-02C: Redundant struct
Member
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | LockScheme.sol:L26 |
Description:
The linked struct
member remains unutilized throughout the project.
Example:
22struct UserInfo {23 uint256 balance; // IOU Balance for this lock contract24 uint256 accruedReward; // Reward accrued by an address from previous additions25 uint256 lockInitialStakeBlock;26 uint256 userEndBlock;27}
Recommendation:
As such, we advise that it is safely omitted to optimize the gas cost involved in handling UserInfo
structs.
Alleviation:
The redundant userEndBlock
structure member was omitted from the UserInfo
declaration.
LSE-03C: Variable Mutability Specifiers
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | LockScheme.sol:L16-L19 |
Description:
The linked variables are assigned to only once during the constructor
of the contract yet their mutability specifiers are missing.
Example:
42constructor(43 uint256 _lockPeriod,44 uint256 _rampUpPeriod,45 uint256 _bonusPercent,46 address _lmcContract47) public {48 lockPeriod = _lockPeriod;49 rampUpPeriod = _rampUpPeriod;50 bonusPercent = _bonusPercent;51 lmcContract = _lmcContract;52}
Recommendation:
We advise that they are set as immutable
to greatly optimize the gas cost involved in utilizing them.
Alleviation:
The immutable
mutability specifier was introduced for all linked configurational variables of the LockScheme
.