Potential Issue with Commission Distribution in StakeCredit Contract
Description
There appears to be an inconsistency in how validator commissions are handled in the StakeCredit contract's distributeReward function. Based on the code analysis, the current implementation may not be working as intended according to the expected reward distribution mechanism.
Expected Behavior
According to the distributeReward function's documentation and typical staking pool designs:
_commission should go directly to the validator as their commission
_reward (remaining amount after commission) should be added to the shared pool for all stakers
The commission should be deducted from the total reward and given exclusively to the validator, not shared with other delegators.
Actual Behavior
In the current implementation, both _commission and _reward are effectively added to the totalPooledBNB:
_reward is explicitly added to totalPooledBNB:
rewardRecord[index] += _reward;
totalPooledBNB += _reward;
_commission is also added to totalPooledBNB through the _mintAndSync function:
function _mintAndSync(address account, uint256 bnbAmount) internal returns (uint256 shares) {
// ...
totalPooledBNB += bnbAmount; // This adds the commission amount to the pool
}
This means that the validator's commission is also indirectly shared with all delegators, which may not be the intended behavior.
Code References
- File: [StakeCredit.sol]
- Function:
distributeReward
- Related function:
_mintAndSync
Impact
This implementation could lead to:
- Validators receiving less commission than expected (since part is shared)
- Delegators receiving more rewards than intended
- Incorrect reward calculations for all participants
Suggested Fix
If the intention is for commissions to go exclusively to validators, the _mintAndSync function should not increase totalPooledBNB when minting commission shares. Instead, a separate mechanism should be used to track validator-exclusive rewards.
Alternatively, if this is the intended behavior, the documentation should be updated to clarify that validator commissions are also shared with delegators.
Question
Could you please confirm whether this is the intended behavior or if this is indeed an issue that needs to be addressed?
Potential Issue with Commission Distribution in StakeCredit Contract
Description
There appears to be an inconsistency in how validator commissions are handled in the
StakeCreditcontract'sdistributeRewardfunction. Based on the code analysis, the current implementation may not be working as intended according to the expected reward distribution mechanism.Expected Behavior
According to the
distributeRewardfunction's documentation and typical staking pool designs:_commissionshould go directly to the validator as their commission_reward(remaining amount after commission) should be added to the shared pool for all stakersThe commission should be deducted from the total reward and given exclusively to the validator, not shared with other delegators.
Actual Behavior
In the current implementation, both
_commissionand_rewardare effectively added to thetotalPooledBNB:_rewardis explicitly added tototalPooledBNB:_commissionis also added tototalPooledBNBthrough the_mintAndSyncfunction:This means that the validator's commission is also indirectly shared with all delegators, which may not be the intended behavior.
Code References
distributeReward_mintAndSyncImpact
This implementation could lead to:
Suggested Fix
If the intention is for commissions to go exclusively to validators, the
_mintAndSyncfunction should not increasetotalPooledBNBwhen minting commission shares. Instead, a separate mechanism should be used to track validator-exclusive rewards.Alternatively, if this is the intended behavior, the documentation should be updated to clarify that validator commissions are also shared with delegators.
Question
Could you please confirm whether this is the intended behavior or if this is indeed an issue that needs to be addressed?