QuantAMM

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

The implemented algorithm does not correspond to the stated Minimum Variance strategy

Summary

The Minimum Variance update rule implemented in MinimumVarianceUpdateRule.sol incorrectly calculates new asset weights, ignoring the correlation between them. Instead of the full inverse covariance matrix, only diagonal elements (variance) are used, which contradicts the principles of the Minimum Variance strategy and may lead to suboptimal asset allocation and increased risk.

Vulnerability Details

Lines of MinimumVarianceUpdateRule.sol demonstrate the calculation of newWeights without considering the correlation between assets, using only the vector containing inverse variance values.

Formula in the code comments of MinimumVarianceUpdateRule.sol: w(t) = (Λ w(t - 1)) + ((1 - Λ)Σ^-1(t)) / N,j=1∑ Σ^-1 j(t), where Σ^-1(t) is the full inverse covariance matrix.

The formula assumes the full inverse covariance matrix Σ^-1(t). This matrix contains information about the variance of each asset (on the diagonal) and the covariance between each pair of assets (off the diagonal).

int256[] memory newWeights = _calculateQuantAMMVariance(_data, _poolParameters);
int256 divisionFactor;
newWeightsConverted = new int256[](_prevWeights.length);
if (_parameters[0].length == 1) {
int256 mixingVariance = _parameters[0][0];
// calculating (1 − Λ)*Σ^−1(t)
int256 oneMinusLambda = ONE - mixingVariance;
for (uint i; i < _prevWeights.length; ) {
int256 precision = ONE.div(newWeights[i]);
divisionFactor += precision;
newWeights[i] = oneMinusLambda.mul(precision);
unchecked {
++i;
}
}
// To avoid intermediate overflows (because of normalization), we only downcast in the end to an uint64
// Divide precision vector by the sum of precisions and add Λw(t - 1)
// (Λ * w(t − 1)) + ((1 − Λ)*Σ^−1(t)) / N,j=1∑ Σ^−1 j(t)
for (uint i; i < _prevWeights.length; ) {
int256 res = mixingVariance.mul(int256(_prevWeights[i])) + newWeights[i].div(divisionFactor);
newWeightsConverted[i] = res;
unchecked {
++i;
}
}

The code calculates new weights (newWeightsConverted) without considering the correlation between assets. Instead of calculating the full inverse covariance matrix Σ^−1(t), the code uses a vector obtained from the function _calculateQuantAMMVariance, which returns only the inverse values of the variances.

Impact

This inconsistency causes the implemented algorithm to fall short of the stated Minimum Variance strategy. Instead of minimizing the overall risk of the portfolio by taking into account the correlation between assets, the code simply scales the weights of assets based on their individual volatility. Simply put, the formula in the comments talks about the need to consider the "relationships" between assets, but the code only looks at how much each asset "jumps" on its own.

The consequences of this mismatch are:

  • Inefficient asset allocation.

  • Increased risk for investors.

  • Non-compliance with the stated functionality of the Minimum Variance Update Rule.

To illustrate, if Bitcoin and Ethereum exhibit a strong positive correlation (meaning they tend to move in the same direction), simply diversifying by allocating assets between them might not be effective in mitigating risk. A Minimum Variance update rule that accounts for correlation would ideally reduce the weight of both assets in favour of less correlated assets to decrease the overall portfolio risk.

Unfortunately, the current implementation in MinimumVarianceUpdateRule.sol cannot achieve this due to its failure to consider correlation. Instead, it might even increase the weights of Bitcoin and Ethereum if their individual variances decrease, ultimately leading to an increase in the overall portfolio risk.

Tools Used

Manual

Recommendations

it's crucial to address this discrepancy by explicitly calculating and utilising the full inverse covariance matrix Σ^−1(t) within the Minimum Variance update rule algorithm. This will ensure that the strategy aligns with its theoretical foundation and effectively minimises portfolio risk

Updates

Lead Judging Commences

n0kto Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Appeal created

hajime Submitter
11 months ago
n0kto Lead Judge
11 months ago
n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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

Give us feedback!