Skip to main content
Glama

write_account_close

Idempotent

Atomic flash-action that closes an Arcadia account position in ONE transaction. Combines up to 3 steps atomically: [burn LP position] + [swap all tokens to a single target asset] + [repay debt]. Tokens remain in the account after closing: use write_account_withdraw to send them to your wallet.

ALWAYS try this tool first when closing/exiting a position. Only fall back to individual tools (write_account_remove_liquidity, write_account_swap, write_account_deleverage, write_account_withdraw) if this tool fails.

Supports two modes:

  • close_lp_only=true: Burns LP and leaves underlying tokens in the account. Use as step 1 if the full close fails, then call again with close_lp_only=false to swap+repay the remaining tokens.

  • close_lp_only=false (default): Full atomic close: burns LP, swaps everything to receive_assets, repays debt. Remaining tokens stay in the account. Follow up with write_account_withdraw to send to wallet. Supports multiple receive assets with custom distribution.

The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up). Response includes tenderly_sim_url and tenderly_sim_status for pre-broadcast validation.

Input Schema

NameRequiredDescriptionDefault
assetsYesAssets to close/sell from the account. IMPORTANT: For LP positions (NFTs), always use amount='1' and decimals=1: do NOT pass the liquidity amount. asset_address = position manager, asset_id = NFT token ID. For ERC20 tokens: asset_id = 0, amount = full balance in raw units, decimals = real token decimals. Get all values from read_account_info.
chain_idNoChain ID: 8453 (Base), 130 (Unichain), 10 (Optimism), or 4663 (Robinhood)
slippageNoBasis points, 100 = 1%
close_lp_onlyNotrue = only burn LP positions, leave underlying tokens in account. false = full close (burn + swap + repay).
receive_assetsNoTarget assets to receive after closing. For a single target, pass one entry. Required when close_lp_only=false. Omit for close_lp_only=true.
account_addressYesArcadia account address

Output Schema

NameRequiredDescriptionDefault
afterNo
beforeNo
descriptionNo
transactionYes
price_checksNo
tenderly_sim_urlNo
tenderly_sim_statusNo
expected_value_changeNo
expected_value_change_unavailableNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedOutput schema / properties / expected_value_change_unavailable
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / price_checks
      Added value: +{
      +  "items": {
      +    "additionalProperties": {},
      +    "properties": {
      +      "pool": {
      +        "type": "string"
      +      },
      +      "status": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "pool",
      +      "status"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
  2. Changed8 schema fields changed
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • removedInput schema / additionalProperties
      Removed value: -false
    • changedInput schema / properties / assets / description
      Previous value: -"Assets to close/sell from the account. IMPORTANT: For LP positions (NFTs), always use amount='1' and decimals=1 — do NOT pass the liquidity amount. asset_address = position manager, asset_id = NFT token ID. For ERC20 tokens: asset_id = 0, amount = full balance in raw units, decimals = real token decimals. Get all values from read.account.info."New value: +"Assets to close/sell from the account. IMPORTANT: For LP positions (NFTs), always use amount='1' and decimals=1: do NOT pass the liquidity amount. asset_address = position manager, asset_id = NFT token ID. For ERC20 tokens: asset_id = 0, amount = full balance in raw units, decimals = real token decimals. Get all values from read_account_info."
    • removedInput schema / properties / assets / items / additionalProperties
      Removed value: -false
    • removedInput schema / properties / receive_assets / items / additionalProperties
      Removed value: -false
    • changedOutput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • changedOutput schema / properties / after / additionalProperties
      Previous value: -trueNew value: +{}
    • changedOutput schema / properties / before / additionalProperties
      Previous value: -trueNew value: +{}
  3. Changed1 schema field changed
    • changedInput schema / properties / chain_id / description
      Previous value: -"Chain ID: 8453 (Base), 130 (Unichain), or 10 (Optimism)"New value: +"Chain ID: 8453 (Base), 130 (Unichain), 10 (Optimism), or 4663 (Robinhood)"
  4. Changed1 schema field changed
    • changedOutput schema / properties / tenderly_sim_status / enum
      Previous value: -[
      -  "true",
      -  "false",
      -  "unavailable"
      -]New value: +[
      +  "success",
      +  "failure",
      +  "unavailable"
      +]
  5. Changed1 schema field changed
    • changedInput schema / properties / chain_id / description
      Previous value: -"Chain ID: 8453 (Base) or 130 (Unichain)"New value: +"Chain ID: 8453 (Base), 130 (Unichain), or 10 (Optimism)"
  6. Added

TDQS

A4.8/5.0
Behavior5/5

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

Goes well beyond the annotations: tokens remain in the account after closing, calldata is time-sensitive (30s signing window), retry-at-least-once guidance on price-movement reverts, and pre-broadcast validation via tenderly_sim_url/tenderly_sim_status. Annotations only cover readOnly/openWorld/idempotent flags, so this text supplies the substantive behavioral context.

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

Conciseness4/5

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

Front-loaded with the atomic-close claim, then the priority rule, then modes, then timing caveats — a sensible ordering. Slightly verbose with some restatement between the mode bullets and the fallback paragraph, but nearly every sentence carries an operational fact.

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

Completeness5/5

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

For a 6-parameter mutation tool with an output schema, it covers the decision path, mode semantics, post-close state, timing constraints, and retry behavior. Nothing an agent needs to invoke and follow up correctly is missing.

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 100%, so the baseline is 3; the description still adds meaning by framing close_lp_only as a fallback strategy and by noting multiple receive assets with custom distribution. It doesn't add format details for assets/chain_id/slippage beyond the schema.

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?

States a specific verb and resource ("Atomic flash-action that closes an Arcadia account position in ONE transaction") and enumerates the three bundled steps. It is unmistakably distinct from siblings like write_account_remove_liquidity or write_account_swap, which it names.

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

Usage Guidelines5/5

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

Explicit routing: "ALWAYS try this tool first when closing/exiting a position", with a named fallback list and the failure condition that triggers it. It also explains the two-mode workflow (close_lp_only true as step 1 then false) and the follow-up write_account_withdraw.

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.