-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Code is here:
v4-core/src/libraries/StateLibrary.sol
Lines 176 to 191 in 59d3ecf
/** | |
* @notice Retrieves total the liquidity of a pool. | |
* @dev Corresponds to pools[poolId].liquidity | |
* @param manager The pool manager contract. | |
* @param poolId The ID of the pool. | |
* @return liquidity The liquidity of the pool. | |
*/ | |
function getLiquidity(IPoolManager manager, PoolId poolId) internal view returns (uint128 liquidity) { | |
// slot key of Pool.State value: `pools[poolId]` | |
bytes32 stateSlot = _getPoolStateSlot(poolId); | |
// Pool.State: `uint128 liquidity` | |
bytes32 slot = bytes32(uint256(stateSlot) + LIQUIDITY_OFFSET); | |
liquidity = uint128(uint256(manager.extsload(slot))); | |
} |
The docstring states that the function "[r]etrieves total the liquidity of a pool" but an examination of the code reveals that it instead gets the active liquidity, not total liquidity. Active liquidity is fine but the doscstring is misleading.
Expected Behavior
Expected behavior is that the function would return the total liquidity.
To Reproduce
It's a lot of overhead to show it in code (you can just look at what the source does) but it can be confirmed by doing the following:
- Make a new, empty pool with some starting price with tick
t
. - Add single-sided liquidity at tick
t'
wheret != t'
. - Check that tokens were moved into the pool manager via
getBalance
. - Call
StateLibrary.getLiquidity()
. It will return 0 since the current price/tick is not in the range of liquidity added.
Obviously one must take are that t'
is not in the same tick-spacing-bin as t
.
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working