Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xyek
Copy link
Contributor

@xyek xyek commented May 28, 2024

This util is helpful when someone wants to read all the global pool state. It is better than making multiple extsload calls.

@xyek xyek force-pushed the add-pool-state-extsload branch from 498b540 to 27aa510 Compare May 31, 2024 08:43
@xyek xyek force-pushed the add-pool-state-extsload branch from 27aa510 to 677adce Compare June 4, 2024 08:45
StateLibrary.getPoolState(manager, poolId);
snapLastCall("extsload getPoolState");

assertEq(slot0.sqrtPriceX96(), 78680104762184586858280382455);
Copy link
Contributor

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);
Copy link
Contributor

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))
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants