Description
In UpdateWeightRunner.sol, both the uplift fee and swap fee mechanisms incorrectly use the same state variable quantAMMSwapFeeTake. This prevents the protocol from implementing different fee structures for swap and uplift operations, potentially leading to revenue loss and economic model disruption.
Vulnerable Code
uint256 public quantAMMSwapFeeTake = 0.5e18;
function setQuantAMMSwapFeeTake(uint256 _quantAMMSwapFeeTake) external override {
require(msg.sender == quantammAdmin, "ONLYADMIN");
require(_quantAMMSwapFeeTake <= 1e18, "Swap fee must be less than 100%");
uint256 oldSwapFee = quantAMMSwapFeeTake;
quantAMMSwapFeeTake = _quantAMMSwapFeeTake;
emit SwapFeeTakeSet(oldSwapFee, _quantAMMSwapFeeTake);
}
function setQuantAMMUpliftFeeTake(uint256 _quantAMMUpliftFeeTake) external {
require(msg.sender == quantammAdmin, "ONLYADMIN");
require(_quantAMMUpliftFeeTake <= 1e18, "Uplift fee must be less than 100%");
uint256 oldSwapFee = quantAMMSwapFeeTake;
quantAMMSwapFeeTake = _quantAMMUpliftFeeTake;
emit UpliftFeeTakeSet(oldSwapFee, _quantAMMUpliftFeeTake);
}
function getQuantAMMUpliftFeeTake() external view returns (uint256) {
return quantAMMSwapFeeTake;
}
Impact
HIGH severity due to:
Protocol cannot maintain separate fee structures for different operations
Setting one fee automatically overwrites the other
Protocol loses revenue when a higher fee is overwritten by a lower fee
Users may be charged incorrect fees
Proof of Concept
setQuantAMMSwapFeeTake(0.5e18);
assert(getQuantAMMSwapFeeTake() == 0.5e18);
setQuantAMMUpliftFeeTake(1e18);
assert(getQuantAMMUpliftFeeTake() == 1e18);
assert(getQuantAMMSwapFeeTake() == 1e18);
Tools Used
Manual code review
Static analysis
Recommendations
Separate State Variables
uint256 public quantAMMSwapFeeTake = 0.5e18;
uint256 public quantAMMUpliftFeeTake = 0.5e18;
Fix Uplift Fee Setter
function setQuantAMMUpliftFeeTake(uint256 _quantAMMUpliftFeeTake) external {
require(msg.sender == quantammAdmin, "ONLYADMIN");
require(_quantAMMUpliftFeeTake <= 1e18, "Uplift fee must be less than 100%");
uint256 oldUpliftFee = quantAMMUpliftFeeTake;
quantAMMUpliftFeeTake = _quantAMMUpliftFeeTake;
emit UpliftFeeTakeSet(oldUpliftFee, _quantAMMUpliftFeeTake);
}
Fix Uplift Fee Getter
function getQuantAMMUpliftFeeTake() external view returns (uint256) {
return quantAMMUpliftFeeTake;
}