Omniscia Hot Cross Audit

CrossPool Code Style Findings

CrossPool Code Style Findings

CPL-01C: Potentially Misaligned lastRewardBlock

TypeSeverityLocation
Standard ConformityInformationalCrossPool.sol:L265

Description:

The updatePool function evaluates the minimum between block.number and endBlock to ensure that a sensible number is assigned to lastRewardBlock, however, the assignment within the second if clause of the function does not perform the same evaluation.

Example:

contracts/CrossPool.sol
255function updatePool(uint256 pid) private {
256 PoolInfo storage pool = poolInfo[pid];
257
258 if (block.number <= pool.lastRewardBlock) {
259 return;
260 }
261
262 uint256 stakingTokenSupply = pool.stakingToken.balanceOf(address(this));
263
264 if (stakingTokenSupply == 0) {
265 pool.lastRewardBlock = block.number;
266 return;
267 }
268
269 uint256 tokenReward = getReward(pool);
270 pool.accRewardPerShare = getAccRewardPerShare(
271 pool.accRewardPerShare,
272 tokenReward,
273 stakingTokenSupply
274 );
275
276 pool.lastRewardBlock = block.number.min(endBlock);
277}

Recommendation:

We advise the same evaluation to be performed in the linked assignment to ensure consistency in the codebase.

Alleviation:

The assignment of the lastRewardBlock within the respective if clause was properly updated to assign the minimum between block.number and endBlock.

CPL-02C: Redundant Default Value Assignment

TypeSeverityLocation
Code StyleInformationalCrossPool.sol:L81

Description:

In Solidity, all variable types have a default value they are assigned to during declaration which is equivalent to the value of 0 in the respective data type.

Example:

contracts/CrossPool.sol
61function initialize(
62 IBEP20 rewardToken_,
63 RewardVault rewardVault_,
64 uint256 rewardPerBlock_,
65 uint256 startBlock_,
66 uint256 endBlock_,
67 uint256 timeLock_
68) public initializer {
69 __Ownable_init();
70 Misc.zeroOrContract(address(rewardToken_), "Invalid rewardToken address");
71 Misc.zeroOrContract(address(rewardVault_), "Invalid reward vault address");
72
73 __Ownable_init();
74
75 rewardToken = rewardToken_;
76 rewardVault = rewardVault_;
77 rewardPerBlock = rewardPerBlock_;
78 startBlock = startBlock_;
79 endBlock = endBlock_;
80 timeLock = timeLock_;
81 totalAllocPoint = 0;
82}

Recommendation:

We advise the redundant zero assignment to be removed from the codebase.

Alleviation:

The zero-value assignment was safely omitted from the codebase.