Omniscia Platypus Finance Audit
WETHForwarder Code Style Findings
WETHForwarder Code Style Findings
WET-01C: Memory Usage Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | WETHForwarder.sol:L59, L61 |
Description:
The setPool
function reads the value of the current _pool
from storage, retains it in memory and then proceeds to emit an event with it.
Example:
contracts/pool/WETHForwarder.sol
53/**54 * @notice Changes the pool. Can only be set by the contract owner.55 * @param pool new contract pool address56 */57function setPool(address pool) external onlyOwner {58 require(pool != address(0), 'Pool address cannot be zero');59 address oldPool = _pool;60 _pool = pool;61 emit PoolUpdated(oldPool, pool);62}
Recommendation:
We advise the event to be emitted directly before writing to the _pool
data entry, thus ensuring that the value is utilized directly and the oldPool
variable is rendered redundant.
Alleviation:
The contract is no longer part of the codebase rendering this exhibit null.
WET-02C: Variable Mutability Specifier
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | WETHForwarder.sol:L19, L39 |
Description:
The linked variable is only set once during the constructor
of the contract.
Example:
contracts/pool/WETHForwarder.sol
18/// @notice Weth (or wavax in our case) address19address private _weth;20
21/// @notice Pool address22address private _pool;23
24/// @notice An event thats emitted when pool is updated25event PoolUpdated(address indexed previousPool, address indexed newPool);26
27/// @dev Modifier ensuring that certain function can only be called by pool28modifier onlyPool() {29 require(msg.sender == _pool, 'FORBIDDEN');30 _;31}32
33/**34 * @notice Constructor.35 * @param weth The weth (or wavax) address to be used.36 */37constructor(address weth) {38 require(weth != address(0), 'ADDRESS_ZERO');39 _weth = weth;40}
Recommendation:
We advise it to be set as immutable
greatly optimizing the codebase's gas cost.
Alleviation:
The contract is no longer part of the codebase rendering this exhibit null.