F-2025-0017·gas-optimization

Redundant positionId in Position struct

Acknowledgedstakingnft-boostrewards
TL;DR

Position struct stores positionId, duplicating the mapping key and incurring extra storage writes plus drift risk between key and field.

Severity
INFO
Impact
LOW
Likelihood
LOW
Method
MManual review
CAT.
Complexity
LOW
Exploitability
LOW
02Section · Description

Description

The Position struct includes a positionId field that duplicates the key used in the positions mapping:

solidity
struct Position {
uint positionId; // Redundant with mapping key
address walletAddress;
// ... other fields
}
mapping(uint => Position) public positions; // positionId is already the key

While this might seem convenient for frontend integration or event emission, it:

  1. Wastes gas by storing the same data twice.
  2. Requires maintaining consistency between mapping key and struct field.
  3. Increases contract deployment cost.
03Section · Recommendation

Recommendation

Remove the redundant positionId from the struct and use the mapping key when needed.

F-2025-0017

oog
zealynx

Smart Contract Security Digest

Monthly exploit breakdowns, audit checklists, and DeFi security research — straight to your inbox

© 2026 Zealynx