The StargateNFT inherits the Levels library allowing levels to be added into the contract by an address with the LEVEL_OPERATOR_ROLE privilege (set by protocol). However, when adding a level the addLevel function emits incorrect/misleading events. Specifically, the function emits:
LevelUpdated: misleading and incorrect because this is an addition operation and not updating an existing level.
LevelCirculatingSupplyUpdated: misleading and incorrect because this is an addition operation (not an update). Also the oldCirculatingSupply value is 0 which isn't useful.
LevelCapUpdated: again, not an updating operation; the oldCap parameter is meaningless.
These events are emitted by Levels::updateLevel. Note: in version 3 of StargateNFT the updateLevel function is no longer exposed. Documentation confirms removal of setters: StargateNFT#L92 "Removed setters to optimize contract size: setStargateDelegation, setLegacyNodes, updateLevelCap, updateLevel".
The addLevel function should emit its own unique event that accurately represents the addition operation and contains meaningful data.
The Associated Code
StargateNFT wrapper:
Levels library (relevant extract):
Impact
This is classified as an Insight under "Code Optimizations and Enhancements". Incorrect or misleading event emission can confuse indexers, analytics services, and anyone relying on on-chain events to understand protocol state changes. The semantics of "add" differ from "update" and should be represented distinctly.
Mitigation
Create and emit a new event that accurately represents level addition. Suggested event:
Change Levels::addLevel to emit the new event instead of the three misleading events. Example patch:
This preserves accurate semantics and removes confusing old* fields that are meaningless for additions.