Omniscia Platypus Finance Audit

Asset Code Style Findings

Asset Code Style Findings

ASS-01C: Redundant In-Memory Declarations

TypeSeverityLocation
Gas OptimizationInformationalAsset.sol:L103, L122

Description:

The linked setter functions redundantly declare an in-memory variable that is then emitted in the function's event.

Example:

contracts/asset/Asset.sol
98/**
99 * @notice Changes asset max supply. Can only be set by the contract owner.
100 * @param maxSupply_ the new asset's max supply
101 */
102function setMaxSupply(uint256 maxSupply_) external onlyOwner {
103 uint256 oldMaxSupply = _maxSupply;
104 _maxSupply = maxSupply_;
105 emit MaxSupplyUpdated(oldMaxSupply, maxSupply_);
106}

Recommendation:

We advise the event to be emitted prior to the value being written to storage thus rendering the in-memory variable redundant.

Alleviation:

The event emission statements have been optimised accordingly.

ASS-02C: Redundant User-Defined Getters

Description:

The linked functions are meant to return private variables of the same name that contain the underscore (_) prefix.

Example:

contracts/asset/Asset.sol
108/**
109 * @notice Gets current Pool address
110 * @return The current Pool address for Asset
111 */
112function pool() external view returns (address) {
113 return _pool;
114}

Recommendation:

We advise the functions to be omitted from the codebase, the variables to be renamed sans the underscore and them to be set as public thereby ensuring the compiler generates a getter function for them automatically. In general, compiler-generated getter functions are preferable over user-defined ones as the latter are prone to human error such as improper maintenance.

Alleviation:

The Platypus team considered this exhibit but opted not to apply a remediation for it.

ASS-03C: Redundant Variable Declarations

TypeSeverityLocation
Gas OptimizationInformationalAsset.sol:L29-L32

Description:

The _name and _symbol variables are redundantly declared as equivalent variables sans the underscore (_) prefix already exist and contain the same value in the ERC20Upgradeable implementation.

Example:

contracts/asset/Asset.sol
29/// @notice Name of the asset
30string public _name;
31/// @notice Symbol of the asset
32string public _symbol;

Recommendation:

We advise them to be safely omitted from the codebase.

Alleviation:

They have been safely omitted from the codebase.