Omniscia Steer Protocol Audit

SingleStaking Code Style Findings

SingleStaking Code Style Findings

SSG-01C: Inefficient Code Structure

Description:

The referenced if-else block within the StakingSingleRewards::withdraw function will repeat the same statements across the code branches except for a single require check.

Example:

contracts/Staking/SingleStaking.sol
714if (isLocked) {
715 require(block.timestamp > periodFinish, "Period is not finished");
716 _totalSupply = _totalSupply.sub(amount);
717 _balances[msg.sender] = _balances[msg.sender].sub(amount);
718 stakingToken.safeTransfer(msg.sender, amount);
719 emit Withdrawn(msg.sender, amount);
720} else {
721 _totalSupply = _totalSupply.sub(amount);
722 _balances[msg.sender] = _balances[msg.sender].sub(amount);
723 stakingToken.safeTransfer(msg.sender, amount);
724 emit Withdrawn(msg.sender, amount);
725}

Recommendation:

We advise the code to instead perform the require check within the existing if clause, the else clause to be removed, and the remaining statements in the if clause to be relocated outside of it and specifically after it.

Alleviation (6513a21a002d422e298719b22f73a4559dfd4663):

The code was optimized per our recommendation, significantly reducing the bytecode size of the contract.

SSG-02C: Repetitive Value Literal

Description:

The linked value literal is repeated across the codebase multiple times.

Example:

contracts/Staking/SingleStaking.sol
680.mul(1e18)

Recommendation:

We advise it to be set to a constant variable instead, optimizing the legibility of the codebase.

In case the constant has already been declared, we advise it to be properly re-used across the code.

Alleviation (6513a21a002d422e298719b22f73a4559dfd4663):

The referenced value literal PRECISION has been properly relocated to a contract-level constant declaration labelled 1e18, optimizing the code's legibility.