The QuantAMMWeightedPoolFactory contract lacks essential validation for token weights during pool creation, violating a fundamental mathematical requirement of weighted pools. The weights must sum to FixedPoint.ONE (1.0) to ensure correct price calculations and pool operations.
Here's the comment on the contract:
Here are the affected code:
https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/QuantAMMWeightedPoolFactory.sol#L44
https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/QuantAMMWeightedPoolFactory.sol#L131C3-L173C2
https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/QuantAMMWeightedPoolFactory.sol#L85C1-L125C6
The weight validation is crucial because:
Price Calculation Formula: P = (Balance_out/Weight_out)/(Balance_in/Weight_in)
Incorrect weights directly distort this calculation
Example: With weights summing to 1.2 instead of 1.0, prices are off by 20%
Pool Balance Requirements:
Price Distortions:
Swaps execute at incorrect prices
Arbitrage opportunities emerge
Pool value can be extracted
Liquidity Provider Effects:
Incorrect share distribution
Impermanent loss miscalculations
Unintended exposure ratios
Pool Operations:
All swap calculations permanently incorrect
Join/Exit ratios distorted
Fee calculations inaccurate
Connected Systems:
Price oracles receive wrong data
Connected pools affected
Trading strategies compromised
Manual review
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
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.