The AMM's weight calculation function (_getWeights) in ChannelFollowingUpdateRule.sol implements asymmetric validation between scalar and vector kappa modes. While vector kappa mode enforces positive weight validation through a require statement, scalar kappa mode lacks this protection, allowing portfolio weights to become negative. This discrepancy creates a potential for portfolio imbalance and system manipulation.
Affected section of code: https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/rules/ChannelFollowingUpdateRule.sol#L226-L236
Within the _getWeights function, weight validation occurs differently based on the kappa parameter structure:
In vector kappa mode (when kappa.length > 1), weights are validated:
In scalar kappa mode (when kappa.length == 1), no validation exists, allowing negative weights:
The issue manifests under certain parameter combinations:
Small initial weights
Large price differentials
High amplitude settings
Narrow width parameters
Paste the following code into the QuantAMMChannelFollowing.t.sol file
Portfolio Imbalance: Negative weights can create mathematically inconsistent portfolio allocations
Economic Risks: Negative weights could be exploited to manipulate pool balances
Protocol Inconsistency: Different behavior between scalar and vector modes creates unexpected edge cases
Potential System Gaming: Attackers could intentionally trigger negative weights to exploit pool dynamics
Manual code review
Foundry testing framework
Primary Fix: Add weight validation to scalar kappa mode:
_clampWeights will check that these weights are positive and in the boundaries before writing them in storage.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.