function insert(State storage self, uint256 navPerShare, uint40 timestamp) internal {
if (timestamp < self.lastFinalizedTimestamp) revert InvalidNavTimestamp(self.lastFinalizedTimestamp, timestamp);
// if it's been a day since the last finalized value, then finalize the current value
// otherwise continue to overwrite the currentIndex
if (timestamp - self.lastFinalizedTimestamp >= 1 days) {
if (self.lastFinalizedTimestamp > 0) {
self.currentIndex = (self.currentIndex + 1) % MAX_NAV_TRACKING;
}
self.lastFinalizedTimestamp = timestamp;
}
self.history[self.currentIndex] = navPerShare;
if (self.len < MAX_NAV_TRACKING) {
self.len += 1;
}
@audit emit event
// TODO: emit an event -- allow us to see if there are frequently gaps in reporting
}
Revised Code File (Optional)
Create an event and emit it at the end of the function.
function insert(State storage self, uint256 navPerShare, uint40 timestamp) internal {
if (timestamp < self.lastFinalizedTimestamp) revert InvalidNavTimestamp(self.lastFinalizedTimestamp, timestamp);
// if it's been a day since the last finalized value, then finalize the current value
// otherwise continue to overwrite the currentIndex
if (timestamp - self.lastFinalizedTimestamp >= 1 days) {
if (self.lastFinalizedTimestamp > 0) {
self.currentIndex = (self.currentIndex + 1) % MAX_NAV_TRACKING;
}
self.lastFinalizedTimestamp = timestamp;
}
self.history[self.currentIndex] = navPerShare;
if (self.len < MAX_NAV_TRACKING) {
self.len += 1;
}
emit Inserted(self, navPerShare, timestamp);
}
Github username: @https://github.com/Pavel2202 Twitter username: https://twitter.com/timenov_pavel Submission hash (on-chain): 0x6996a376bdfb967f743bdc367f39bf023d8add97faf700dfeb46c17082431f1a Severity: low
Description: Description\ In
NavTracking::insert
there is a left TODO. It states that an ecent should be emitted. However that is not true.Attachments
Create an event and emit it at the end of the function.