Omniscia Badai Tech Audit
BadAIStaking Code Style Findings
BadAIStaking Code Style Findings
BAS-01C: Generic Typographic Mistakes
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | BadAIStaking.sol: • I-1: L34 • I-2: L35 • I-3: L36 |
Description:
The referenced lines contain typographical mistakes (i.e. private variable without an underscore prefix) or generic documentational errors (i.e. copy-paste) that should be corrected.
Example:
34uint public constant unstakingFeeRatioTimelockPeriod = 600;Recommendation:
We advise them to be corrected enhancing the legibility of the codebase.
Alleviation (d639d227f8b8d90dbd9813ab9d7a5cbee34dd9b1):
All relevant constant declarations have been renamed based on the UPPER_CASE_FORMAT, addressing this exhibit.
BAS-02C: Ineffectual Usage of Safe Arithmetics
| Type | Severity | Location |
|---|---|---|
| Language Specific | ![]() | BadAIStaking.sol: • I-1: L138 • I-2: L140 • I-3: L159 • I-4: L365 • I-5: L369 • I-6: L373 • I-7: L379 |
Description:
The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.
Example:
153require(154 _amount <= stakes[msg.sender],155 "BADStakingImp: not enough stake to transfer"156);157_updateReward(msg.sender);158_updateReward(_recipient);159stakes[msg.sender] -= _amount;Recommendation:
Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.
Alleviation (d639d227f8b8d90dbd9813ab9d7a5cbee34dd9b1):
The Badai Tech team evaluated this optimization and opted to retain checked arithmetics across the codebase so as to increase its readability and prevent future code updates to result in undetected overflows / underflows.
BAS-03C: Inefficient Maximum Mechanism
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | BadAIStaking.sol:L357 |
Description:
The referenced maximum value acquisition will be triggered once in the lifetime of the contract resulting in a continuous inefficiency.
Example:
348function getTotalEmittedTokens(349 uint _from,350 uint _to,351 uint _startingCheckPoint352) public view returns (uint, uint) {353 require(_to >= _from, "LM: _to has to be greater than _from.");354 uint totalEmittedTokens = 0;355
356 // The time to start calculating rewards from. We'll update it for each emission period we iterate over357 uint nextStartTime = Math.max(_from, checkPoints[0]);Recommendation:
We advise the code to be revised by configuring the nextStartTime to the value of checkPoints[0] when startingCheckPoint is 0 (i.e. until the first emission occurs).
Alleviation (d639d227f8b8d90dbd9813ab9d7a5cbee34dd9b1):
The Badai Tech team evaluated this exhibit and opted to retain the maximum mathematical calculation albeit between the _from value and the _startingCheckpoint checkpoint value so as to support external view-only calls.
As external call support is meant to be retained by this function, we consider this exhibit to be resolved.
