Skip to main content
Glama
lordbasilaiassistant-sudo

base-multi-wallet-mcp

coordinated_sell

Execute synchronized token sales across multiple managed wallets on Base using Uniswap V2. Specify token address, percentage to sell, and slippage tolerance for coordinated portfolio management.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address to sell
percent_to_sellNoPercentage of token balance to sell per wallet (default 100)
slippage_percentNoSlippage tolerance percentage (default 5)

Implementation Reference

  • The handler function for the 'coordinated_sell' tool, which iterates over managed wallets to sell tokens on Uniswap V2.
    async function handleCoordinatedSell(
      args: z.infer<typeof CoordinatedSellSchema>
    ): Promise<string> {
      if (wallets.length === 0) {
        return JSON.stringify({
          success: false,
          error: "No managed wallets. Create or import wallets first.",
        });
      }
    
      const provider = getProvider();
      const deadline = Math.floor(Date.now() / 1000) + 1200;
      const path = [args.token_address, WETH];
    
      const sellPromises = wallets.map(async (w) => {
        const signer = getSignerForWallet(w);
    
        try {
          const tokenBalance = await getTokenBalance(
            provider,
            args.token_address,
            w.address
          );
    
          if (tokenBalance === 0n) {
            throw new Error("No token balance to sell");
          }
    
          const sellAmount =
            args.percent_to_sell >= 100
              ? tokenBalance
              : (tokenBalance * BigInt(args.percent_to_sell)) / 100n;
    
          if (sellAmount === 0n) {
            throw new Error("Sell amount rounds to zero");
          }
    
          // Check and set approval
          const token = new ethers.Contract(args.token_address, ERC20_ABI, signer);
          const allowance: bigint = await token.allowance(w.address, UNISWAP_V2_ROUTER);
    
          if (allowance < sellAmount) {
            const approveTx = await token.approve(
              UNISWAP_V2_ROUTER,
              ethers.MaxUint256,
              { gasLimit: 100_000n }
            );
            await approveTx.wait();
          }
    
          // Get quote
          const router = new ethers.Contract(UNISWAP_V2_ROUTER, ROUTER_ABI, provider);
          const amounts = await router.getAmountsOut(sellAmount, path);
          const expectedEth: bigint = amounts[1];
    
          const slippageBps = BigInt(Math.floor(args.slippage_percent * 100));
          const minOut = expectedEth - (expectedEth * slippageBps) / 10000n;
    
          // Execute sell
          const routerSigner = new ethers.Contract(
            UNISWAP_V2_ROUTER,
            ROUTER_ABI,
            signer
          );
          const tx = await routerSigner.swapExactTokensForETH(
            sellAmount,
            minOut,
            path,
            w.address,
            deadline,
            { gasLimit: 300_000n }
          );
    
          const receipt = await tx.wait();
    
          return {
            address: w.address,
            label: w.label,
            tokens_sold: sellAmount.toString(),
            expected_eth: formatEth(expectedEth),
            txHash: tx.hash,
            success: receipt !== null && receipt.status === 1,
          };
        } catch (err: unknown) {
          return {
            address: w.address,
            label: w.label,
            tokens_sold: "0",
            expected_eth: "0",
            txHash: "",
            success: false,
            error: err instanceof Error ? err.message : String(err),
          };
        }
      });
    
      const results = await Promise.allSettled(sellPromises);
      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;
    
      return JSON.stringify(
        {
          success: succeeded > 0,
          token: args.token_address,
          sold: succeeded,
          failed: outcomes.length - succeeded,
          percent_sold: args.percent_to_sell + "%",
          slippage: args.slippage_percent + "%",
          results: outcomes,
        },
        null,
        2
      );
    }
  • Zod schema defining the input arguments for 'coordinated_sell'.
    const CoordinatedSellSchema = z.object({
      token_address: z.string().describe("Token contract address to sell"),
      percent_to_sell: z
        .number()
        .default(100)
        .describe("Percentage of token balance to sell per wallet (default 100)"),
      slippage_percent: z
        .number()
        .default(5)
        .describe("Slippage tolerance percentage (default 5)"),
    });
  • src/index.ts:849-873 (registration)
    Registration of 'coordinated_sell' in the tool list provided by the MCP server.
      name: "coordinated_sell",
      description:
        "Sell a token from all managed wallets via Uniswap V2 on Base.",
      inputSchema: {
        type: "object" as const,
        properties: {
          token_address: {
            type: "string",
            description: "Token contract address to sell",
          },
          percent_to_sell: {
            type: "number",
            description:
              "Percentage of token balance to sell per wallet (default 100)",
            default: 100,
          },
          slippage_percent: {
            type: "number",
            description: "Slippage tolerance percentage (default 5)",
            default: 5,
          },
        },
        required: ["token_address"],
      },
    },
Behavior3/5

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

With no annotations provided, the description carries the full burden. It successfully discloses the venue (Uniswap V2) and chain (Base), which are critical behavioral constraints. However, it omits key operational details for a financial mutation tool: transaction irreversibility, gas cost implications, failure handling across multiple wallets, and return value format.

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, dense sentence of 11 words with zero redundancy. Every element earns its place: the action (Sell), subject (token), scope (all managed wallets), protocol (Uniswap V2), and network (Base) are all front-loaded and essential for tool selection.

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?

For a DeFi coordination tool with no output schema or annotations, the description provides sufficient context for basic selection but lacks operational completeness. It omits return value documentation, error handling behavior for partial failures across wallets, and prerequisites like gas token (ETH) requirements on Base.

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?

The schema has 100% description coverage, establishing a baseline of 3. The description mentions 'Sell a token' (aligning with token_address) and implies the 'all managed wallets' scope, but adds no additional syntax guidance, format examples, or semantic constraints beyond what the schema already provides for percent_to_sell or slippage_percent.

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 ('Sell'), resource ('token'), and precise scope ('from all managed wallets via Uniswap V2 on Base'). It clearly distinguishes from siblings like 'coordinated_buy' (sell vs buy) and 'collect_funds' (DEX selling vs fund collection) by specifying the venue and chain.

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?

The description implies usage through the 'Sell' action and 'all managed wallets' scope, distinguishing it from buying or single-wallet operations. However, it lacks explicit guidance on when to use this versus 'collect_funds' for consolidation, or warnings about gas requirements and market timing.

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