Skip to main content

Documentation Index

Fetch the complete documentation index at: https://v2-docs.exponent.finance/llms.txt

Use this file to discover all available pages before exploring further.

The Titan instructions module enables vault managers and allocators to swap tokens through Titan, a Solana DEX aggregator. The integration works in two steps: fetch a swap quote from Titan’s gateway, then wrap the resulting instruction in a Squads sync transaction.
Titan swap quotes are fetched from Titan’s REST gateway, which requires a base URL (baseUrl) and an auth token (authToken) issued by Titan.

Transaction Structure

Every Titan interaction goes through createVaultSyncTransaction, which returns three parts:
const { preInstructions, instruction, postInstructions } =
  await createVaultSyncTransaction({
    instructions,   // Array of VaultInstruction descriptors
    owner,          // Vault PDA (the Squads smart account)
    connection,
    policyPda,      // Policy authorizing this execution
    vaultPda,       // Squads vault PDA
    signer,         // The allocator or manager wallet
    vaultAddress,   // ExponentStrategyVault PDA (auto-resolves hook accounts)
  });

// Send all three parts in order
const tx = new Transaction().add(...preInstructions, instruction, ...postInstructions);
await sendAndConfirmTransaction(connection, tx, [wallet]);
PartWhat it containsWhy it’s separate
preInstructionsAny permissionless setup instructionsMust be top-level instructions
instructionSquads sync transaction wrapping all vault-signed instructionsExecutes with the vault’s smart account as signer
postInstructionsAny post-operation instructionsMust be top-level instructions

Fetching a Quote

TitanGatewayClient.quoteVaultSwapInstruction requests a swap route from Titan’s gateway and returns a TransactionInstruction along with any Address Lookup Table addresses needed for transaction compilation.
import { TitanGatewayClient } from "@exponent-labs/exponent-sdk";
import { PublicKey } from "@solana/web3.js";

const titan = new TitanGatewayClient({
  baseUrl: "https://...",   // Titan gateway URL
  authToken: "...",         // Titan auth token
});

const quoteResult = await titan.quoteVaultSwapInstruction({
  inputMint: new PublicKey("..."),    // Token to sell
  outputMint: new PublicKey("..."),   // Token to buy
  amount: 1_000_000_000n,             // Amount of input token in native units
  slippageBps: 50,                    // Slippage tolerance in basis points
  ownerPda: vaultPda,                 // The vault's smart account (trader)
});

Parameters

ParameterTypeDescription
baseUrlstringTitan gateway base URL
authTokenstringTitan auth token. Sent as an Authorization: Bearer header
inputMintPublicKeyMint address of the token to sell
outputMintPublicKeyMint address of the token to buy
amountbigintAmount of input token in native units
slippageBpsnumberOptional. Slippage tolerance in basis points
ownerPdaPublicKeyThe trader’s smart account — use the vault’s Squads PDA

Return Value

FieldTypeDescription
instructionTransactionInstructionThe Titan SwapRouteV2 instruction to execute
addressLookupTableAddressesPublicKey[]Address Lookup Table addresses from the Titan route
Titan swap quotes have a short expiry. Fetch the quote and submit the transaction promptly to avoid stale routes.

Executing a Swap

titanAction.swap wraps the instruction from quoteVaultSwapInstruction into a vault instruction descriptor for createVaultSyncTransaction.
import {
  titanAction,
  createVaultSyncTransaction,
} from "@exponent-labs/exponent-sdk";

const { preInstructions, instruction, postInstructions } =
  await createVaultSyncTransaction({
    instructions: [
      titanAction.swap({
        instruction: quoteResult.instruction,
        addressLookupTableAddresses: quoteResult.addressLookupTableAddresses,
      }),
    ],
    owner: vaultPda,
    connection,
    policyPda,
    vaultPda,
    signer: wallet.publicKey,
    vaultAddress,
  });

const tx = new Transaction().add(...preInstructions, instruction, ...postInstructions);
await sendAndConfirmTransaction(connection, tx, [wallet]);

Parameters

ParameterTypeDescription
instructionTransactionInstructionThe Titan SwapRouteV2 instruction returned by quoteVaultSwapInstruction
addressLookupTableAddressesPublicKey[]Optional. ALT addresses from the quote. Defaults to []. Strongly recommended
Passing addressLookupTableAddresses from the quote is strongly recommended — the sync transaction builder uses them to compress the final V0 message.
A matching policy must exist before executing. See Policy Builders.

Full Flow Example

This example demonstrates fetching a Titan swap quote and executing it through the vault.

Step 1: Fetch Swap Quote

import {
  TitanGatewayClient,
  titanAction,
  createVaultSyncTransaction,
} 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 INPUT_MINT = new PublicKey("...");   // e.g., USDC
const OUTPUT_MINT = new PublicKey("...");  // e.g., SOL

const titan = new TitanGatewayClient({
  baseUrl: "https://...",
  authToken: "...",
});

const quoteResult = await titan.quoteVaultSwapInstruction({
  inputMint: INPUT_MINT,
  outputMint: OUTPUT_MINT,
  amount: 1_000_000_000n,
  slippageBps: 50,
  ownerPda: vaultPda,
});

Step 2: Execute Swap Through Vault

const { preInstructions, instruction, postInstructions } =
  await createVaultSyncTransaction({
    instructions: [
      titanAction.swap({
        instruction: quoteResult.instruction,
        addressLookupTableAddresses: quoteResult.addressLookupTableAddresses,
      }),
    ],
    owner: vaultPda,
    connection,
    policyPda,
    vaultPda,
    signer: wallet.publicKey,
    vaultAddress,
  });

const tx = new Transaction().add(...preInstructions, instruction, ...postInstructions);
await sendAndConfirmTransaction(connection, tx, [wallet]);