In _quantAMMPack128Matrix, when handling matrices where the total number of elements is odd, the code assumes that the last element should always be placed at the very end of the storage array (_targetArray[targetArrayLength - 1]). However, this assumption is incorrect because:
The storage array length might be longer than what's needed for the matrix
The code should continue placing elements sequentially at the current targetArrayIndex
The current implementation could leave gaps (zeros) in the middle of the storage array
For example, if we have a 3x3 matrix (9 elements) and a target array of length 7, the last element would be placed at index 6 instead of index 4 where it should be according to the sequential packing pattern.
put this in test folder and run forge test --mp test/foundry/MatrixPack.t.sol -vvv
Data corruption when reading/unpacking the matrix incase of situation where by the matrix storage array is longer than data requirement.
Potential issues when interacting with other functions that expect packed data to be sequential.
Modify the code to place the last element at the current targetArrayIndex instead of forcing it to the end of the storage array:
This ensures that elements are always packed sequentially without leaving gaps in the storage array.
Called only in QuantammCovarianceBasedRule.sol with trusted parameters (set during creation or per a trusted function): `intermediateCovarianceStates[_poolAddress]`/`intermediateCovarianceStates[_poolParameters.pool]`. No real impact.
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.