get_farm_positions
Retrieve farming positions and staking rewards for a Solana wallet, including staked LP tokens and claimable rewards.
Instructions
Get all farming positions and staking rewards for a wallet. Shows staked LP tokens and claimable rewards.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wallet | Yes | Solana wallet address |
Implementation Reference
- src/tools/get-farm-positions.js:5-59 (handler)Primary handler function that executes the get_farm_positions tool logic: validates wallet input, fetches positions from farmService, formats output as formatted text response, handles empty results and errors.async function getFarmPositionsTool(args, farmService) { const { wallet } = args; if (!wallet) { throw new Error("Wallet address is required"); } try { const positions = await farmService.getFarmPositions(wallet); if (positions.length === 0) { return { content: [ { type: "text", text: `No farm positions found for wallet: ${wallet}`, }, ], }; } // Format positions let positionsText = `**Farm Positions for ${wallet}**\n\n`; positionsText += `Total Farms: ${positions.length}\n\n`; positions.forEach((pos, idx) => { positionsText += `**Position ${idx + 1}:**\n` + `- Farm: ${pos.farmAddress}\n` + `- LP Token: ${pos.lpAddress}\n` + `- Staked Amount: ${pos.stakedAmount}\n` + `- Pool: ${pos.token0} / ${pos.token1}\n`; if (pos.pendingRewards && pos.pendingRewards.length > 0) { positionsText += `- Pending Rewards:\n`; pos.pendingRewards.forEach((reward) => { positionsText += ` • ${reward.amount} ${reward.symbol}\n`; }); } positionsText += `\n`; }); return { content: [ { type: "text", text: positionsText, }, ], }; } catch (error) { throw new Error(`Failed to get farm positions: ${error.message}`); } }
- src/index.js:101-114 (schema)Schema definition for the get_farm_positions tool, including input schema (wallet address required), provided in the ListTools response for tool discovery.name: "get_farm_positions", description: "Get all farming positions and staking rewards for a wallet. Shows staked LP tokens and claimable rewards.", inputSchema: { type: "object", properties: { wallet: { type: "string", description: "Solana wallet address", }, }, required: ["wallet"], }, },
- src/index.js:165-166 (registration)Tool registration in the central CallToolRequestSchema handler: dispatches calls to get_farm_positions to the specific getFarmPositionsTool function with farmService.case "get_farm_positions": return await getFarmPositionsTool(args, this.farmService);
- src/index.js:19-19 (registration)Import of the getFarmPositionsTool handler from its dedicated tool module.const { getFarmPositionsTool } = require("./tools/get-farm-positions.js");
- src/services/farm-service.js:8-11 (helper)Supporting service method called by the tool handler to retrieve farm positions data (currently a stub implementation).async getFarmPositions(walletAddress) { // Return empty for demo return []; }