Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Valid

Incorrect distribution of fees among veRAAC holders

Summary

The _calculateDistribution function incorrectly calculates the distribution of total fees among different stakeholders.

Vulnerability Details

The FeeCollector::_calculateDistribution() function first calculates the weighted share of each fee type relative to totalFees and assigns these to shares. However, after summing up the weighted shares, the function overwrites them:

[contracts/core/collectors/FeeCollector.sol]
431 function _calculateDistribution(uint256 totalFees) internal view returns (uint256[4] memory shares) {
432 uint256 totalCollected;
433
434 for (uint8 i = 0; i < 8; i++) {
435 uint256 feeAmount = _getFeeAmountByType(i);
436 if (feeAmount == 0) continue;
437
438 FeeType memory feeType = feeTypes[i];
439 totalCollected += feeAmount;
440
441 uint256 weight = (feeAmount * BASIS_POINTS) / totalFees;
442 shares[0] += (weight * feeType.veRAACShare) / BASIS_POINTS;
443 shares[1] += (weight * feeType.burnShare) / BASIS_POINTS;
444 shares[2] += (weight * feeType.repairShare) / BASIS_POINTS;
445 shares[3] += (weight * feeType.treasuryShare) / BASIS_POINTS;
446 }
447
448 if (totalCollected != totalFees) revert InvalidFeeAmount();
449
450 -> shares[0] = (totalFees * shares[0]) / BASIS_POINTS;
451 -> shares[1] = (totalFees * shares[1]) / BASIS_POINTS;
452 -> shares[2] = (totalFees * shares[2]) / BASIS_POINTS;
453 -> shares[3] = (totalFees * shares[3]) / BASIS_POINTS;
454
455 uint256 remainder = totalFees - (shares[0] + shares[1] + shares[2] + shares[3]);
456 if (remainder > 0) shares[3] += remainder;
457 }

Since shares are already weighted relative to totalFees, this second scaling step results in incorrect share allocations. The final allocations will not accurately reflect the intended distribution percentages.

Impact

Incorrect distribution of fees among veRAAC holders

Recommendations

The initial calculation already distributes the fees correctly, so applying an additional scaling factor leads to incorrect results. The correct approach is to directly assign the weighted values to shares without further modification.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

FeeCollector distributes too much to treasury when fee amounts are small relative to total due to precision loss in (feeAmount * BASIS_POINTS) / totalFees

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

FeeCollector distributes too much to treasury when fee amounts are small relative to total due to precision loss in (feeAmount * BASIS_POINTS) / totalFees

Support

FAQs

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