Skip to main content
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.

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:
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:
// 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:
// 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:
// Fulfill up to 10 pending requests
const txSig = await glamClient.invest.fulfill(10);

// Fulfill all pending requests
const txSig = await glamClient.invest.fulfill(null);
Before fulfilling requests, the vault must be priced. See Pricing for details on generating pricing instructions.

Claim

After a request is fulfilled, the subscriber must claim to complete the flow:
// 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:
// 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:
// 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:
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();