Skip to main content
Glama

GET_POSITIONS

Retrieve a list of all your active positions in BAMM contracts on Fraxtal blockchain.

Instructions

Get all your active BAMM positions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The GET_POSITIONS tool definition and execute handler. It initializes WalletService and BammPositionsService, calls getPositions() and formatPositions() to fetch and display all active BAMM positions for the user.
    import { BammPositionsService } from "../services/get-positions.js";
    import { WalletService } from "../services/wallet.js";
    
    export const getPositionsTool = {
    	name: "GET_POSITIONS",
    	description: "Get all your active BAMM positions",
    	// biome-ignore lint/suspicious/noExplicitAny: <these are not used anyways>
    	execute: async (_params: any, _context: any) => {
    		try {
    			const privateKey = process.env.WALLET_PRIVATE_KEY;
    			if (!privateKey) {
    				return "Error: WALLET_PRIVATE_KEY environment variable is not set. Please set it with your wallet's private key (without 0x prefix).";
    			}
    
    			const walletService = new WalletService(privateKey);
    			const positionsService = new BammPositionsService(walletService);
    
    			const positions = await positionsService.getPositions();
    			const formattedPositions = positionsService.formatPositions(positions);
    
    			return formattedPositions;
    		} catch (error) {
    			if (error instanceof Error) {
    				return `❌ Failed to retrieve positions: ${error.message}`;
    			}
    			return "❌ An unknown error occurred while retrieving positions";
    		}
    	},
    };
  • The BammPosition interface defining the schema of a position: bamm address, vault (token0, token1, rented), pairAddress, poolName, token0Symbol, token1Symbol.
    export interface BammPosition {
    	bamm: Address;
    	vault: {
    		token0: bigint;
    		token1: bigint;
    		rented: bigint;
    	} | null;
    	// Additional Frax pool fields
    	pairAddress: string;
    	poolName: string;
    	token0Symbol: string;
    	token1Symbol: string;
    }
  • The getPositions() method in BammPositionsService. Queries the BAMM factory for all BAMM addresses, checks if the user has a position in each via isUser(), fetches vault details and Fraxswap pool metadata for each active position.
    async getPositions(): Promise<BammPosition[]> {
    	const publicClient = this.walletService.getPublicClient();
    	const walletClient = this.walletService.getWalletClient();
    
    	if (!walletClient || !walletClient.account) {
    		throw new Error("Wallet client is not initialized");
    	}
    
    	const userAddress = walletClient.account.address;
    
    	// 1. Retrieve the list of all BAMM addresses from the factory
    	const bammsArray = [
    		...(await publicClient.readContract({
    			address: BAMM_ADDRESSES.FACTORY,
    			abi: BAMM_FACTORY_ABI,
    			functionName: "bammsArray",
    			args: [],
    		})),
    	];
    
    	const positions: BammPosition[] = [];
    
    	// 2. Loop through each BAMM contract address
    	for (const bamm of bammsArray) {
    		// 3. Check if the user is registered in this BAMM using isUser
    		const isUser: boolean = await publicClient.readContract({
    			address: bamm,
    			abi: BAMM_ABI,
    			functionName: "isUser",
    			args: [userAddress],
    		});
    
    		// 4. If the user is registered, get their vault details
    		if (isUser) {
    			const vault = await publicClient.readContract({
    				address: bamm,
    				abi: BAMM_ABI,
    				functionName: "getUserVault",
    				args: [userAddress],
    			});
    			// get pair address from the BAMM contract
    			const pairAddress = await publicClient.readContract({
    				address: bamm,
    				abi: BAMM_ABI,
    				functionName: "pair",
    				args: [],
    			});
    			// call fraxswap API to get the pool details
    			const response = await fetch(
    				`https://api.frax.finance/v2/fraxswap/pools/${pairAddress}`,
    			);
    			if (!response.ok) {
    				throw new Error(
    					`Failed to fetch pool details: ${response.statusText}`,
    				);
    			}
    			const poolData = await response.json();
    			const poolName = poolData.pools[0].poolName;
    			const token0Symbol = poolData.pools[0].token0Symbol;
    			const token1Symbol = poolData.pools[0].token1Symbol;
    			positions.push({
    				bamm,
    				vault,
    				pairAddress,
    				poolName,
    				token0Symbol,
    				token1Symbol,
    			});
    		}
    	}
    
    	return positions;
    }
  • The formatPositions() method in BammPositionsService. Formats all BAMM positions into a human-readable message string with token amounts and rented info, filtering out zero-value or null positions.
    	formatPositions(positions: BammPosition[]) {
    		if (positions.length === 0 || positions.every((v) => !v)) {
    			return "📊 No Active BAMM Positions Found";
    		}
    
    		const formattedPositions = positions
    			.map((pos) => {
    				// Skip if vault is null
    				if (!pos.vault) {
    					return null;
    				}
    
    				// return if token0 and token1 is 0
    				if (pos.vault.token0 === 0n && pos.vault.token1 === 0n) {
    					return null;
    				}
    
    				return dedent`
                **💰 BAMM Position**
                - bamm: ${pos.bamm}
    						- Pair: ${pos.pairAddress}
                - ${pos.token0Symbol}: ${formatWeiToNumber(pos.vault.token0)}
                - ${pos.token1Symbol}: ${formatWeiToNumber(pos.vault.token1)}
    						- rented: ${formatWeiToNumber(pos.vault.rented)}
            `;
    			})
    			.filter(Boolean)
    			.join("\n\n");
    
    		return `📊 *Your Active BAMM Positions*\n\n${formattedPositions}`;
    	}
    }
  • src/index.ts:21-25 (registration)
    Registration of the GET_POSITIONS tool on the FastMCP server via server.addTool(getPositionsTool).
    server.addTool(getPositionsTool);
    server.addTool(lendTool);
    server.addTool(poolStatsTool);
    server.addTool(removeCollateralTool);
    server.addTool(repayTool);
Behavior2/5

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

No annotations provided and description does not disclose behavioral traits such as data freshness, permissions, or side effects; agent has no additional behavioral context.

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

Conciseness5/5

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

Single sentence with no waste; efficiently conveys purpose without extraneous information.

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

Completeness3/5

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

Minimal description covers basic function but lacks definition of 'BAMM', output details, and relation to siblings; adequate for such a simple tool but could be improved.

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?

Zero parameters mean schema coverage is complete; baseline score of 4 as per rules, though description does not elaborate on 'active BAMM positions'.

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

Purpose4/5

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

Description clearly states retrieval of user's active BAMM positions with specific verb and scope, implicitly distinguishing from mutation siblings but not from POOL_STATS.

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 guidance on when to use this tool versus alternatives like POOL_STATS or when not to use; agent must infer from name alone.

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

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/IQAIcom/mcp-bamm'

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