F-2025-0015·incorrect-accounting

moveStakeToSelfStake Does Not Decrease stakers Count

Fixedliquid-stakinglststaking-poolsgithub.com/matchain/contracts
TL;DR

When a user transfers their PoolOwnership NFT, moveStakeToSelfStake migrates their stake into selfStake but never decrements the stakers counter, leaving the metric inflated.

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

Description

When a user transfers their PoolOwnership NFT by calling transferFrom(), the NFT contract internally invokes:

solidity
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 stakers variable 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.
03Section · Impact

Impact

The stakers counter drifts upward over time, breaking analytics and any feature that relies on accurate staker counts.

04Section · Recommendation

Recommendation

Update the moveStakeToSelfStake function to ensure the stakers count is decremented when a non-zero stake is moved:

solidity
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
}
}
F-2025-0015

oog
zealynx

Smart Contract Security Digest

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

© 2026 Zealynx