Omniscia Flisko Audit

KSTStaking Code Style Findings

KSTStaking Code Style Findings

KSS-01C: Redundant SafeMath Utilization

TypeSeverityLocation
Gas OptimizationInformationalKSTStaking.sol:L53

Description:

The linked sub invocation is redundant as it is guaranteed to execute successfully due to the require check imposed above it.

Example:

contracts/KSTStaking.sol
50function unstake(uint256 value) external lockable {
51 require(_balances[_msgSender()] >= value, 'KSTStaking: insufficient staked balance');
52
53 _balances[_msgSender()] = _balances[_msgSender()].sub(value,"KSTStaking: insufficient staked balance");
54 _token.transfer(_msgSender(), value);
55 emit Unstake(_msgSender(),block.timestamp,value);
56}

Recommendation:

We advise a raw subtraction to instead take its place to optimize the gas cost of the function.

Alleviation:

The SafeMath utilization was safely dropped from the codebase, optimizing the function's gas cost.