Skip to main content
Glama

GET_POSITIONS

Retrieve all active positions from the Borrow Automated Market Maker (BAMM) contracts on the Fraxtal blockchain, enabling users to manage and monitor their borrowing activities efficiently.

Instructions

Get all your active BAMM positions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler for the GET_POSITIONS tool. It initializes the wallet and positions service, fetches positions, formats them, and handles errors.
    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";
    		}
    	},
    };
  • Type definition for BammPosition, used to structure the data returned by getPositions.
    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;
    }
  • src/index.ts:21-21 (registration)
    Registers the getPositionsTool with the FastMCP server.
    server.addTool(getPositionsTool);
  • Fetches all active BAMM positions for the user by querying the BAMM factory, checking user registration in each BAMM, retrieving vault details, and enriching with pool info from Frax API.
    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;
    }
  • Formats the list of BAMM positions into a human-readable string with details like balances and rented amounts.
    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}`;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states what the tool does without disclosing behavioral traits like whether it's read-only, requires authentication, has rate limits, or what format the output takes. It mentions 'active' positions, which adds some context, but overall transparency is limited.

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?

The description is a single, efficient sentence that front-loads the core purpose without any wasted words. It's appropriately sized for a simple tool with no parameters, making it highly concise and well-structured.

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?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is minimally complete but lacks depth. It states what the tool does but doesn't cover behavioral aspects or usage context, making it adequate but with clear gaps for an agent to rely on.

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?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate, earning a baseline score of 4 for adequately handling the lack of parameters.

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?

The description clearly states the action ('Get') and target resource ('all your active BAMM positions'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like POOL_STATS, which might also provide position-related information, so it doesn't reach the highest score.

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?

The description provides no guidance on when to use this tool versus alternatives like POOL_STATS or other siblings. It lacks context about prerequisites, timing, or comparisons, leaving the agent with minimal usage direction.

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

Related 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