QuantAMM

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

Channel following strategy is not implemented as per the QuantAMM whitepaper.

Summary

Incorrect implementation of the ‘trend’ or m(t) portion of the Channel following rule with respect to the QuantAMM whitepaper.

Vulnerability Details

In the ChannelFollowingUpdateRule.sol, the ‘trend’ or m(t) implementation is different from that specified in the whitepaper. The implementation in the contract is for

trend = (1-envelope) * sign(g) * |g/(2S)|^(exponent)

whereas in the QuantAMM whitepaper [Reference: https://docsend.com/view/8bx7x3vvjj6y44rh/d/xz4rrts499p69ha4], it is specified as

trend = (1-envelope) * sign(g) * |g|^(exponent)

where,
g = normalized price gradient = (1/p)·(dp/dt)

in both the cases.

All other equations for all the QuantAMM rules from the aforementioned QuantAMM whitepaper match the implementation. QuantAMM whitepaper is taken as a source of truth here and as mentioned in the “Known Issues” section, reproduced here.

“We do not exclude issues that find silent overflows, unintended sign changes based on the whitepaper equations, weight vectors that mean calculated values are not in accordance with whitepaper equations or ultimate breach of guard rails in a given block inside the weighted pool itself.”

Impact

High

Tools Used

Manual review

Recommended Mitigation

The factor (1/(2*S)) from the exponent portion of the equation for ‘trend’ or ‘m(t)’ to be deleted. For this consider changing the lines #170 and #191 of the contract from

int256 scaledAbsGradient = absGradient.div(locals.preExpScaling[0].mul(TWO));

to

int256 scaledAbsGradient = absGradient;

for the https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/rules/ChannelFollowingUpdateRule.sol#L170

and the line number #191 https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/rules/ChannelFollowingUpdateRule.sol#L191
can be modified from

int256 scaledAbsGradient = absGradient.div(locals.preExpScaling[locals.i].mul(TWO));

to

int256 scaledAbsGradient = absGradient;
Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

invalid_ChannelFollowingUpdateRule_whitepaper_incorrect_implementation

The formula here is the one in Whitepaper page 11, which is right and the division is explained on the last line : "Finally note …".

Support

FAQs

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