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

# withdrawFromYieldVault

# withdrawFromYieldVault

Withdraws assets from an [Earn](/docs/overview/yield) vault, then signs and sends the resulting transaction. As with [`depositToYieldVault`](/docs/javascript/reference/client/deposit-to-yield-vault), the vault's contract address and asset decimals are resolved server-side — you pass a `vaultId` and a human-readable `amount`.

Unlike a deposit, there is no approval step — the wallet is redeeming shares it already holds — so this is always a single transaction.

## Usage

```javascript theme={"system"}
import { withdrawFromYieldVault } from '@dynamic-labs-sdk/client';

const { transactionHash } = await withdrawFromYieldVault({
  vaultId: 'fb-eth-galaxy-usdc-fw-01',
  walletAccount,
  amount: '10.5', // 10.5 USDC — human-readable units, not raw
});

console.log('Transaction hash:', transactionHash);
```

## Parameters

| Parameter         | Type                       | Description                                                                                                                                                                                   |
| ----------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `vaultId`         | `string`                   | Opaque vault identifier, from [`listYieldVaults`](/docs/javascript/reference/client/list-yield-vaults).                                                                                            |
| `walletAccount`   | `WalletAccount`            | The wallet account whose shares are being redeemed. Must be an EVM wallet account.                                                                                                            |
| `amount`          | `string`                   | How much of the vault's underlying asset to withdraw, in the asset's human-readable units (`'10.5'` USDC, not `'10500000'`). Rejected when it carries more precision than the asset supports. |
| `receiverAddress` | `string` (optional)        | The address that receives the withdrawn assets. Defaults to `walletAccount`'s own address.                                                                                                    |
| `client`          | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple Dynamic clients.                                                                                                               |

## Returns

`Promise<{ transactionHash: string }>` - The hash of the withdraw transaction.

## Examples

### Withdraw the full position

```javascript theme={"system"}
import {
  getYieldDetails,
  getYieldPosition,
  withdrawFromYieldVault,
} from '@dynamic-labs-sdk/client';
import { formatUnits } from 'viem';

async function withdrawAll(vaultId, walletAccount) {
  const [details, position] = await Promise.all([
    getYieldDetails({ vaultId }),
    getYieldPosition({ vaultId, walletAccount }),
  ]);

  const amount = formatUnits(BigInt(position.assets), details.assetDecimals);

  return withdrawFromYieldVault({ vaultId, walletAccount, amount });
}
```

## Supported Chains

`withdrawFromYieldVault` only supports EVM wallet accounts — vault actions are EVM-only today. Calling it with a non-EVM `walletAccount` throws a `WalletProviderMethodUnavailableError`, since only EVM wallet providers implement the underlying `executeYieldTransaction` method.

## React

```tsx theme={"system"}
import { useWithdrawFromYieldVault } from '@dynamic-labs-sdk/react-hooks';

function WithdrawButton({ vaultId, walletAccount, amount, onComplete }) {
  const { mutate: withdraw, isPending } = useWithdrawFromYieldVault();

  return (
    <button
      onClick={() =>
        withdraw(
          { vaultId, walletAccount, amount },
          { onSuccess: ({ transactionHash }) => onComplete(transactionHash) },
        )
      }
      disabled={isPending}
    >
      Withdraw
    </button>
  );
}
```

`useWithdrawFromYieldVault` invalidates [`useGetYieldPosition`](/docs/javascript/reference/client/get-yield-position) on success — treat that refetch as a nudge, since the withdrawal is only broadcast (not necessarily mined) when the mutation resolves.

## Related

* [`depositToYieldVault`](/docs/javascript/reference/client/deposit-to-yield-vault) - Deposit into a vault
* [`getYieldPosition`](/docs/javascript/reference/client/get-yield-position) - Read the wallet's remaining position
