Skip to main content
Glama

POOL_STATS

Retrieve detailed statistics for all BAMM pools on the Fraxtal blockchain to monitor liquidity, borrowing activity, and other key metrics.

Instructions

Get statistics for all BAMM pools

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The POOL_STATS tool handler implementation. It initializes WalletService and BammPoolsStatsService, fetches pool stats, formats them, and returns the result or an error message.
    export const poolStatsTool = {
    	name: "POOL_STATS",
    	description: "Get statistics for all BAMM pools",
    	// 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 poolStatsService = new BammPoolsStatsService(walletService);
    
    			const pools = await poolStatsService.getPoolsStats();
    			const formattedStats = poolStatsService.formatPoolsStats(pools);
    
    			return formattedStats;
    		} catch (error) {
    			if (error instanceof Error) {
    				return `❌ Failed to retrieve pool statistics: ${error.message}`;
    			}
    			return "❌ An unknown error occurred while retrieving pool statistics";
    		}
    	},
    };
  • src/index.ts:23-23 (registration)
    Registration of the poolStatsTool (POOL_STATS) with the FastMCP server.
    server.addTool(poolStatsTool);
  • Core logic in BammPoolsStatsService.getPoolsStats(): Fetches BAMM addresses from blockchain, maps to Fraxswap pools via API, filters and sorts by TVL.
    async getPoolsStats(): Promise<PoolStats[]> {
    	const publicClient = this.walletService.getPublicClient();
    	const zeroAddress = "0x0000000000000000000000000000000000000000";
    
    	// 1. Get the list of all BAMM addresses from the factory.
    	const bammsOnChain: readonly Address[] = await publicClient.readContract({
    		address: BAMM_ADDRESSES.FACTORY,
    		abi: BAMM_FACTORY_ABI,
    		functionName: "bammsArray",
    		args: [],
    	});
    
    	// 2. Build a mapping: underlying Fraxswap pair address -> BAMM address.
    	const pairToBammMap = new Map<string, string>();
    	for (const bammAddress of bammsOnChain) {
    		if (bammAddress === zeroAddress) continue;
    		// Get the Fraxswap pair address from this BAMM contract.
    		const pairAddress: Address = await publicClient.readContract({
    			address: bammAddress,
    			abi: BAMM_ABI,
    			functionName: "pair",
    			args: [],
    		});
    		if (pairAddress && pairAddress !== zeroAddress) {
    			pairToBammMap.set(pairAddress.toLowerCase(), bammAddress);
    		}
    	}
    
    	// 3. Fetch the full list of pools from the Frax API endpoint.
    	const response = await fetch(this.endpoint);
    	if (!response.ok) {
    		throw new Error(`Failed to fetch pools: ${response.statusText}`);
    	}
    	const data = await response.json();
    
    	// Map the API response to our PoolStats type and add placeholder fields.
    	// biome-ignore lint/suspicious/noExplicitAny: <explanation>
    	const allPools: PoolStats[] = data.pools.map((pool: any) => ({
    		...pool,
    		bammAddress: "",
    		bammApr: 0,
    		fraxswapApr: 0,
    	}));
    
    	// 4. Filter the API pools to only include those with a matching pair address.
    	const filteredPools: PoolStats[] = [];
    	for (const pool of allPools) {
    		const poolPair = pool.poolAddress.toLowerCase();
    		if (pairToBammMap.has(poolPair)) {
    			// Set the BAMM address from our mapping.
    			pool.bammAddress = pairToBammMap.get(poolPair) ?? "";
    			filteredPools.push(pool);
    		}
    	}
    
    	filteredPools.sort((a, b) => b.tvl - a.tvl);
    
    	return filteredPools;
    }
  • BammPoolsStatsService.formatPoolsStats(): Formats the pool statistics into a readable string with details for each pool.
    	formatPoolsStats(pools: PoolStats[]): string {
    		if (pools.length === 0) {
    			return "📊 No BAMM Pools Found";
    		}
    
    		const formattedStats = pools
    			.map((pool) => {
    				const poolName = `${pool.token0Symbol}/${pool.token1Symbol}`;
    				return dedent`
              📊 Pool: ${poolName}
              - Pool Address: ${pool.poolAddress}
              - BAMM Address: ${pool.bammAddress}
              - TVL: $${formatNumber(pool.tvl || 0)}
              - ${pool.token0Symbol} Locked: ${formatNumber(
    						pool.token0AmountLocked || 0,
    					)}
              - ${pool.token1Symbol} Locked: ${formatNumber(
    						pool.token1AmountLocked || 0,
    					)}
            `;
    			})
    			.join("\n\n");
    
    		return dedent`
          📊 *BAMM Pool Stats:*
          Total: ${pools.length}
    
          ${formattedStats}
        `;
    	}
    }
  • Type definition for PoolStats used in the service and returned by getPoolsStats().
    export interface PoolStats {
    	poolAddress: string;
    	bammAddress: string;
    	createdAtTimestamp: string;
    	token0Symbol: string;
    	token0AmountLocked: number;
    	token1Symbol: string;
    	token1AmountLocked: number;
    	tvl: number;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'Get statistics,' implying a read-only operation, but doesn't clarify if it's safe, requires authentication, has rate limits, or what the return format might be. This leaves significant gaps in understanding the tool's behavior.

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, clear sentence with no wasted words, making it highly concise and easy to parse. It front-loads the core purpose effectively, earning full marks for efficiency.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'statistics' include, the return format, or any behavioral traits like safety or performance. For a tool in a financial context (BAMM pools), more context is needed to ensure proper use.

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 here, but it could have mentioned if any implicit parameters (like context or filters) are involved, though not strictly required.

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 tool's purpose with a specific verb ('Get') and resource ('statistics for all BAMM pools'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like GET_POSITIONS, which might also retrieve pool-related data, leaving room for potential ambiguity.

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. It doesn't mention prerequisites, timing, or how it differs from siblings like GET_POSITIONS, leaving the agent to infer usage context without explicit 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