moveStakeToSelfStake Does Not Decrease stakers Count
When a user transfers their PoolOwnership NFT, moveStakeToSelfStake migrates their stake into selfStake but never decrements the stakers counter, leaving the metric inflated.
Description
When a user transfers their PoolOwnership NFT by calling transferFrom(), the NFT contract internally invokes:
function moveStakeToSelfStake(address staker) public {require(msg.sender == address(ownershipNFT), "Only NFT contract can call");if (stakes[staker] > 0) {selfStake += stakes[staker];stakes[staker] = 0;}}
While the function correctly transfers the user's stake into selfStake and clears the user's individual stake record, it does not decrement the stakers counter, which is used to track the number of unique addresses with a non-zero stake.
As a result, if a user holding stake transfers their ownership NFT, their stake is zeroed out, but the system still counts them as an active staker.
- The
stakersvariable becomes inaccurate, reflecting a higher count than the actual number of unique stakers. - This can affect analytics, on-chain or off-chain reward calculations, frontend representations, and any logic relying on the true count of active stakers.
Impact
The stakers counter drifts upward over time, breaking analytics and any feature that relies on accurate staker counts.
Recommendation
Update the moveStakeToSelfStake function to ensure the stakers count is decremented when a non-zero stake is moved:
function moveStakeToSelfStake(address staker) public {require(msg.sender == address(ownershipNFT), "Only NFT contract can call");if (stakes[staker] > 0) {selfStake += stakes[staker];stakes[staker] = 0;stakers--; // Adjust stakers count accurately}}

