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

[POC]: include potential positionsV2 #48

Closed
wants to merge 1 commit into from
Closed

Conversation

ChefMist
Copy link
Collaborator

@ChefMist ChefMist commented Nov 4, 2024

POC to check if positionsV2 is preferred. positionsV2 is also more similar to CLPositionManager.positions(tokenId) https://github.com/pancakeswap/pancake-v4-periphery/blob/main/src/pool-cl/CLPositionManager.sol#L425

Copied out from BinPositionManager positionsV2 and positions

function positionsV2(uint256 tokenId)
        external
        view
        returns (
            PoolKey memory poolKey,
            uint24 binId,
            uint128 binReserveX,
            uint128 binReserveY,
            uint256 binLiquidity,
            uint256 totalShares
        )
    {
        TokenPosition memory position = _positions[tokenId];

        if (PoolId.unwrap(position.poolId) == 0) revert InvalidTokenID();
        poolKey = _poolIdToPoolKey[PoolId.unwrap(position.poolId)];
        binId = position.binId;

        (binReserveX, binReserveY, binLiquidity, totalShares) = binPoolManager.getBin(position.poolId, position.binId);
    }

    function positions(uint256 tokenId)
        external
        view
        returns (PoolId poolId, Currency currency0, Currency currency1, uint24 fee, uint24 binId)
    {
        TokenPosition memory position = _positions[tokenId];

        if (PoolId.unwrap(position.poolId) == 0) revert InvalidTokenID();
        PoolKey memory poolKey = _poolIdToPoolKey[PoolId.unwrap(position.poolId)];

        return (position.poolId, poolKey.currency0, poolKey.currency1, poolKey.fee, position.binId);
    }

@ChefMist
Copy link
Collaborator Author

@ChefMist ChefMist closed this Nov 18, 2024
@ChefMist ChefMist deleted the feat/update-position branch November 18, 2024 01:25
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.

1 participant