Summary
The `_initializeFeeTypes()` function in the `FeeCollector.sol` is responsible for setting up default fee types according to protocol rules. While the fee types for most categories appear to be configured correctly, the fee calculations for the Buy/Sell Swap Tax `(feeTypes[6])` and NFT Royalty Fees `(feeTypes[7])` are inconsistent with the documented intended percentages.
Vulnerability Details
The function initializes several fee types with values expressed in basis points. For instance, `feeTypes[0]` through `feeTypes[5]` set percentages that sum to 100% (10000 basis points). However, the following fee types exhibit discrepancies:
Buy/Sell Swap Tax `(feeTypes[6])`:
Documented as "2% total"
Values provided:
veRAACShare: 500
burnShare: 500
repairShare: 1000
treasuryShare: 0
Total = 500 + 500 + 1000 + 0 = 2000 basis points
This total corresponds to 20%, not 2%.
NFT Royalty Fees (feeTypes[7]):
Documented as "2% total"
Values provided:
veRAACShare: 500
burnShare: 0
repairShare: 1000
treasuryShare: 500
Total = 500 + 0 + 1000 + 500 = 2000 basis points
Again, this sums to 20% rather than the intended 2%.
The discrepancy indicates that either the numerical values or the intended percentages are misconfigured.
### Proof of Concept
Consider a transaction where a Buy/Sell Swap Tax is applied on an amount of 100 tokens. With the current configuration:
A fee of 20% would result in a 20-token fee.
However, if the intended fee is 2%, the fee should be only 2 tokens. This clear mismatch demonstrates that the values configured for feeTypes[6] and feeTypes[7] are likely an order of magnitude too high.
Impact
Excessive Fee Charges: If the fee percentages are applied as configured, users may be charged fees up to 20% instead of the intended 2%, leading to significant user dissatisfaction and potential loss of participation.
Misallocation of Protocol Revenue: Incorrect fee calculations can distort the distribution of fees among stakeholders, such as veRAAC holders and the treasury, adversely affecting the protocol’s economics.
Protocol Trust and Adoption: Overcharging fees may deter users and negatively impact trust in the protocol, reducing its overall competitiveness and market adoption.
Tools Used
Manual Review
Recommendations
Review and Correct Fee Values:
Confirm the intended fee percentages. If the intended fee is 2% (i.e., 200 basis points out of 10000), adjust the values for feeTypes[6] and feeTypes[7] accordingly. For example, a possible correction for feeTypes[6] could be:
```solidity
Copy
Edit
feeTypes[6] = FeeType({
veRAACShare: 50, // 0.5%
burnShare: 50, // 0.5%
repairShare: 100, // 1.0%
treasuryShare: 0 // 0%
});
```
Similarly, adjust `feeTypes[7]` so that the sum of its shares equals 200 basis points.
Update Documentation:
Clearly document the intended fee percentages and ensure that the code comments and variable names reflect these intentions accurately.
Implement Unit Tests:
Create tests to simulate fee calculations for each fee type to ensure that the computed fees match the intended percentages, preventing regression in fee configuration.
By addressing these issues, the protocol can ensure that fee distributions are accurately calculated, preserving the intended economic incentives and maintaining user trust.