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.
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
Gas wastage
Manual Review, Chisel.
Total base operations: 3 operations Estimated gas cost: ~9 gas
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.
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.