Submitted by KIntern_NA, also found by Trust and KingNFT
Struct FeeParameters contains 12 fields as follows:
Function LBPair.setFeeParamters(bytes _packedFeeParamters) is used to set the first 8 fields which was stored in 144 lowest bits of LBPair._feeParameters slot to 144 lowest bits of _packedFeeParameters (The layout of _packedFeeParameters can be seen here).
As we can see in the implementation of LBPair._setFeesParametes above, it gets the 112 highest bits of _feeStorageSlot and stores it in the 112 lowest bits of _varParameter. Then it gets the 144 lowest bits of packedFeeParameter and stores it in the 144 lowest bits of _newFeeParameters.
Following the purpose of function setFeeParameters, the new LBPair._feeParameters should form as follow:
It will make feeParameters = _newFeeParameters | (_varParameters << 144). But current implementation just stores the or value of _varParameters and _newFeeParameter into _feeParameters.slot. It forgot to shift left the _varParameters 144 bits before executing or operation.
This will make the value of binStep, , maxVolatilityAccumulated incorrect, and also remove the value (make the bit equal to 0) of volatilityAccumulated, , time.
--> Make all the tokens stuck in the pools
Here is our test script to describe the impacts
You can place this file into /test folder and run it using
Explanation of test script:
Foundry
Modify function LBPair._setFeesParaters as follow:
0x0Louis (Trader Joe) confirmed
Alex the Entreprenerd (judge) commented:
