The calculation of difference momentum have multiple of exponents and negative signs giving these equation to calculate difference momentum
w(t) = w(t − 1) + κ · ( (EWMA_short - EWMA_long) / EWMA_long − ℓp(t))
where ℓp(t) = 1/N * ∑((EWMA_short - EWMA_long) / EWMA_long)_i
Focusing on ℓp(t) and the (EWMA_short - EWMA_long) / EWMA_long
The weight[i] calculate the value of (EWMA_short[i] - EWMA_long[i]) / EWMA_long[i]
And the ℓp(t) is sum of all these values so its bigger than each of them leading to negative weights values appear incase of a scalar kappa (kappa.length = 1)
add this test function in DifferenceMomentumRuleTest
Wrong calculation of weights for Difference Momentum role breaks all logic of the contract
Calculation of weights is a core to the protocol and can't have any small error as it have huge impact on the protocol
manual review
apply this require with a scalar kappa
_clampWeights will check that these weights are positive and in the boundaries before writing them in storage.
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.