QuantAMM

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

Inefficient Bitwise Operations in QuantAMMStorage Contract

Summary

The current implementation of _quantAMMPackTwo128 uses unnecessary shift operations when packing two 128-bit integers into a single 256-bit integer. The function performs redundant left and right shifts on the right integer, resulting in higher gas costs than necessary.

Vulnerability Details

packed = (_leftInt << 128) | int256(uint256(_rightInt << 128) >> 128);

Left shift operation (<< 128) - 3 gas
Type conversion to uint256 - 3 gas
Right shift operation (>> 128) - 3 gas
Type conversion back to int256 - 3 gas
Bitwise OR operation (|) - 3 gas

_rightInt << 128: Shifts left by 128 bits

uint256() conversion

>> 128: Shifts right by 128 bits

Final int256() conversion

Total base operations: 5 operations Estimated gas cost: ~15 gas

Impact

Gas wastage

Tools Used

Manual Review, Chisel.

Recommendations

- packed = (_leftInt << 128) | int256(uint256(_rightInt << 128) >> 128);
+ packed = (_leftInt << 128) | (_rightInt & type(int128).max);

Total base operations: 3 operations Estimated gas cost: ~9 gas

Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas / Admin is trusted / Pool creation is trusted / User mistake / Suppositions

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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