Summary
The updateFeeType function can only set feeTypes with total of 100% fees, but some of the feeTypes such as the Buy/Sell swap tax and NFT Royalty fees are initialized as 2%.
This means that they cannot be updated in the future to between 0% and 99.9%. It has to be 100%.
Vulnerability Details
The updateFeeType function enforces that the total fee percentage to be always total of 100%. This means that feeTypes that are initialized as 2%, cannot be updated to 5% for example.
function updateFeeType(uint8 feeType, FeeType calldata newFee) external override {
if (!hasRole(FEE_MANAGER_ROLE, msg.sender)) revert UnauthorizedCaller();
if (feeType > 7) revert InvalidFeeType();
if (newFee.veRAACShare + newFee.burnShare + newFee.repairShare + newFee.treasuryShare != BASIS_POINTS) {
revert InvalidDistributionParams();
}
feeTypes[feeType] = newFee;
emit FeeTypeUpdated(feeType, newFee);
}
Impact
The contract loses the ability to manage fees dynamically.
If the protocol wants to lower or temporary disable specific fees, they won't be able to.
Tools Used
Manual
Recommendations
Consider using > BASIS_POINTS, instead of != BASIS_POINTS. This way fees can be set from 0 to 10_000.
function updateFeeType(uint8 feeType, FeeType calldata newFee) external override {
if (!hasRole(FEE_MANAGER_ROLE, msg.sender)) revert UnauthorizedCaller();
if (feeType > 7) revert InvalidFeeType();
// Validate fee shares total to 100%
// @audit this doesnt allow the total fees to be under 100%.
// the feeType of [6] and [7] for example is 2% total, but if that in the future
// wants to be changed to 5% total it will revert, since 5% = 500 and 500 != 10_000
- if (newFee.veRAACShare + newFee.burnShare + newFee.repairShare + newFee.treasuryShare != BASIS_POINTS) {
+ if (newFee.veRAACShare + newFee.burnShare + newFee.repairShare + newFee.treasuryShare > BASIS_POINTS) {
revert InvalidDistributionParams();
}
feeTypes[feeType] = newFee;
emit FeeTypeUpdated(feeType, newFee);
}