q402_yield_withdraw
Withdraw stablecoins from a Q402 Yield lending position back to the Agent Wallet, redeeming USDC or USDT on BNB Chain or Base. Use amount 'max' to redeem the maximum available.
Instructions
WRITE - MOVES FUNDS. Withdraws the Agent Wallet's supplied stablecoin (USDC / USDT) out of its Q402 Yield lending position back to the Agent Wallet. Pass amount="max" to withdraw the maximum currently redeemable (can be < full position under vault caps). Server-managed Agent Wallet path (Mode C): authenticated by the configured live Multichain API key - the server holds the encrypted key, signs the withdraw, and sponsors gas. CHAINS: 'bnb' (USDC or USDT); 'base' (USDC only). The venue is the chain's curated lending market and is reported in the receipt. Other chains are not yet available.
REQUIRES CONFIRMATION - like q402_pay, this tool refuses to execute unless confirm: true is set. Call it FIRST without confirm to get a one-line preview of exactly what will happen (amount, token, chain, wallet); show that to the user, get explicit approval, THEN re-call with confirm:true. Never set confirm:true on the user's behalf without that approval.
SANDBOX BY DEFAULT - like q402_pay, no funds move unless a live Multichain key (q402_live_*) is configured AND Q402_ENABLE_REAL_PAYMENTS=1. Without both, confirm:true returns a sandbox preview (no on-chain withdraw) with a setup hint - confirm:true alone does NOT move real funds.
RETRY SAFETY - on a timeout or an unconfirmed broadcast the tool returns status="uncertain" and echoes back the idempotencyKey it used. The withdrawal MAY have settled, so do NOT blindly call again - that starts a NEW withdrawal and can double-withdraw. To resume the SAME operation, re-call with idempotencyKey set to the echoed value; the server dedupes on it and replays the original result.
Use q402_yield_positions first to see the current position size (especially before an amount="max" withdrawal).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain | No | Chain to withdraw on. 'bnb' (USDC or USDT) or 'base' (USDC only). The actual venue is reported in the receipt. | |
| token | Yes | Stablecoin to withdraw. USDC or USDT on bnb; USDC only on base. | |
| amount | Yes | Human-readable decimal amount to withdraw, e.g. "100.00", or the literal "max" to withdraw the maximum currently redeemable (can be < full position under vault liquidity caps). | |
| confirm | No | MUST be true to actually withdraw funds - set only after the user explicitly approved this exact withdrawal in chat. Omit (or false) to preview without moving funds. | |
| protocol | No | Venue to withdraw from when the wallet holds the same token in more than one lending venue on a chain. Omit when unambiguous; on an "AMBIGUOUS_POSITION" error re-call with one of the `protocols` the server lists. | |
| walletId | No | Optional Agent Wallet address to withdraw to when the owner holds multiple wallets. Defaults to Q402_AGENT_WALLET_ADDRESS env, then the owner's default wallet on the server. | |
| consentToken | No | Two-phase consent token. Leave unset on the first call to get a preview + token; re-call with confirm:true AND this token after the user approves. Bound to (chain, token, amount, wallet). | |
| idempotencyKey | No | Optional durable idempotency key. Omit and the tool generates a FRESH random key per invocation, so every call executes a distinct withdrawal. Pass your own STABLE key only for opt-in retry-safety - re-calling with the same key replays the first result instead of double-withdrawing. If a call returns status="uncertain", it echoes the idempotencyKey it used - pass that exact value back here to resume the same withdrawal rather than start a new one. |