Omniscia DAFI Protocol Audit

DAFITokenBSC Code Style Findings

DAFITokenBSC Code Style Findings

DAI-01C: Inexistent Visibility Specifiers

TypeSeverityLocation
Code StyleInformationalDAFITokenBSC.sol:L6, L7, L8

Description:

The linked variables have no visibility specifier explicitly set.

Example:

contracts/DAFITokenBSC.sol
6string constant _name = "DAFI Token";
7string constant _symbol = "DAFI";
8uint256 constant _decimals = 18;
9
10uint256 public maxSupply;

Recommendation:

We advise one to be set so to avoid potential compilation discrepancies in the future as the current behaviour is for the compiler to assign one automatically which may deviate between pragma versions.

Alleviation:

The public visibility specifier was introduced for all linked variables.

DAI-02C: Suboptimal Code

TypeSeverityLocation
Gas OptimizationInformationalDAFITokenBSC.sol:L22

Description:

The linked addition can be performed unsafely as it is guaranteed to not overflow due to the require check that subcedes it.

Example:

contracts/DAFITokenBSC.sol
17function mint(uint256 _value, address _beneficiary) external onlyBridge {
18 require(_beneficiary != address(0),"Beneficiary cannot be ZERO ADDRESS");
19 require(_value > 0,"value should be more than 0");
20 require((_value + _totalSupply) <= maxSupply, "Minting amount exceeding max limit");
21 balances[_beneficiary] = balances[_beneficiary] + _value;
22 _totalSupply = _totalSupply + _value;
23
24 emit Transfer(address(0), _beneficiary, _value);
25}

Recommendation:

We advise it to be executed within an unchecked code block to optimize the code's gas cost.

Alleviation:

The _totalSupply increase is now wrapped in an unchecked code block optimally.

DAI-03C: Variable Mutability Specifier

TypeSeverityLocation
Gas OptimizationInformationalDAFITokenBSC.sol:L10, L14

Description:

The linked variable is assigned to only once during the contract's constructor.

Example:

contracts/DAFITokenBSC.sol
13constructor(address _owner, address _bridge) Ownable(_owner,_bridge) {
14 maxSupply = 2250000000 * 10**_decimals;
15}

Recommendation:

We advise it to be set as immutable greatly optimizing the codebase.

Alleviation:

The immutable specifier was properly introduced for the linked variable.