get_lp_positions
Retrieve all liquidity pool positions for a Solana wallet address, including pool details, token balances, and LP token amounts.
Instructions
Get all liquidity pool positions for a wallet address. Returns pool details, token balances, and LP token amounts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wallet | Yes | Solana wallet address (base58 encoded) |
Implementation Reference
- src/tools/get-lp-positions.js:5-53 (handler)The main execution logic for the get_lp_positions tool. Fetches LP positions via poolService and formats a detailed text response.async function getLpPositionsTool(args, poolService) { const { wallet } = args; if (!wallet) { throw new Error("Wallet address is required"); } try { const positions = await poolService.getLPPositions(wallet); if (positions.length === 0) { return { content: [ { type: "text", text: `No LP positions found for wallet: ${wallet}`, }, ], }; } // Format positions for display const positionsText = positions .map( (pos, idx) => `\n**Position ${idx + 1}:**\n` + `- Pool: ${pos.poolAddress}\n` + `- LP Balance: ${pos.lpTokenBalance}\n` + `- Token 0: ${pos.token0}\n` + `- Token 1: ${pos.token1}\n` ) .join("\n"); return { content: [ { type: "text", text: `Found ${positions.length} LP position(s) for wallet: ${wallet}\n` + positionsText + `\n\n**Summary:**\n` + `Total Positions: ${positions.length}`, }, ], }; } catch (error) { throw new Error(`Failed to get LP positions: ${error.message}`); } }
- src/index.js:50-63 (schema)Input schema and metadata definition for the get_lp_positions tool, specifying the required 'wallet' parameter.name: "get_lp_positions", description: "Get all liquidity pool positions for a wallet address. Returns pool details, token balances, and LP token amounts.", inputSchema: { type: "object", properties: { wallet: { type: "string", description: "Solana wallet address (base58 encoded)", }, }, required: ["wallet"], }, },
- src/index.js:156-157 (registration)Tool dispatch/registration in the CallToolRequest handler, mapping 'get_lp_positions' to the getLpPositionsTool function.case "get_lp_positions": return await getLpPositionsTool(args, this.poolService);
- src/services/pool-service.js:9-35 (helper)Supporting helper method in SarosPoolService that retrieves and simulates LP positions by querying token accounts for the wallet.async getLPPositions(walletAddress) { try { const wallet = new PublicKey(walletAddress); const tokenAccounts = await this.connection.getParsedTokenAccountsByOwner( wallet, { programId: new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") } ); const positions = []; for (const account of tokenAccounts.value) { const accountInfo = account.account.data.parsed.info; const balance = accountInfo.tokenAmount.uiAmount; if (balance > 0 && positions.length < 5) { positions.push({ poolAddress: accountInfo.mint, lpTokenBalance: balance, lpTokenMint: accountInfo.mint, token0: "TokenA", token1: "TokenB", }); } } return positions; } catch (error) { throw new Error(`Failed to get LP positions: ${error.message}`); } }