Skip to main content
Glama

prepare_marginfi_withdraw

DestructiveIdempotent

Withdraw tokens from a MarginFi supply position. Pre-flights the withdrawal to maintain a healthy collateralization ratio and prevent failed transactions.

Instructions

Build an unsigned MarginFi WITHDRAW tx. Withdraws the specified amount (or ALL, via withdrawAll: true) from the user's supplied position in the named bank. Pre-flight refuses if the account has zero free collateral (the withdraw would push the health factor below the maintenance threshold — the on-chain tx would revert). DURABLE NONCE + prepare_marginfi_init prerequisites identical to prepare_marginfi_supply. BLIND-SIGN on Ledger.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletYesBase58 Solana mainnet address (ed25519 pubkey, 43 or 44 chars).
symbolNoCanonical token symbol (USDC, SOL, USDT, JUP, BONK, JTO, mSOL, jitoSOL). The builder resolves this to the underlying mint; MarginFi treats SOL as wSOL internally with auto-wrap/unwrap. Pass `mint` instead if your token isn't in the canonical list.
mintNoBase58 SPL mint address. Used as an override or when the token isn't in the canonical SOLANA_TOKENS table. Exactly one of `symbol` or `mint` must be passed.
accountIndexNoMarginfiAccount slot (0 = first, 1 = second, ...). Most users stay on 0. Use a different index to segregate positions across multiple MarginfiAccounts owned by the same wallet.
amountYesHuman-readable decimal amount to withdraw. Pre-flight refuses if the withdraw would push the health factor below the maintenance threshold.
withdrawAllNoSet true to close the entire supplied position in this bank (lets the SDK pass the `withdraw_all` on-chain flag so the bank clears the balance slot). Omit for partial.
Behavior4/5

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

Annotations indicate destructiveHint=true and readOnlyHint=false, so mutation is expected. The description adds value by disclosing pre-flight refusal behavior, the condition for withdrawal (positive free collateral), and the blind-sign requirement on Ledger. No contradictions with annotations.

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?

Three concise sentences covering purpose, pre-flight behavior, prerequisites, and blind-sign. Every sentence adds value, front-loaded with the core action.

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?

Given no output schema, the description adequately covers all needed context: what the tool does, failure conditions, prerequisites, special parameter behavior (withdrawAll, blind-sign). Sufficient for an agent to select and invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% but the description adds meaningful context: 'withdrawAll' closes the position, 'amount' is human-readable and pre-flight checked, accountIndex allows segregation, symbol/mint resolution with auto-wrap for SOL. These details surpass schema descriptions.

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?

Clearly states it builds an unsigned MarginFi WITHDRAW transaction, specifying the action (withdraw from supplied position in a named bank) and differentiating from siblings like prepare_marginfi_supply or prepare_marginfi_borrow via explicit 'WITHDRAW' label and details about withdrawAll.

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?

Explicitly describes when to use (anytime a withdraw is needed) and when not to (pre-flight refusal if health factor too low, which would cause reversion). References prerequisites (durable nonce + init) and aligns with sibling tools like prepare_marginfi_supply, providing clear context for selection.

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/szhygulin/recon-crypto-mcp'

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