The Anti-Momentum Rule's _getWeights function lacks validation for negative weights when using scalar kappa parameters, while this validation exists for vector kappa. This inconsistency allows negative pool weights to be set, which could lead to invalid pool states and potential economic exploits.
In the _getWeights function, two different paths exist for weight calculation based on whether kappa is scalar (single value) or vector (multiple values):
For vector kappa:
For scalar kappa:
The vulnerability can be triggered under the following conditions:
Using scalar kappa configuration
Price movements creating large gradients
Kappa value sufficient to amplify the negative adjustment
Previous weights small enough to be overwhelmed by the negative adjustment
The issue was reproduced using the following parameters:
Kappa: 0.8e18
Previous weights: [0.5e18, 0.5e18]
Price data: [1e18, 3e18]
Moving averages: [2e18, 2e18]
Lambda: 0.2e18
Paste the code below into the QuantAMMAntiMomentum.t.sol file.
The ability to produce negative weights in an AMM pool can have severe consequences:
Pool operations like swaps and liquidity provisions may revert or behave unpredictably
Economic calculations based on pool weights could produce invalid results
Integration with other DeFi protocols may fail
Potential for economic exploits by manipulating prices to force negative weights
Loss of funds for liquidity providers if negative weights cause incorrect distribution of pool assets
Foundry for testing and reproduction
Manual code review
Add non-negative weight validation for scalar kappa:
_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.