# Operation - Withdraw

### Key Steps

1. **Parse Withdrawal Amount**:
   * Use the `parseEther` function to convert the desired amount of collateral to be withdrawn into Wei. This function ensures that the amount is accurately converted to the smallest unit of ether, allowing precise handling in blockchain transactions.
2. **Execute Withdrawal Transaction**:
   * Call the `doWithdraw` function, passing the necessary parameters such as the public and wallet clients, protocol configuration, collateral information, and the amount of collateral to withdraw. This function handles the transaction on the blockchain and adjusts the user's trove accordingly.

### Usage

This function is typically used when a user wants to:

* **Access Liquidity**: Withdraw a portion of their collateral for immediate liquidity needs, such as covering expenses or reinvesting in other opportunities.
* **Adjust Collateral Levels**: Decrease their collateral exposure due to changes in market conditions or personal risk preferences.

### Example

```typescript
import { parseEther } from 'viem';
import { publicClient, walletClient, protocolConfig, collateral } from 'satoshi-sdk';

async function withdrawCollateral() {
  // Step 1: Define the amount to withdraw
  const withdrawCollAmt = parseEther('0.01');  // Withdrawing 0.01 ETH worth of collateral

  // Step 2: Execute the withdrawal transaction
  const receipt = await satoshiClient.Postition.doWithdraw({
    publicClient,
    walletClient,
    protocolConfig,
    collateral,
    withdrawCollAmt,
  });

  console.log('Withdrawal successful:', receipt);
}

withdrawCollateral();
```

This example function, `withdrawCollateral`, demonstrates the step-by-step process to withdraw a small amount of collateral from a trove. It includes the precise conversion of the desired withdrawal amount and the execution of the withdrawal transaction, ensuring the trove remains compliant with the protocol's requirements.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.river.inc/satoshi-protocol-v1/sdk/position/operation-withdraw.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
