> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Morpho Blue Withdraw Collateral

Remove collateral from a Morpho Blue position. Modes: 'exact' (specific amount, pre-checked for LTV safety) or 'max' (all collateral, requires zero debt). Supports Ethereum (1), Optimism (10), Polygon (137), Robinhood Chain (4663), Base (8453), Arbitrum (42161). Ideal for: closing position after repay, reducing leverage, reclaiming idle collateral.

![Morpho Blue Withdraw Collateral logo](https://cdn.b3.fun/b3os-icons/morpho.svg)
Catalog action EVM Onchain wallet Gas

Remove collateral from a Morpho Blue position. Modes: 'exact' (specific amount, pre-checked for LTV safety) or 'max' (all collateral, requires zero debt). Supports Ethereum (1), Optimism (10), Polygon (137), Robinhood Chain (4663), Base (8453), Arbitrum (42161). Ideal for: closing position after repay, reducing leverage, reclaiming idle collateral.

**Review wallet and value movement**

This action can require a wallet connector, gas, token movement, or an external side effect. Test with simulation or a controlled amount before using it in a live workflow.

## At a Glance

| Field | Value |
| --- | --- |
| Action ID | `morpho-blue-withdraw-collateral` |
| Category | EVM Onchain |
| Connector | `wallet` |
| Requires gas | Yes |
| Funds movement | None declared |
| Tags | `morpho`, `morpho-blue`, `lending`, `collateral`, `withdraw`, `write`, `defi` |

## Payload Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `marketId` | `string` | Yes | Morpho Blue market ID \(bytes32 hex\) |
| `chainId` | `number` | Yes | Chain ID. Supported: Ethereum \(1\), Optimism \(10\), Polygon \(137\), Robinhood Chain \(4663\), Base \(8453\), Arbitrum \(42161\) |
| `amountMode` | `string` | Yes | "exact" = withdraw a specific collateral amount \(pre-checked for LTV safety\). "max" = withdraw all collateral \(requires zero debt\). |
| `amount` | `string` | No | Required when amountMode="exact". Collateral-token raw amount to withdraw. |
| `gasLimit` | `string` | No | Optional gas limit as a positive integer string \(e.g., "300000"\) |

## Result Schema

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | `string` | Yes | - |
| `transactionHash` | `string` | Yes | - |
| `transactionUrl` | `string` | No | Block explorer URL for the transaction \(e.g. https://basescan.org/tx/0x...\) |
| `blockNumber` | `number` | No | - |
| `withdrawnCollateral` | `string` | No | Raw amount of collateral token withdrawn \(wei\). |
| `withdrawnCollateralFormatted` | `string` | No | Human-readable withdrawn amount in collateral token units |
| `resultingLtvPercent` | `number \| null` | No | Position LTV \(%\) after the withdraw; null if fully closed or oracle unavailable |
| `isFullyClosed` | `boolean` | No | True if collateral reached zero after this withdraw |

## Examples

**Workflow node**

```json
{
  "type": "morpho-blue-withdraw-collateral",
  "payload": {
    "marketId": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "chainId": 1,
    "amountMode": "exact"
  },
  "children": [],
  "connector": {
    "type": "wallet",
    "id": "conn_wallet"
  }
}
```
  **Test with API**

```bash
curl -X POST "https://api.b3os.org/v1/actions/morpho-blue-withdraw-collateral/test" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "inputs": {
    "marketId": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "chainId": 1,
    "amountMode": "exact"
  }
}'
```

**Use expressions for dynamic values**

Payload fields can use workflow expressions such as `{{$trigger.body.amount}}`, `{{$nodes.fetch.result.price}}`, and `{{$props.asset}}` when the value should come from a trigger, prior node, or reusable workflow prop.