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

# Investment Flows

> Subscribe to and redeem from tokenized vaults

The `invest` sub-client handles subscription and redemption flows for tokenized vaults. It supports both instant and queued modes depending on the vault's configuration.

For conceptual details on subscription and redemption flows, see [Flows](/v1/operations/flows).

## Subscribe

Subscribe to a tokenized vault by depositing the base asset and receiving vault shares.

### Instant Subscription

When the vault supports instant subscriptions, shares are issued in the same transaction:

```typescript theme={null}
import { GlamClient } from "@glamsystems/glam-sdk";
import { BN } from "@coral-xyz/anchor";

const glamClient = new GlamClient();

// Subscribe with 10 SOL (instant mode)
const txSig = await glamClient.invest.subscribe(
  new BN(10_000_000_000), // amount in base asset units
  false, // queued = false for instant
);
```

### Queued Subscription

When the vault requires pricing delays or notice periods, use queued subscription:

```typescript theme={null}
// Subscribe with 10 SOL (queued mode)
const txSig = await glamClient.invest.subscribe(
  new BN(10_000_000_000),
  true, // queued = true
);
```

## Redeem

### Queued Redemption

Submit a redemption request to burn vault shares and receive the base asset:

```typescript theme={null}
// Redeem 5 shares
const txSig = await glamClient.invest.queuedRedeem(
  new BN(5_000_000_000),
);
```

## Fulfill Requests

The vault manager (or any actor, if permissionless fulfillment is enabled) can fulfill pending subscription and redemption requests:

```typescript theme={null}
// Fulfill up to 10 pending requests
const txSig = await glamClient.invest.fulfill(10);

// Fulfill all pending requests
const txSig = await glamClient.invest.fulfill(null);
```

<Info>
  Before fulfilling requests, the vault must be priced. See [Pricing](/v1/sdk/pricing) for details on generating pricing instructions.
</Info>

## Claim

After a request is fulfilled, the subscriber must claim to complete the flow:

```typescript theme={null}
// Claim for the connected wallet
const txSig = await glamClient.invest.claim();

// Claim for a specific user (manager only)
const txSig = await glamClient.invest.claimForUser(
  new PublicKey("User1111111111111111111111111111"),
);
```

## Cancel

Cancel a pending request before it is fulfilled:

```typescript theme={null}
// Cancel the connected wallet's pending request
const txSig = await glamClient.invest.cancel();

// Cancel a specific user's request (manager only)
const txSig = await glamClient.invest.cancelForUser(
  new PublicKey("User1111111111111111111111111111"),
);
```

## Query Pending Requests

Fetch the pending subscription or redemption request for a user:

```typescript theme={null}
// Fetch pending request for connected wallet
const request = await glamClient.invest.fetchPendingRequest();

// Fetch pending request for a specific user
const request = await glamClient.invest.fetchPendingRequest(
  new PublicKey("User1111111111111111111111111111"),
);
```

## End-to-End Example

A complete queued subscription flow:

```typescript theme={null}
import { GlamClient } from "@glamsystems/glam-sdk";
import { BN } from "@coral-xyz/anchor";

const glamClient = new GlamClient();

// 1. Subscriber submits a queued subscription
await glamClient.invest.subscribe(new BN(10_000_000_000), true);

// 2. Manager prices the vault
const pricingIxs = await glamClient.price.priceVaultIxs();
// ... send pricing transaction

// 3. Manager fulfills pending requests
await glamClient.invest.fulfill(null);

// 4. Subscriber claims their shares
await glamClient.invest.claim();
```
