QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: medium
Invalid

Incorrect Rounding Direction in Weight Calculation Leading to Pool Insolvency Risk

Summary

A vulnerability has been identified in the calculateBlockNormalisedWeight function where incorrect rounding direction is used for negative weight multipliers. The function currently uses mulUp when calculating weight reductions:

https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/QuantAMMWeightedPool.sol#L538

if (multiplier > 0) {
return uint256(weight) + FixedPoint.mulDown(uint256(multiplierScaled18), timeSinceLastUpdate);
} else {
return uint256(weight) - FixedPoint.mulUp(uint256(-multiplierScaled18), timeSinceLastUpdate); // Incorrect rounding
}

The vulnerability stems from the mathematical implications of rounding up negative multipliers. When weights are decreasing, the function rounds up the reduction amount, causing weights to decrease more aggressively than mathematically intended. This excessive reduction compounds over time, systematically undervaluing pool assets relative to their true mathematical weights.

The economic impact manifests through arbitrage opportunities where users can extract more value than mathematically justified. For instance, when a weight should decrease by 1.5 units, the current implementation rounds up to 2 units. This 0.5 unit excessive reduction per calculation creates a cumulative deviation from the true mathematical model, potentially leading to protocol insolvency through systematic exploitation of these undervalued assets.

Recommended Mitigation Steps

The fix requires modifying the rounding direction for negative multipliers to use mulDown, ensuring conservative weight reductions that protect protocol solvency:

if (multiplier > 0) {
return uint256(weight) + FixedPoint.mulDown(uint256(multiplierScaled18), timeSinceLastUpdate);
} else {
return uint256(weight) - FixedPoint.mulDown(uint256(-multiplierScaled18), timeSinceLastUpdate);
}
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.