Summary
The Swap Tax and NFT Royalty Fees are supposd to be initialized at 2%
total according to the comments. However, the implementation is set at 20%
.
Vulnerability Details
The implementation sets these fees at 20%
instead of 2%
as stated in the comments
feeTypes[6] = FeeType({
>>
veRAACShare: 500,
burnShare: 500,
repairShare: 1000,
treasuryShare: 0
});
feeTypes[7] = FeeType({
>>
veRAACShare: 500,
burnShare: 0,
repairShare: 1000,
treasuryShare: 500
});
As seen above, the percentages are wrongly set. For example, using basis points set at 10000
representing 100%
, 0.5%
should be represented by 50 bps
not 500
as used above.
During fee distribution, the shares are computed based on the fee type basis points as shown here:
for (uint8 i = 0; i < 8; i++) {
uint256 feeAmount = _getFeeAmountByType(i);
if (feeAmount == 0) continue;
FeeType memory feeType = feeTypes[i];
totalCollected += feeAmount;
uint256 weight = (feeAmount * BASIS_POINTS) / totalFees;
>> shares[0] += (weight * feeType.veRAACShare) / BASIS_POINTS;
>> shares[1] += (weight * feeType.burnShare) / BASIS_POINTS;
>> shares[2] += (weight * feeType.repairShare) / BASIS_POINTS;
>> shares[3] += (weight * feeType.treasuryShare) / BASIS_POINTS;
}
if (totalCollected != totalFees) revert InvalidFeeAmount();
shares[0] = (totalFees * shares[0]) / BASIS_POINTS;
shares[1] = (totalFees * shares[1]) / BASIS_POINTS;
shares[2] = (totalFees * shares[2]) / BASIS_POINTS;
shares[3] = (totalFees * shares[3]) / BASIS_POINTS;
>> uint256 remainder = totalFees - (shares[0] + shares[1] + shares[2] + shares[3]);
>> if (remainder > 0) shares[3] += remainder;
Impact
If it the intention of the protocol is to allocate a very small portion of Swap taxes and Royalty fees to other entities and the rest to treasury, this will not work as required.
Tools Used
Manual Review
Recommendations
Adjust the basis points as follows:
// Buy/Sell Swap Tax (2% total)
feeTypes[6] = FeeType({
- veRAACShare: 500, // 0.5%
- burnShare: 500, // 0.5%
- repairShare: 1000, // 1.0%
- treasuryShare: 0
+ veRAACShare: 50, // 0.5%
+ burnShare: 50, // 0.5%
+ repairShare: 100, // 1.0%
+ treasuryShare: 0
});
// NFT Royalty Fees (2% total)
feeTypes[7] = FeeType({
- veRAACShare: 500, // 0.5%
- burnShare: 0,
- repairShare: 1000, // 1.0%
- treasuryShare: 500 // 0.5%
+ veRAACShare: 50, // 0.5%
+ burnShare: 0,
+ repairShare: 100, // 1.0%
+ treasuryShare: 50 // 0.5%
});