QuantAMM

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

Discrepancy in Trend Portion Calculation in Channel Following Strategy

Summary

The trend portion calculation in the _getWeights function deviates from the whitepaper specification for the channel-following strategy. The deviation involves an additional division by 2โ‹…๐‘†, which reduces the magnitude of the trend contribution. This discrepancy impacts the behavior of the trend-following component, particularly for larger price gradients, leading to potential underperformance in capturing trends.

Vulnerability Details

The whitepaper defines the trend portion as:

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

In the _getWeights function, the following steps calculate the trend portion:

  1. Absolute Gradient Calculation

// Calculate trend portion
int256 absGradient = locals.newWeights[locals.i] >= 0
? locals.newWeights[locals.i]
: -locals.newWeights[locals.i];

This computes โˆฃ๐‘”โˆฃ, the absolute value of the price gradient, as required

  1. Scaling the Absolute Gradient

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

Here, the absolute gradient is scaled down by 2โ‹…๐‘†. This step is not specified in the whitepaper.

  1. Exponentiation

trendPortion = _pow(scaledAbsGradient, locals.exponents[0]);

The scaled gradient is raised to the power of the exponent

  1. Reintroducing the Sign

if (locals.newWeights[locals.i] < 0) {
trendPortion = -trendPortion;
}
  1. Combining with the Envelope

trendPortion = trendPortion.mul(ONE - envelope);

The division by 2โ‹…๐‘† during the scaling step artificially reduces the magnitude of the trend portion. This scaling is not part of the whitepaperโ€™s formula, leading to smaller contributions from the trend-following component, especially for larger price gradients.

Impact

The division by 2โ‹…๐‘† dampens the trend portionโ€™s magnitude. As a result:

  • For small gradients, the trend portion may become negligible, diminishing the systemโ€™s ability to respond to subtle market trends.

  • For large gradients, the reduced trend magnitude may fail to capitalize on significant directional changes.

Tools Used

Manual Review

Recommendations

Remove the division by 2โ‹…๐‘† in the scaling of the absolute gradient

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

If the division by 2โ‹…๐‘† is intentional (e.g., for stability or design constraints), document this deviation in the code and any associated documentation to ensure transparency.

Updates

Lead Judging Commences

n0kto Lead Judge about 1 year 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.

Give us feedback!