Open
Description
Describe the bug
The StateLibrary contract function getTickBitmap
performs the necessary slot hashing to retrieve a particular tick initialization bitmap from storage at a given word, but the function argument and doc comments reference the lookup value as int16 tick
. The argument should be int16 word
(or similar) since bitmaps are divided at 256 bit (32 byte) boundaries. Further, ticks are int24
values, at odds with the function definition.
The function works correctly with some mental remapping of "tick" to "word", but leaving the argument name as-is will cause confusion.
Expected Behavior
The function should be modified to substitute "word" for "tick" where appropriate:
/**
* @notice Retrieves the tick bitmap of a pool at a specific word.
* @dev Corresponds to pools[poolId].tickBitmap[word]
* @param manager The pool manager contract.
* @param poolId The ID of the pool.
* @param word The word to retrieve the bitmap for.
* @return tickBitmap The bitmap of the word.
*/
function getTickBitmap(IPoolManager manager, PoolId poolId, int16 word)
internal
view
returns (uint256 tickBitmap)
{
// slot key of Pool.State value: `pools[poolId]`
bytes32 stateSlot = _getPoolStateSlot(poolId);
// Pool.State: `mapping(int16 => uint256) tickBitmap;`
bytes32 tickBitmapMapping = bytes32(uint256(stateSlot) + TICK_BITMAP_OFFSET);
// slot id of the mapping key: `pools[poolId].tickBitmap[word]
bytes32 slot = keccak256(abi.encodePacked(int256(word), tickBitmapMapping));
tickBitmap = uint256(manager.extsload(slot));
}
To Reproduce
No response
Additional context
No response