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

# Withdraw

> Withdraw assets from DeFi positions

# Withdraw

Withdraw assets from a DeFi yield position back to the sub-account's wallet.

## Steps

### 1. Create the withdraw plan

<CodeGroup>
  ```typescript TypeScript theme={null}
  const plan = await client.plan.withdraw(account.account_id, {
    amount: "500000",    // 0.5 USDC
    asset: "USDC",
    network: "base",
    protocol: "compound",
  });
  ```

  ```python Python theme={null}
  plan = await client.plan.withdraw(
      account["account_id"],
      amount="500000",    # 0.5 USDC
      asset="USDC",
      network="base",
      protocol="compound",
  )
  ```

  ```rust Rust theme={null}
  let plan = client
      .plan()
      .withdraw(
          &account.account_id,
          WithdrawParams {
              amount: "500000".to_string(),    // 0.5 USDC
              asset: "USDC".to_string(),
              network: "base".to_string(),
              protocol: "compound".to_string(),
          },
      )
      .await?;
  ```
</CodeGroup>

### 2. Sign and execute

The flow is identical to earn — sign the digest and call execute. See [Plan-Sign-Execute](/concepts/plan-execute-flow).

### 3. Monitor

The resulting activity will have `action_type: "COMET_WITHDRAW"` (for Compound) in its metadata.
