Skip to main content
Glama

平仓

build_close_position
Read-only

Builds a market-close transaction for USDC- or meme-coin-margined positions, defaulting to full close; set sizeUsd to partially close and reclaim margin proportionally.

Instructions

生成市价平仓交易(兼容 USDC 本位与 Meme 币本位),默认全平;传 sizeUsd 可部分平仓(按比例取回保证金)。

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "account": "<account>",
      "market": "<market>",
      "side": "<side>",
      "slippagePct": "<slippagePct>"
    },
    "name": "build_close_position"
  }
}

Input Schema

NameRequiredDescriptionDefault
sideYeslong 做多,short 做空
agentNoagent 专用通道:填 agent 自己的钱包地址后,交易由 agent 用自己的私钥直接签名发送,不用用户逐笔确认(用户需先用 build_agent_authorize 授权这个地址)。不填则由用户钱包签名
marketYes市场:短链接 slug、市场合约地址、代币地址、代币代号,或标的代号如 BTC / ETH / XAU(表示该标的的官方市场)
accountYes用户钱包地址(交易的签名人和收款人)
sizeUsdNo要平掉的仓位规模(美元名义);不填为全平
slippagePctYes滑点百分数,默认 0.3(即 0.3%)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, so the safety profile is covered. The description adds real behavior beyond that: it is a market order (not limit), it works across both USDC- and Meme-margined accounts, and a partial close returns margin proportionally. It does not say whether the built transaction is returned unsigned or dispatched, which matters given the agent-signing path described in the schema.

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 sentence, front-loaded with the action and order type, then the margin-system compatibility, then the default/override behavior. Every clause carries information an agent needs and nothing is repeated from the schema verbatim.

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?

With no output schema and six parameters, the description should say something about what is produced (an unsigned transaction object? calldata? what the agent does with it) and note that a position must already exist. It covers the sizing behavior well but leaves the return contract and preconditions unstated.

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?

Schema description coverage is 100%, so the baseline is 3. The description still adds meaning not in the schema: that sizeUsd drives a proportional margin return rather than an arbitrary quantity, and that the default (unset) is a full close. It says nothing about side or slippagePct semantics, so it stays just above baseline.

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 pairs a generic verb (生成) with a highly specific resource (市价平仓交易), and further narrows scope by naming the two margin systems (USDC 本位与 Meme 币本位). An agent can distinguish it from build_open_position or build_add_margin by the 平仓 framing alone. It stops short of 5 because it never explicitly contrasts itself with those siblings.

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?

It gives one useful usage rule: default is full close, pass sizeUsd for partial close. But it offers no when-to-use guidance versus alternatives (e.g., setting TP/SL to exit, or adding margin to avoid closing), and no prerequisites such as needing an existing position or choosing the correct side. Usage is implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.