prepare_morpho_withdraw_collateral
Build an unsigned Morpho Blue transaction to withdraw collateral from a market and return it to your wallet. Only exact amounts; check deposited collateral via get_morpho_positions first.
Instructions
Build an unsigned Morpho Blue withdrawCollateral transaction — removes collateral from a market to send back to the wallet. Only withdraws the exact amount specified; "max" is NOT supported because Morpho's isolated-market accounting doesn't expose a clean max-safe value without simulating against the market's oracle/LLTV (query get_morpho_positions first to know your deposited collateral). Will revert on-chain if the withdrawal would push the position below the liquidation threshold. No approval step needed. Returns a handle + preview for Ledger signing.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wallet | Yes | 0x-prefixed EVM wallet address (40 hex chars) that will execute this action. | |
| chain | No | EVM chain Morpho Blue is deployed on. Currently only ethereum is enabled. | ethereum |
| marketId | Yes | Morpho Blue market id — 32-byte hex (0x + 64 hex chars). Identifies the market's (loanToken, collateralToken, oracle, irm, lltv) tuple. Discover via get_morpho_positions. | |
| amount | Yes | Human-readable decimal amount, NOT raw wei/base units. Example: "10" for 10 USDC. Pass "max" for full-balance withdraw/repay. |