Skip to main content
Glama

LEND

Deposit Fraxswap LP tokens into a BAMM contract to earn interest and unlock borrowing power.

Instructions

Lend Fraxswap LP tokens to a BAMM contract

Input Schema

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

Implementation Reference

  • The 'LEND' tool definition with the execute function that creates a WalletService and LendService, calls lendService.execute(), and returns a formatted success/error message. This is the primary handler invoked when the LEND tool is called.
    export const lendTool: Tool<FastMCPSessionAuth, typeof lendToolParams> = {
    	name: "LEND",
    	description: "Lend Fraxswap LP tokens to a BAMM contract",
    	parameters: lendToolParams,
    	execute: async (params, _context) => {
    		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";
    		}
    	},
    };
  • The LendService.execute() method that performs the actual on-chain logic: reads LP token address from BAMM via pair(), checks balance, ensures token approval, then calls bamm.mint() to deposit LP tokens into the BAMM contract.
    	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;
    		}
    	}
    }
  • Zod schema for the LEND tool params: bammAddress (Ethereum address regex) and amount (string). Defines input validation for the tool.
    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"),
    });
  • src/index.ts:22-22 (registration)
    Registration of the lendTool on the FastMCP server via server.addTool(lendTool).
    server.addTool(lendTool);
  • The LEND_TEMPLATE, a prompt template derived from SIMPLE_AMOUNT_TEMPLATE, used for AI to extract lending parameters (bammAddress, amount) from natural language.
    export const LEND_TEMPLATE = SIMPLE_AMOUNT_TEMPLATE.replace(
    	/{{operation}}/g,
    	"lending",
    );
Behavior2/5

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

With no annotations, the description must convey behavioral traits. It only states the action but omits critical details like required approvals, side effects (e.g., token transfer), reversibility, or success/failure conditions.

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?

A single, front-loaded sentence with no redundant words. Every piece of information earns its place.

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?

For a financial lending action, the description is too brief. It lacks details about LP token type, approval steps, response behavior, and potential risks. Given no output schema, more context is needed.

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 baseline is 3. The description adds no extra meaning beyond the schema descriptions, which already define bammAddress and amount adequately.

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

Purpose5/5

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

The description clearly states the action (Lend), the resource (Fraxswap LP tokens), and the target (BAMM contract), making it distinct from sibling tools like BORROW or ADD_COLLATERAL.

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 is provided on when to use this tool versus alternatives, nor any prerequisites or exclusions. This leaves the agent without context for tool selection.

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