Skip to main content
Glama

close_perp_position

Destructive

Close a perp position (full/partial) on its venue (non-custodial).

position_id is venue-native (for Drift it is the market symbol). close_pct in (0, 100]. Returns an UNSIGNED tx / signing payload to sign + broadcast.

jurisdiction: closes are geo-gated too -- see place_perp_order.

idempotency_key (optional): a client-generated UUID. Retrying with the same key + same args replays the original result instead of re-closing the position. Reuse the SAME key across the build call and its signed_transaction completion call -- see place_perp_order; the two legs dedupe independently, so this never raises IDEMPOTENCY_CONFLICT.

signed_transaction / verify (two-phase execution): see place_perp_order -- re-call with the signed payload and Crank relays it by custody tier and verifies the result.

venue_action (optional, completion leg only): see place_perp_order -- pass back the build leg's extra['venue_action'] (e.g. Jupiter's decrease-position) so the relay route is the venue's own declared one instead of one inferred from the signed bytes.

simulate (optional): true = rehearse this call. The full gate stack (capability, kill switch, session signer, wallet policy, permission mode, soft launch, venue / compliance / token checks, fee quote) is evaluated read-only and returned as verdicts + would_execute, with a paper fill where one applies. Nothing is built, signed, broadcast or charged. Omitted = your wallet's default_simulate setting; false = execute.

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": {
      "wallet_address": "<wallet_address>",
      "position_id": "<position_id>"
    },
    "name": "close_perp_position"
  }
}

Input Schema

NameRequiredDescriptionDefault
ipNo
venueNo
verifyNo
simulateNo
caller_idNo
close_pctNo
position_idYes
jurisdictionNo
pay_in_crankNo
venue_actionNo
payment_headerNo
wallet_addressYes
idempotency_keyNo
acknowledge_tier_bNo
signed_transactionNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / simulate
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
  2. Changed1 schema field changed
    • addedInput schema / properties / venue_action
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
  3. Changed2 schema fields changed
    • addedInput schema / properties / ip
      Added value: +{
      +  "default": "",
      +  "type": "string"
      +}
    • addedInput schema / properties / jurisdiction
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
  4. Changed2 schema fields changed
    • addedInput schema / properties / signed_transaction
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • addedInput schema / properties / verify
      Added value: +{
      +  "default": true,
      +  "type": "boolean"
      +}
  5. First observed

TDQS

A3.9/5.0
Behavior5/5

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

Annotations already flag it as destructive/openWorld, and the description adds substantial context beyond them: it returns an UNSIGNED tx to sign+broadcast, closes are geo-gated, the idempotency_key replay semantics, the two-phase signed_transaction/verify flow, and that simulate runs the full gate stack read-only with no build/sign/broadcast/charge. This is rich behavioral disclosure an agent needs for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose is front-loaded and parameter names are marked, but the text repeatedly defers to 'see place_perp_order' (four times), forcing the agent to consult another tool's definition to understand this one. For a tool of this complexity some length is justified, yet the cross-references reduce standalone readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need not be explained, and the description covers the two-phase execution, signing, simulation, and gating model adequately. The remaining gap is the handful of undocumented parameters and the reliance on place_perp_order for shared semantics.

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 coverage is 0% and there are 15 parameters, so the description must carry the burden. It explains the tricky ones well (position_id is venue-native/market symbol for Drift, close_pct in (0,100], idempotency_key semantics, venue_action relay, simulate, jurisdiction). It leaves roughly seven params (ip, venue, caller_id, pay_in_crank, payment_header, acknowledge_tier_b) undocumented, so it compensates well but not completely.

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?

States a specific verb and resource ('Close a perp position (full/partial) on its venue') and adds the non-custodial qualifier, so the core action is unambiguous. However, it does not differentiate itself from near-identical siblings such as perp_close, leverage_close, or short_close, leaving the agent to infer which close path applies.

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 gives usage conditions for several parameters (close_pct range, idempotency_key replay, simulate behavior, geo-gated closes), which implies when to use those options. But it never states when to choose this tool over sibling close tools, nor any prerequisites beyond 'see place_perp_order'.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources