QuantAMM

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

Gas waste by initializing n*n 2d memory array in QuantAMMCovarianceBasedRule

Summary

In QuantAMMCovarianceBasedRule::_setIntermediateCovariance the function initializes a 2d array of size n*n as seen here line 59

int256[][] memory newState = new int256[][]();

newState is meant to be an n by n 2d array for the covariance matrix but is instead initialized as an n*n by n 2d array.
In the case of pools with say 8 tokens , this becomes a 64 by 8 2d array, which leads to significant gas wastage due to solidity's memory expansion costs.

Impact

Low - unnecessary gas waste in an already gas intensive function

Tools Used

Manual Review

Recommendations

Should instead be

int256[][] memory newState = new int256[][]();
Updates

Lead Judging Commences

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