The QuantAMM protocol's gradient-based update rules share a common state mapping that persists across rule transitions, allowing potential manipulation of pool weights through inconsistent gradient interpretations between different rules.
The QuantAMM protocol implements several weight update rules that inherit from QuantammGradientBasedRule
to dynamically adjust pool weights. These rules include MomentumUpdateRule
, AntiMomentumUpdateRule
, ChannelFollowingUpdateRule
, and PowerChannelUpdateRule
.
The base contract QuantammGradientBasedRule
maintains gradient states in a shared mapping:
QuantammGradientBasedRule.sol#L18-L19
This mapping stores intermediate gradient calculations used by all rules for exponential moving averages and weight adjustments. The critical vulnerability stems from three key issues:
The intermediateGradientStates
mapping is shared across all rules for a given pool address
The mapping is marked as internal
rather than private
, allowing inherited contracts to modify it
The setRuleForPool()
function in UpdateWeightRunner
lacks gradient state validation during rule transitions
Different rules interpret these gradients in fundamentally different ways:
When a pool transitions between rules via setRuleForPool()
, the gradient states persist without normalization, allowing the new rule to misinterpret the previous rule's gradient calculations.
Medium severity as the shared gradient state can be exploited to manipulate pool weights during rule transitions, leading to artificial price movements and arbitrage opportunities. While weight guards provide some protection, the core issue allows gradual manipulation across update cycles.
Attacker initializes pool with MomentumUpdateRule
:
Manipulates gradient state through price movements:
Transitions to ChannelFollowingUpdateRule
:
Exploits distorted weights through arbitrage before normalization.
Manual Review
Implement gradient state isolation by extending the state mapping with rule type and add gradient normalization during rule transitions. Additionally, implement proper validation in the UpdateWeightRunner
to ensure safe state transitions between different update rules, preventing potential manipulation of pool weights through gradient state inheritance.
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.