Skip to content

Potential Issue with Commission Distribution in StakeCredit Contract #646

Description

@nickwest-zkp

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:

  1. _reward is explicitly added to totalPooledBNB:
rewardRecord[index] += _reward;
totalPooledBNB += _reward;
  1. _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:

  1. Validators receiving less commission than expected (since part is shared)
  2. Delegators receiving more rewards than intended
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions