-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add getPoolState method to the StateLibrary #721
base: main
Are you sure you want to change the base?
Conversation
498b540
to
27aa510
Compare
27aa510
to
677adce
Compare
StateLibrary.getPoolState(manager, poolId); | ||
snapLastCall("extsload getPoolState"); | ||
|
||
assertEq(slot0.sqrtPriceX96(), 78680104762184586858280382455); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you instead test these against getSlot0
?
returns (Slot0 slot0, uint256 feeGrowthGlobal0X128, uint256 feeGrowthGlobal1X128, uint128 liquidity) | ||
{ | ||
bytes32 stateSlot = _getPoolStateSlot(poolId); | ||
bytes memory data = manager.extsload(stateSlot, 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be updated to an array of bytes32 that gets returned
slot0 := mload(add(data, 32)) | ||
feeGrowthGlobal0X128 := mload(add(data, 64)) | ||
feeGrowthGlobal1X128 := mload(add(data, 96)) | ||
liquidity := mload(add(data, 128)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to be masked to remove the other 128 bits of data from this data type
This util is helpful when someone wants to read all the global pool state. It is better than making multiple extsload calls.