Omniscia Sova Network Audit
PriceOracleReporter Code Style Findings
PriceOracleReporter Code Style Findings
POR-01C: Inefficient Event Emission
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | PriceOracleReporter.sol:L72, L73, L76 |
Description:
The PricePerShareUpdated event emitted in the PriceOracleReporter::update function will re-read the currentRound and pricePerShare from storage even though its function body has read these values into memory.
Example:
src/reporter/PriceOracleReporter.sol
67function update(uint256 newPricePerShare, string calldata source_) external {68 if (!authorizedUpdaters[msg.sender]) revert Unauthorized();69 if (bytes(source_).length == 0) revert InvalidSource();70
71 // Create new price update72 currentRound++;73 pricePerShare = newPricePerShare;74 lastUpdateAt = block.timestamp;75
76 emit PricePerShareUpdated(currentRound, pricePerShare, source_);77}Recommendation:
We advise the currentRound to be cached to memory, incremented, and set to storage and the PricePerShareUpdated event to be updated to use the in-memory currentRound variable as well as the newPricePerShare variable.
Alleviation (e4d6885477438291b0d3ca477fab7e088522967b):
The event's emission was optimized as advised, utilizing variables that are present in memory rather than loaded from storage.
