Skip to main content
Glama

LEND

Deposit Fraxswap LP tokens into a BAMM contract to enable borrowing and liquidity management on the Fraxtal blockchain.

Instructions

Lend Fraxswap LP tokens to a BAMM contract

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesThe amount of LP tokens to lend
bammAddressYesThe address of the BAMM contract

Implementation Reference

  • The main handler for the 'LEND' tool, defining the tool name, description, parameters schema, and the execute function that orchestrates wallet setup and calls the LendService.
    export const lendTool: Tool<undefined, typeof lendToolParams> = {
    	name: "LEND",
    	description: "Lend Fraxswap LP tokens to a BAMM contract",
    	parameters: lendToolParams,
    	execute: async (params) => {
    		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 lendService = new LendService(walletService);
    
    			const result = await lendService.execute({
    				bammAddress: params.bammAddress as Address,
    				amount: params.amount,
    			});
    
    			return dedent`
            ✅ Lending Successful
    
            🌐 BAMM Address: ${params.bammAddress}
            💰 Amount: ${formatNumber(Number(params.amount))} LP tokens
            🔗 Transaction: ${result.txHash}
    
            LP tokens have been deposited to the BAMM contract.
          `;
    		} catch (error) {
    			if (error instanceof Error) {
    				return dedent`
              ❌ Lending Failed
    
              Error: ${error.message}
    
              Please verify your inputs and try again.
            `;
    			}
    			return "An unknown error occurred while lending LP tokens";
    		}
    	},
    };
  • Zod schema definition for the LEND tool parameters (bammAddress and amount), including TypeScript type export.
    const lendToolParams = z.object({
    	bammAddress: z
    		.string()
    		.regex(/^0x[a-fA-F0-9]{40}$/)
    		.describe("The address of the BAMM contract"),
    	amount: z.string().min(1).describe("The amount of LP tokens to lend"),
    });
    
    export type LendToolParams = z.infer<typeof lendToolParams>;
  • src/index.ts:22-22 (registration)
    Registration of the LEND tool on the FastMCP server instance.
    server.addTool(lendTool);
  • The LendService class containing the core logic for lending: reading LP token from BAMM.pair(), balance checks, approvals, and minting BAMM tokens.
    export class LendService {
    	constructor(private walletService: WalletService) {}
    
    	/**
    	 * Lend Fraxswap LP tokens to the BAMM contract.
    	 * Reads the LP token address from bamm.pair(), approves the BAMM to spend them if needed,
    	 * and calls bamm.mint() to deposit.
    	 */
    	async execute(params: LendParams): Promise<{ txHash: string }> {
    		const { bammAddress, amount } = params;
    		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;
    		const lpAmountWei = BigInt(Math.floor(Number(amount) * 1e18));
    		try {
    			// 1. Read the Fraxswap LP token address from the BAMM contract
    			const lpTokenAddress: Address = await publicClient.readContract({
    				address: bammAddress,
    				abi: BAMM_ABI,
    				functionName: "pair",
    				args: [],
    			});
    
    			// 2. Check user's LP token balance
    			await checkTokenBalance(
    				lpTokenAddress,
    				userAddress,
    				lpAmountWei,
    				publicClient,
    			);
    
    			// 3. Approve the BAMM contract to spend LP tokens
    			await ensureTokenApproval(
    				lpTokenAddress,
    				bammAddress,
    				lpAmountWei,
    				publicClient,
    				walletClient,
    			);
    			// 4. Call bamm.mint(to, lpIn) to deposit LP and receive BAMM tokens
    			const { request: mintRequest } = await publicClient.simulateContract({
    				address: bammAddress,
    				abi: BAMM_ABI,
    				functionName: "mint",
    				args: [userAddress, lpAmountWei],
    				account: walletClient.account,
    			});
    			const txHash = await walletClient.writeContract(mintRequest);
    			await publicClient.waitForTransactionReceipt({ hash: txHash });
    
    			return { txHash };
    		} catch (error) {
    			console.error("Error in lend service", error);
    			throw error;
    		}
    	}
    }
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 mentions 'lend' which implies a financial transaction, but fails to detail risks, permissions, rate limits, or what happens upon lending (e.g., interest, lock-up periods). 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, efficient sentence with zero wasted words, clearly stating the tool's action and target. It is appropriately sized and front-loaded, making it easy to grasp immediately.

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 complexity of a financial lending tool with no annotations and no output schema, the description is insufficient. It lacks details on return values, error conditions, or broader context like what Fraxswap or BAMM contracts entail, leaving the agent with incomplete information for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already documents both parameters ('amount' and 'bammAddress') adequately. The description adds no additional meaning or context beyond what the schema provides, such as units for 'amount' or how to find a BAMM address, meeting the baseline for high coverage.

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 ('Lend') and the resource ('Fraxswap LP tokens to a BAMM contract'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like ADD_COLLATERAL or BORROW, which might involve similar assets or contracts, so it falls short of a perfect 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 ADD_COLLATERAL or BORROW, nor does it mention prerequisites, context, or exclusions. It merely states what the tool does without offering usage instructions.

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