# Withdrawal Methods

### `withdraw()`

Withdraws tokens from the Papaya protocol.

```typescript
async withdraw(amount: bigint | number): Promise<ethers.TransactionResponse>
```

**Parameters:**

* `amount`: The amount of tokens to withdraw, should be formatted using `formatInput()`

**Returns:** An ethers.js `TransactionResponse` object.

**Example:**

```typescript
// Format the amount correctly (50 USDT with 18 decimals)
const amount = formatInput('50', 18);

// Withdraw
const tx = await papaya.withdraw(amount);
await tx.wait();
console.log('Withdrawal successful');
```

### `withdrawBySig()`

Creates a withdrawal transaction that can be signed off-chain and executed by anyone.

```typescript
async withdrawBySig(amount: bigint | number, deadline: number): Promise<ethers.TransactionResponse>
```

**Parameters:**

* `amount`: The amount of tokens to withdraw, should be formatted using `formatInput()`
* `deadline`: Timestamp after which the transaction can't be executed

**Returns:** An ethers.js `TransactionResponse` object.

**Example:**

```typescript
// Format the amount correctly (50 USDT with 18 decimals)
const amount = formatInput('50', 18);

// Set deadline to 1 hour from now
const deadline = Math.floor(Date.now() / 1000) + 3600;

// Create the withdrawBySig transaction
const tx = await papaya.withdrawBySig(amount, deadline);
await tx.wait();
```

### `withdrawTo()`

Withdraws tokens directly to another address.

```typescript
async withdrawTo(to: string, amount: bigint | number): Promise<ethers.TransactionResponse>
```

**Parameters:**

* `to`: The recipient address
* `amount`: The amount of tokens to withdraw, should be formatted using `formatInput()`

**Returns:** An ethers.js `TransactionResponse` object.

**Example:**

```typescript
const recipientAddress = '0x...';
// Format the amount correctly (25 USDT with 18 decimals)
const amount = formatInput('25', 18);

// Withdraw to the recipient
const tx = await papaya.withdrawTo(recipientAddress, amount);
await tx.wait();
```


---

# 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.papaya.finance/sdk/api-reference/withdrawal-methods.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.
