Submitted by Trust
It is advised to first read finding: Due to slot confusion, reserve amounts in the pump will be corrupted, resulting in wrong oracle values, which provides all the contextual information for this separate bug.
Weve discussed how a wrong sload() source slot leads to corruption of the reserves. In LibBytes16, another confusion occurs.
Recall the correct storage overwriting done in LibBytes:
Importantly, it clears the lower 128 bytes of the source slot and replaces the upper 128 bytes of the dest slot using the upper 128 bytes of  the source slot:
shl(128,shr(128,SOURCE))
In storeBytes16(), the shl() operation has been discarded. This means the code will use the upper 128 bytes of SOURCE to overwrite the lower 128 bytes in DEST.
In other words, regardless of the SLOT being read, instead of keeping the lower 128 bits as is, it stores whatever happens to be in the upper 128 bits. Note this is a completely different error from the slot confusion, which happens to be in the same line of code.
Reserve amounts in the pump will be corrupted, resulting in wrong oracle values
Assume slot confusion bug has been corrected for clarity.
Replace the affected line with the calculation below:
shr(128, shl(128, SLOT))
This will use the lower 128 bytes and clear the upper 128 bytes,as intended.
publiuss (Basin) confirmed, but disagreed with severity and commented:
alcueca (Judge) decreased severity to Medium and commented:
publiuss (Basin) commented:
