The QuantAMMGradientBasedRule contract, which serves as a base for multiple update rules, handles negative prices asymmetrically compared to positive prices. This leads to inconsistent gradient calculations that propagate to derived rules. While ChainlinkOracle enforces positive prices, negative prices can occur through MultiHopOracle's mathematical operations. The asymmetric gradient calculations could cause unexpected pool behavior and potential economic vulnerabilities.
Location: pkg/pool-quantamm/contracts/rules/base/QuantammGradientBasedRule.sol
The issue occurs in the gradient calculation where negative prices produce asymmetric results compared to equivalent positive prices:
When handling negative prices, the asymmetry arises from:
The price difference calculation (_newData[i] - _poolParameters.movingAverage[i])
Division by oneMinusLambda
Multiplication by the mulFactor (λ^3 / (1-λ))
Test Results:
Base gradient calculations are asymmetric for positive vs negative prices
This asymmetry propagates to all derived update rules
~91.7% larger gradient magnitude for negative prices
Inconsistent pool behavior depending on price sign
Could lead to unexpected weight distributions in derived rules
May create arbitrage opportunities due to predictable asymmetry
Breaks mathematical symmetry expected in gradient calculations
Could compound with other weight calculation issues
Modify gradient calculation to maintain symmetry:
Consider architectural improvements:
Add explicit sign handling throughout gradient calculations
Implement symmetry validation in base rule tests
Add invariant checks for gradient sign handling
Consider using absolute values for intermediate calculations
Add documentation about gradient sign handling expectations
Add comprehensive tests:
Test gradient symmetry with various price magnitudes
Test edge cases with extreme price values
Add property-based tests for gradient sign handling
Test interactions with derived rules
Test compounding effects over multiple updates
Multihop will call ChainlinkOracle and the check is in it: `require(data > 0, "INVLDDATA");` MultiHop is just here to combine Chainlinks feed when there is no direct USD price feed for a token.
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.