get_farm_positions
Retrieve farming positions and staking rewards for any Solana wallet address, 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)Main tool execution handler: validates wallet arg, fetches positions via farmService, formats detailed text response with positions and rewards.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:100-114 (schema)Input schema definition for the get_farm_positions tool, specifying required 'wallet' string parameter.{ 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 dispatch/registration in the CallToolRequestSchema switch statement, invoking the handler with args and farmService.case "get_farm_positions": return await getFarmPositionsTool(args, this.farmService);
- src/index.js:19-19 (registration)Import of the getFarmPositionsTool handler from its module.const { getFarmPositionsTool } = require("./tools/get-farm-positions.js");
- src/services/farm-service.js:8-11 (helper)Helper service method called by the tool handler to fetch farm positions (demo implementation returns empty array).async getFarmPositions(walletAddress) { // Return empty for demo return []; }