# Write Methods

#### createVault

Creates a new vault through the YieldVaultFactory.

```tsx
const hash = await client.createVault({
  factory: "0xFactoryAddress",
  name: "My Vault",
  symbol: "MVLT",
  asset: "0xUnderlyingTokenAddress",
});
```

#### deposit

Deposits underlying assets into a vault. The SDK automatically handles checking and requesting the necessary ERC-20 approval before executing the deposit.

```tsx
const hash = await client.deposit({
  vault: "0xVaultAddress",
  assets: 1000000n, // Amount in underlying token decimals
});
```

#### mint

Mints a specific target amount of vault shares. Like `deposit`, it handles approvals automatically.

```tsx
const hash = await client.mint({
  vault: "0xVaultAddress",
  shares: 1000000n, // Amount in vault share decimals (18)
});
```

#### withdraw

Withdraws assets directly from the vault. **Note:** This method only works when the cooldown mechanism is disabled.

```tsx
const hash = await client.withdraw({
  vault: "0xVaultAddress",
  assets: 500000n,
});
```

#### redeem

Redeems shares directly for underlying assets. **Note:** This method only works when the cooldown mechanism is disabled.

```tsx
const hash = await client.redeem({
  vault: "0xVaultAddress",
  shares: 500000n,
});
```

#### cooldownAssets & cooldownShares

When cooldown is enabled, direct withdrawals are blocked. Instead, users must initiate a cooldown flow.

```tsx
// Start cooldown using an asset amount
const hash1 = await client.cooldownAssets({
  vault: "0xVaultAddress",
  assets: 500000n,
});

// Or start cooldown using a share amount
const hash2 = await client.cooldownShares({
  vault: "0xVaultAddress",
  shares: 500000n,
});
```

#### claimFromAp

After a cooldown period finishes, users call this method to claim their matured assets from the aging pool.

```tsx
const hash = await client.claimFromAp({
  vault: "0xVaultAddress",
  // Optionally override recipient:
  // receiver: "0xAnotherAddress"
});
```


---

# 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://city-protocol.gitbook.io/docs/software-development-kit/vault/write-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.
