Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: high
Invalid

Double Counting Error in Fee Calculation Leads to Excess Shares Minted and Distributed to Fee Receivers

Summary

In the StakingPool::_updateStrategyRewards function, the protocol calculates and distributes Liquid Staking Tokens (LST) to fee receivers based on balance changes in strategies. However, due to a double counting error in the calculation of totalFeeAmounts, the protocol mints and distributes an excess amount of shares to fee receivers. This incorrect share distribution can distort the token supply and unfairly reward participants.

Vulnerability Details

In the _updateStrategyRewards function, the protocol calculates the number of shares to be minted using the formula:

uint256 sharesToMint = (totalFeeAmounts * totalShares) / (totalStaked - totalFeeAmounts);

This formula ensures that totalFeeAmounts are subtracted from totalStaked before minting new shares. However, there is a double counting error in how totalFeeAmounts is handled.

The first time totalFeeAmounts is updated is when strategyFeeAmounts are added:

for (uint256 j = 0; j < strategyReceivers.length; ++j) {
totalFeeAmounts += strategyFeeAmounts[j];
}

View the relevant code here.

The second time occurs when feeAmounts[feeAmounts.length - 1][i] is added:

for (uint256 i = 0; i < fees.length; i++) {
receivers[receivers.length - 1][i] = fees[i].receiver;
feeAmounts[feeAmounts.length - 1][i] = (uint256(totalRewards) * fees[i].basisPoints) / 10000;
totalFeeAmounts += feeAmounts[feeAmounts.length - 1][i];
}

View the relevant code here.

This leads to a double counting issue because strategyFeeAmounts and feeAmounts are both portions of the same depositChange. The strategyFeeAmounts[j] are portions of depositChange, and feeAmounts[i] are portions of totalRewards, which is the sum of all strategies’ depositChange. View this here.

The double addition of totalFeeAmounts results in an inflated value, causing excess shares to be minted.

Impact

This error causes the protocol to mint more shares than necessary and distribute them to fee receivers.

Tools Used

Manual

Recommendations

To resolve the issue, ensure that totalFeeAmounts is only counted once when calculating shares to be minted. Adjust the fee calculation logic to avoid adding totalFeeAmounts twice and ensure that only the correct portions of depositChange are considered in the calculation.

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.