Skip to main content
Glama

pancakeMyPosition

Track and manage your liquidity positions on PancakeSwap using the BSC MCP Server. This tool provides insights into your holdings, enabling informed decisions for DeFi strategies.

Instructions

check my liquidity position on panceke

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers the MCP tool 'View_PancakeSwap_Positions' (pancakeMyPosition) on the server.
    export function registerPancakeMyPosition(server: McpServer) {
    
        server.tool("View_PancakeSwap_Positions", "📊View your active liquidity positions on PancakeSwap", {}, async ({}) => {
    
                try {
                
                    const account = await getAccount();
                    const positions = await myPosition(account.address);
                    return {
                        content: [
                            {
                                type: "text",
                                text: `get user potitions successfully. ${JSON.stringify(positions, bigIntReplacer)}`
                            },
                        ],
                    };
                } catch (error) {
                    const errorMessage =
                        error instanceof Error ? error.message : String(error);
                    return {
                        content: [
                            {
                                type: "text",
                                text: `get user potitions failed: ${errorMessage}`,
                            },
                        ],
                        isError: true,
                    };
                }
            }
        );
    }
  • Inline handler for the tool that fetches account, calls myPosition helper, and returns formatted positions or error.
    server.tool("View_PancakeSwap_Positions", "📊View your active liquidity positions on PancakeSwap", {}, async ({}) => {
    
            try {
            
                const account = await getAccount();
                const positions = await myPosition(account.address);
                return {
                    content: [
                        {
                            type: "text",
                            text: `get user potitions successfully. ${JSON.stringify(positions, bigIntReplacer)}`
                        },
                    ],
                };
            } catch (error) {
                const errorMessage =
                    error instanceof Error ? error.message : String(error);
                return {
                    content: [
                        {
                            type: "text",
                            text: `get user potitions failed: ${errorMessage}`,
                        },
                    ],
                    isError: true,
                };
            }
        }
    );
  • Core helper function that queries PancakeSwap V3 positions for a given account address, retrieves detailed info including liquidity amounts, ticks, token details, and current values.
    export const myPosition = async (accountAddress: Address) => {
    
    
        const balance = await publicClient.readContract({
            abi: masterChefV3ABI,
            address: POSITION_MANAGER_ADDRESS,
            functionName: 'balanceOf',
            args: [accountAddress],
        })
    
    
        if (Number(balance) === 0) {
            return;
        }
    
        const nftCalls = []
        for (let i = 0; i < Number(balance); i++) {
            const nftCall = {
                abi: masterChefV3ABI,
                address: POSITION_MANAGER_ADDRESS,
                functionName: 'tokenOfOwnerByIndex',
                args: [accountAddress, BigInt(i)],
            }
            nftCalls.push(nftCall)
        }
    
    
        const nftIds = await publicClient.multicall<BigInt[]>({
            contracts: nftCalls,
            allowFailure: false,
        })
    
    
        const positionCalls = nftIds.map((nftId) => {
            return {
                abi: masterChefV3ABI,
                address: POSITION_MANAGER_ADDRESS,
                functionName: 'positions',
                args: [nftId],
            }
        })
    
        const positions = await publicClient.multicall<any[]>({
            contracts: positionCalls,
            allowFailure: false,
        }) as any[]
    
        const getTokenInfo = async (token: Address) => {
            const infoCalls = [
                {
                    address: token,
                    abi: ERC20_ABI,
                    functionName: 'symbol',
                    args: [],
                },
                {
                    address: token,
                    abi: ERC20_ABI,
                    functionName: 'name',
                    args: [],
                },
                {
                    address: token,
                    abi: ERC20_ABI,
                    functionName: 'decimals',
                    args: [],
                },
            ]
    
            const tokenInfo = await publicClient.multicall<any[]>({
                contracts: infoCalls,
                allowFailure: false,
            }) as any[]
            return {
                token,
                symbol: tokenInfo[0] as string,
                name: tokenInfo[1] as string,
                decimals: Number(tokenInfo[2]),
            }
        }
    
        const poolTokenInfos = await Promise.all(positions.map(async (position) => {
            const tokenInfos = await Promise.all([
                getTokenInfo(position[2] as Address),
                getTokenInfo(position[3] as Address),
            ]);
            return {
                token0: tokenInfos[0],
                token1: tokenInfos[1],
            }
        })) as any[]
    
        const poolCalls = []
        for (const position of positions) {
            const poolCall = {
                address: FACTORY_ADDRESS,
                abi: FACTORY_ABI,
                functionName: 'getPool',
                args: [
                    position[2] as Address,
                    position[3] as Address,
                    BigInt(position[4])
                ]
            }
            poolCalls.push(poolCall);
        }
    
        const pools = await publicClient.multicall<any[]>({
            contracts: poolCalls,
            allowFailure: false,
        }) as any[]
    
        const slot0Calls = []
        for (const pool of pools) {
            const slot0Call = {
                address: pool as Address,
                abi: POOL_ABI,
                functionName: 'slot0',
            }
            slot0Calls.push(slot0Call);
        }
        const slot0s = await publicClient.multicall<any[]>({
            contracts: slot0Calls,
            allowFailure: false,
        }) as any[]
    
        const positionInfos = []
        for (let i = 0; i < pools.length; i++) {
            const positionInfo = {
                tickCurrent: slot0s[i][1],
                tickLower: positions[i][5],
                tickUpper: positions[i][6],
                liquidity: positions[i][7],
                ...poolTokenInfos[i],
                feeTier: positions[i][4],
                positionId: nftIds[i],
            }
            const sqrtPriceX96 = TickMath.getSqrtRatioAtTick(positionInfo.tickCurrent);
            const sqrtPriceAX96 = TickMath.getSqrtRatioAtTick(positionInfo.tickLower);
            const sqrtPriceBX96 = TickMath.getSqrtRatioAtTick(positionInfo.tickUpper);
            const liquidity = BigInt(positionInfo.liquidity);
            let amount0;
            let amount1;
            if (positionInfo.tickCurrent < positionInfo.tickLower) {
                amount0 = SqrtPriceMath.getAmount0Delta(sqrtPriceAX96, sqrtPriceBX96, liquidity,
                    false);
                amount1 = BigInt(0);
            } else if (positionInfo.tickCurrent > positionInfo.tickUpper) {
                amount0 = BigInt(0);
                amount1 = SqrtPriceMath.getAmount1Delta(sqrtPriceAX96, sqrtPriceBX96, liquidity,
                    false);
            } else {
                amount0 = SqrtPriceMath.getAmount0Delta(sqrtPriceX96, sqrtPriceBX96, liquidity,
                    false);
                amount1 = SqrtPriceMath.getAmount1Delta(sqrtPriceAX96, sqrtPriceX96, liquidity,
                    false);
            }
            positionInfos.push({
                ...positionInfo,
                amount0,
                amount1,
                amount0Format: formatUnits(amount0, Number(positionInfo.token0.decimals)),
                amount1Format: formatUnits(amount1, Number(positionInfo.token1.decimals)),
            });
    
        }
    
        return positionInfos;
    }
  • src/main.ts:14-34 (registration)
    Imports and calls registerPancakeMyPosition to register the tool in the main server setup.
    import { registerPancakeMyPosition } from "./tools/pancakeMyPosition.js";
    import { registerPancakeRemovePosition } from "./tools/pancakeRemovePosition.js";
    import { registerGoplusSecurityCheck } from "./tools/goplusSecurityCheck.js";
    import { registerQueryMemeTokenDetails } from "./tools/queryMemeTokenDetails.js";
    
    // Main server entry
    export async function main() {
        const server = new McpServer({
            name: "bsc-mcp",
            version: "1.0.0"
        });
    
        // Register all tools
        registerTransferNativeToken(server);
        registerTransferBEP20Token(server);
        registerPancakeSwap(server);
        registerGetWalletInfo(server);
        registerBuyMemeToken(server);
        registerSellMemeToken(server);
        registerPancakeAddLiquidity(server);
        registerPancakeMyPosition(server);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states it's a read operation ('check'), but doesn't disclose behavioral traits such as authentication needs, rate limits, or what data is returned (e.g., position details, value). This leaves significant gaps for a tool interacting with DeFi protocols.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence but contains a typo ('panceke'), which undermines clarity. It's front-loaded with the core action, but the error reduces effectiveness, making it less than ideal for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of DeFi liquidity positions and lack of annotations or output schema, the description is incomplete. It doesn't explain what information is returned (e.g., token amounts, fees, value), leaving the agent uncertain about the tool's behavior and output.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description adds no parameter information, which is acceptable given no parameters exist, aligning with the baseline of 4 for zero-parameter tools.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the purpose ('check my liquidity position') but is vague about what 'panceke' refers to (likely a typo for PancakeSwap). It distinguishes from siblings like 'pancakeAddLiquidity' and 'pancakeRemovePosition' by focusing on checking rather than modifying positions, but the typo reduces clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives. It implies usage for checking liquidity positions, but doesn't specify prerequisites (e.g., needing an active position) or contrast with similar tools like 'getWalletInfo' for broader wallet data.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TermiX-official/bsc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server