Skip to main content
Glama
lordbasilaiassistant-sudo

base-multi-wallet-mcp

coordinated_buy

Execute simultaneous token purchases across multiple managed wallets using Uniswap V2 on Base blockchain. Specify token address, ETH amount per wallet, and optional slippage tolerance.

Instructions

Buy a token from all managed wallets simultaneously via Uniswap V2 on Base.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address to buy
eth_per_walletYesETH each wallet spends on the buy (e.g. '0.001')
slippage_percentNoSlippage tolerance percentage (default 5)

Implementation Reference

  • The `handleCoordinatedBuy` function performs the swap logic for all managed wallets using Uniswap V2. It calculates expected output based on slippage, performs balance checks, and executes the swap transactions in parallel.
    async function handleCoordinatedBuy(
      args: z.infer<typeof CoordinatedBuySchema>
    ): Promise<string> {
      if (wallets.length === 0) {
        return JSON.stringify({
          success: false,
          error: "No managed wallets. Create or import wallets first.",
        });
      }
    
      const provider = getProvider();
      const ethPerWallet = ethers.parseEther(args.eth_per_wallet);
      const deadline = Math.floor(Date.now() / 1000) + 1200; // 20 min
      const path = [WETH, args.token_address];
    
      // Get quote for slippage calc
      const router = new ethers.Contract(UNISWAP_V2_ROUTER, ROUTER_ABI, provider);
    
      let expectedOut: bigint;
      try {
        const amounts = await router.getAmountsOut(ethPerWallet, path);
        expectedOut = amounts[1];
      } catch {
        return JSON.stringify({
          success: false,
          error:
            "Failed to get quote. Token may not have a V2 liquidity pool on Base.",
        });
      }
    
      const slippageBps = BigInt(Math.floor(args.slippage_percent * 100));
      const minOut = expectedOut - (expectedOut * slippageBps) / 10000n;
    
      // Execute buys from all wallets in parallel
      const buyPromises = wallets.map(async (w) => {
        const signer = getSignerForWallet(w);
    
        try {
          const balance = await provider.getBalance(w.address);
          if (balance < ethPerWallet) {
            throw new Error(
              `Insufficient ETH: has ${formatEth(balance)}, needs ${formatEth(ethPerWallet)}`
            );
          }
    
          const routerContract = new ethers.Contract(
            UNISWAP_V2_ROUTER,
            ROUTER_ABI,
            signer
          );
    
          const tx = await routerContract.swapExactETHForTokens(
            minOut,
            path,
            w.address,
            deadline,
            { value: ethPerWallet, gasLimit: 300_000n }
          );
    
          const receipt = await tx.wait();
    
          return {
            address: w.address,
            label: w.label,
            eth_spent: formatEth(ethPerWallet),
            txHash: tx.hash,
            success: receipt !== null && receipt.status === 1,
          };
        } catch (err: unknown) {
          return {
            address: w.address,
            label: w.label,
            eth_spent: "0",
            txHash: "",
            success: false,
            error: err instanceof Error ? err.message : String(err),
          };
        }
      });
    
      const results = await Promise.allSettled(buyPromises);
      const outcomes = results.map((r) =>
        r.status === "fulfilled"
          ? r.value
          : { address: "unknown", label: "", success: false, error: "Promise rejected" }
      );
    
      const succeeded = outcomes.filter((o) => o.success).length;
  • The `CoordinatedBuySchema` defines the input parameters for the coordinated_buy tool, including token address, ETH amount per wallet, and slippage tolerance.
    const CoordinatedBuySchema = z.object({
      token_address: z.string().describe("Token contract address to buy"),
      eth_per_wallet: z
        .string()
        .describe("ETH each wallet spends on the buy (e.g. '0.001')"),
      slippage_percent: z
        .number()
        .default(5)
        .describe("Slippage tolerance percentage (default 5)"),
    });
  • src/index.ts:824-843 (registration)
    The tool `coordinated_buy` is registered with a description and its input schema in the server's tool definition list.
    {
      name: "coordinated_buy",
      description:
        "Buy a token from all managed wallets simultaneously via Uniswap V2 on Base.",
      inputSchema: {
        type: "object" as const,
        properties: {
          token_address: {
            type: "string",
            description: "Token contract address to buy",
          },
          eth_per_wallet: {
            type: "string",
            description: "ETH each wallet spends on the buy (e.g. '0.001')",
          },
          slippage_percent: {
            type: "number",
            description: "Slippage tolerance percentage (default 5)",
            default: 5,
          },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'Buy' and parameter descriptions note ETH spending, but fails to disclose critical traits: that this is a destructive/spending operation, transaction failure handling across multiple wallets, or that it executes blockchain writes. Missing safety context for a financial tool.

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 zero waste. Front-loaded with action ('Buy'), immediately followed by scope ('all managed wallets'), method ('simultaneously via Uniswap V2'), and network ('on Base'). Every word earns its place.

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 100% schema coverage, the description adequately covers the 'what' and 'where', but lacks important contextual details expected for a multi-wallet financial transaction tool without output schema or annotations: return value format, transaction confirmation details, or side effects (e.g., gas costs deducted from wallets).

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 coverage is 100%, establishing a baseline of 3. The description adds platform context ('via Uniswap V2 on Base') which implicitly constrains token_address to Base-compatible contracts and slippage_percent to DEX mechanics, but does not explicitly elaborate on parameter formats beyond the schema definitions.

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 provides a specific verb ('Buy'), resource ('token'), and clear differentiators including 'all managed wallets simultaneously', 'Uniswap V2', and 'on Base'. It clearly distinguishes from siblings like coordinated_sell, create_wallet, and fund_wallets through its explicit action and scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

While the description implies usage through naming ('Buy' vs coordinated_sell) and mentions the execution context (Uniswap V2 on Base), it lacks explicit guidance on prerequisites (e.g., requiring funded wallets first) or when to choose this over alternatives like fund_wallets or coordinated_sell.

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/lordbasilaiassistant-sudo/base-multi-wallet-mcp'

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