/**
* Tool: Get LP Positions
* Returns all liquidity pool positions for a given wallet
*/
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}`);
}
}
module.exports = { getLpPositionsTool };