Omniscia WagmiDAO Audit

WagmiBond Code Style Findings

WagmiBond Code Style Findings

WBD-01C: Redundant Conditional Execution

TypeSeverityLocation
Gas OptimizationInformationalWagmiBond.sol:L487, L495, L510

Description:

The if branch within the deposit function is redundant as the value of wagmiPerPrincipal will be different than (!=) zero over the lifetime of the contract.

Example:

WagmiBond.sol
487require(_wagmiPerPrincipal != 0, 'ratio cant be zero');
488 wagmiPerPrincipal = _wagmiPerPrincipal;
489 require(_ratioPrecision != 0, 'precision cant be zero');
490 ratioPrecision = _ratioPrecision;
491}
492
493function setRatio(uint256 _wagmiPerPrincipal, uint256 _ratioPrecision) external onlyOwner {
494 emit RatioChanged(wagmiPerPrincipal, _wagmiPerPrincipal, ratioPrecision, _ratioPrecision);
495 require(_wagmiPerPrincipal != 0, 'ratio cant be zero');
496 wagmiPerPrincipal = _wagmiPerPrincipal;
497 require(_ratioPrecision != 0, 'precision cant be zero');
498 ratioPrecision = _ratioPrecision;
499}
500
501function addWagmiToPay(uint256 amount) external {
502 IERC20(wagmi).safeTransferFrom(msg.sender, address(this), amount);
503 wagmiAvailableToPay += amount;
504
505 emit WagmiAdded(amount);
506}
507
508function deposit(uint256 amount) external returns (uint256) {
509 uint256 payout;
510 if(wagmiPerPrincipal != 0)
511 payout = amount * wagmiPerPrincipal / ratioPrecision;

Recommendation:

We advise it to be safely omitted from the codebase.

Alleviation:

The if conditional has been safely omitted from the codebase and its inner statements have been set one level higher.

WBD-02C: Redundant Memory Declaration

TypeSeverityLocation
Gas OptimizationInformationalWagmiBond.sol:L80, L82

Description:

The linked statements perform a memory declaration of a storage value, write over it with an in-memory value and emit an event right after with the value read from storage before the write and the input argument of the function.

Example:

WagmiBond.sol
75/**
76 * @dev Transfers ownership of the contract to a new account (`newOwner`).
77 * Internal function without access restriction.
78 */
79function _transferOwnership(address newOwner) internal virtual {
80 address oldOwner = _owner;
81 _owner = newOwner;
82 emit OwnershipTransferred(oldOwner, newOwner);
83}

Recommendation:

We advise the event emission to be relocated before the storage write to directly utilize the storage member and render the in-memory variable declaration redundant within the code.

Alleviation:

The statements were adjusted as per our recommendation.