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

# Create Vault (via SDK)

> Create a vault, configure policies, and execute strategy operations

***

<Info>
  Strategy Vaults can also be created through the Strategy Vault manager frontend, which simplifies setup by offering a guided interface for configuring vault metadata, policies, roles, and other core vault parameters.
</Info>

This guide walks through the vault setup workflow, from loading a vault to configuring policies and executing strategy operations, as well as managing withdrawals.

## Exponent SDK Installation

<CodeGroup>
  ```bash yarn theme={null}
  yarn add @exponent-labs/exponent-sdk
  ```

  ```bash npm theme={null}
  npm install @exponent-labs/exponent-sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @exponent-labs/exponent-sdk
  ```
</CodeGroup>

### Strategy Vault Setup

```typescript theme={null}
import { ExponentVault } from "@exponent-labs/exponent-sdk";
import {
  Connection,
  PublicKey,
  Transaction,
  sendAndConfirmTransaction,
  Keypair,
} from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com");
const wallet = Keypair.fromSecretKey(/* your keypair */);
const vaultAddress = new PublicKey("...");

// Load the vault — fetches on-chain state and all token entries
const vault = await ExponentVault.load({ connection, address: vaultAddress });
```

## Vault Creation

Strategy Vaults are created by the vault manager using `ExponentVault.ixInitializeVault`. This sets up the vault PDA, mints initial LP tokens, and creates the Squads smart account for policy-gated execution. See [Initialize Vault](/developer-strategy-vaults/typescript/admin-operations/initialize-vault) for the full parameter reference.

### Loading a Vault

```typescript theme={null}
import { ExponentVault } from "@exponent-labs/exponent-sdk";
import { Connection, PublicKey } from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");
const vaultAddress = new PublicKey("...");

const vault = await ExponentVault.load({ connection, address: vaultAddress });

// Access vault state
const squadsVault = vault.state.squadsVault;     // Squads smart account PDA
const tokenEntries = vault.state.tokenEntries;    // Accepted deposit tokens
const aumInBase = vault.state.financials.aumInBase;
```

## Configuring Policies

Before the vault can execute any strategy operations, the manager must add policies that authorize specific interactions. Each policy defines which programs, instructions, and accounts the vault is permitted to interact with.

Policies are added using `vault.ixWrapperAddPolicy`. This instruction enforces that the vault has zero AUM — policies must be configured before any deposits are accepted.

<Warning>
  Once the vault holds depositor funds (AUM > 0), policy changes must go through a governance proposal using `PolicyAction`. See [Governance](/developer-strategy-vaults/typescript/governance/overview) for the proposal flow.
</Warning>

```typescript theme={null}
import {
  ExponentVault,
  createKaminoPolicy,
  KAMINO_MARKETS,
  KAMINO_RESERVES,
  KaminoMarket,
} from "@exponent-labs/exponent-sdk";
import { Connection, PublicKey, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");
const vault = await ExponentVault.load({ connection, address: vaultAddress });

const policyConfig = createKaminoPolicy({
  allowedDepositMints: [KAMINO_RESERVES[KaminoMarket.MAIN]["USDC"].mint],
  actions: ["deposit", "withdraw"],
  allowedLendingMarkets: [KAMINO_MARKETS[KaminoMarket.MAIN]],
});

const ix = vault.ixWrapperAddPolicy({
  payer: managerWallet.publicKey,
  policyConfig,
  squadsProgram,
  nextPolicySeed,
  nextTransactionIndex,
});

const tx = new Transaction().add(ix);
await sendAndConfirmTransaction(connection, tx, [managerWallet]);
```

### Available Policy Builders

The SDK provides policy builders for each supported integration:

| Builder                                                                                     | Integration               | Description                                                                       |
| ------------------------------------------------------------------------------------------- | ------------------------- | --------------------------------------------------------------------------------- |
| `createCorePolicy`                                                                          | Exponent Core             | Strip and merge base tokens into PT + YT                                          |
| `createMarketTwoTradePtPolicy`, `createMarketTwoBuyYtPolicy`, `createMarketTwoSellYtPolicy` | Exponent AMM (Market Two) | Trade PT, buy YT, and sell YT on legacy AMM markets                               |
| `createOrderbookPolicy`                                                                     | Exponent Orderbook        | Post offers, market orders, remove offers, withdraw funds                         |
| `createClmmPolicy`                                                                          | Exponent CLMM             | Provide liquidity, trade PT/YT, claim farm emissions                              |
| `createKaminoPolicy`                                                                        | Kamino Lending            | Deposit, withdraw, borrow, and repay on Kamino reserves                           |
| `createJupiterEarnPolicy`                                                                   | Jupiter Lend Earn         | Deposit, mint, withdraw, redeem on Jupiter Earn jlToken vaults                    |
| `createJupiterBorrowPolicy`                                                                 | Jupiter Lend Borrow       | Init, deposit/withdraw collateral, borrow/repay debt, and paired operate ops      |
| `createOrcaWhirlpoolPolicy`                                                                 | Orca Whirlpool            | Open positions, modify liquidity, collect fees/rewards, close positions, and swap |
| `createLoopscalePolicy`                                                                     | Loopscale                 | Authorize lender-side strategy and borrower-side loan actions                     |
| `createTitanSwapPolicy`                                                                     | Titan                     | Swap tokens through the Titan DEX aggregator                                      |

See [Policy Builders](/developer-strategy-vaults/policy-builders) for detailed parameters and examples for each builder.

<Warning>
  Policies are enforced onchain. Any transaction that does not match an approved policy is rejected. Ensure the correct policies are in place before attempting strategy operations.
</Warning>

## Executing Strategy Operations

Strategy operations use a two-step pattern:

1. **Build instruction descriptors** using a protocol-specific action builder (`kaminoAction`, `orderbookAction`, `coreAction`, `marketTwoAction`, `clmmAction`, `orcaWhirlpoolAction`, `titanAction`). Each builder returns a lightweight descriptor — it does not execute anything on its own.
2. **Wrap in a sync transaction** by passing the descriptors to `createVaultSyncTransaction`, which resolves all required accounts, builds the Squads sync transaction, and returns the final instructions to send.

```typescript theme={null}
import {
  kaminoAction,
  createVaultSyncTransaction,
  KaminoMarket,
} from "@exponent-labs/exponent-sdk";
import { BN } from "@coral-xyz/anchor";

// Step 1: Build an instruction descriptor
const depositDescriptor = kaminoAction.deposit(KaminoMarket.MAIN, "USDC", new BN(100_000_000));

// Step 2: Wrap in a sync transaction
const { preInstructions, instruction, postInstructions } =
  await createVaultSyncTransaction({
    instructions: [depositDescriptor],
    owner: vaultPda,
    connection,
    policyPda,
    vaultPda,
    signer: wallet.publicKey,
    vaultAddress,
  });

// Step 3: Send
const tx = new Transaction().add(...preInstructions, instruction, ...postInstructions);
await sendAndConfirmTransaction(connection, tx, [wallet]);
```

### Action Builders

Each integration has its own action builder namespace:

| Action Builder        | Integration               | Example                                                                           |
| --------------------- | ------------------------- | --------------------------------------------------------------------------------- |
| `coreAction`          | Exponent Core             | `coreAction.strip({ vault, amountBase })`                                         |
| `marketTwoAction`     | Exponent AMM (Market Two) | `marketTwoAction.tradePt({ market, netTraderPt, syConstraint })`                  |
| `orderbookAction`     | Exponent Orderbook        | `orderbookAction.postOffer({ orderbook, direction, priceApy, amount, offerIdx })` |
| `clmmAction`          | Exponent CLMM             | `clmmAction.buyPt({ market, amountSy, outConstraint })`                           |
| `kaminoAction`        | Kamino Lending            | `kaminoAction.deposit(KaminoMarket.MAIN, "USDC", new BN(100_000_000))`            |
| `jupiterEarnAction`   | Jupiter Lend Earn         | `jupiterEarnAction.deposit({ instruction })`                                      |
| `jupiterBorrowAction` | Jupiter Lend Borrow       | `jupiterBorrowAction.depositCollateral({ instruction, vaultId: 1 })`              |
| `orcaWhirlpoolAction` | Orca Whirlpool            | `orcaWhirlpoolAction.increaseLiquidityV2({ instruction })`                        |
| `managerAction`       | Manager (vault-side)      | `managerAction.fillWithdrawal({ withdrawalAccount, amount: { kind: "full" } })`   |
| `titanAction`         | Titan                     | `titanAction.swap({ instruction })`                                               |

<Note>
  For Titan swaps, the instruction descriptor wraps a pre-built `TransactionInstruction` obtained from `TitanGatewayClient.quoteVaultSwapInstruction`. See [Titan Instructions](/developer-strategy-vaults/titan-dex-instructions) for the full flow.
</Note>

See the individual instruction pages for full usage and parameter details:

<CardGroup cols={2}>
  <Card href="/developer-strategy-vaults/policy-builders" title="Policy Builders">
    Start here to define what your vault is allowed to do.
  </Card>

  <Card href="/developer-strategy-vaults/exponent-core-instructions" title="Core Instructions">
    Strip and merge tokens through Exponent Core.
  </Card>

  <Card href="/developer-strategy-vaults/kamino-instructions" title="Kamino Lend Instructions">
    Deposit, withdraw, borrow, and repay on Kamino Lend.
  </Card>

  <Card href="/developer-strategy-vaults/kamino-vault-instructions" title="Kamino Vault Instructions">
    Deposit into and withdraw from direct Kamino Vault positions.
  </Card>

  <Card href="/developer-strategy-vaults/exponent-orderbook-instructions" title="Order Book Instructions">
    Trade PT and YT on Exponent Orderbook, place limit orders.
  </Card>

  <Card href="/developer-strategy-vaults/orca-whirlpool-instructions" title="Orca Whirlpool Instructions">
    Wrap Orca Whirlpool position and swap instructions for vault execution.
  </Card>

  <Card href="/developer-strategy-vaults/exponent-clmm-instructions" title="CLMM Instructions">
    Provide liquidity and trade on the Exponent CLMM.
  </Card>

  <Card href="/developer-strategy-vaults/loopscale-instructions" title="Loopscale Instructions">
    Build raw Loopscale responses and turn them into executable vault transactions.
  </Card>

  <Card href="/developer-strategy-vaults/titan-dex-instructions" title="Titan Instructions">
    Swap tokens through the Titan DEX aggregator.
  </Card>
</CardGroup>

## Managing Withdrawals

When depositors queue withdrawals, the vault manager fills them from available liquidity:

1. **Queue** — A depositor calls `ixQueueWithdrawal` to lock LP tokens and create a withdrawal request.
2. **Fill** — The vault manager calls `fillWithdrawal` to associate underlying tokens with the pending request. LP tokens are burned at this step.
3. **Execute** — The depositor calls `ixExecuteWithdrawal` to receive their underlying tokens.

See [Moving Capital In/Out](/developer-strategy-vaults/typescript/vault-operations/overview) for the full depositor-facing flow.
