Skip to main content

Common token mints

WSOL

Wrapped SOL token mint address.
import { WSOL } from '@glamsystems/glam-sdk';

const WSOL = new PublicKey('So11111111111111111111111111111111111111112');

MSOL

Marinade staked SOL (mSOL) token mint address.
import { MSOL } from '@glamsystems/glam-sdk';

const MSOL = new PublicKey('mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So');

USDC

USDC token mint address (6 decimals).
import { USDC } from '@glamsystems/glam-sdk';

USDT

USDT token mint address (6 decimals).
import { USDT } from '@glamsystems/glam-sdk';

PDA seeds

Constants used for deriving Program Derived Addresses.

SEED_STATE

Seed for vault state accounts.
const SEED_STATE = "state";

SEED_VAULT

Seed for vault treasury accounts.
const SEED_VAULT = "vault";

SEED_MINT

Seed for share token mint accounts.
const SEED_MINT = "mint";

SEED_ESCROW

Seed for escrow accounts.
const SEED_ESCROW = "escrow";

SEED_REQUEST_QUEUE

Seed for request queue accounts.
const SEED_REQUEST_QUEUE = "request-queue";

Account sizes

Constants for account size calculations.

STAKE_ACCOUNT_SIZE

Size in bytes for native Solana stake accounts.
const STAKE_ACCOUNT_SIZE = 200;

KAMINO_OBTRIGATION_SIZE

Size in bytes for Kamino lending obligation accounts.
const KAMINO_OBTRIGATION_SIZE = 3344;

DRIFT_VAULT_DEPOSITOR_SIZE

Size in bytes for Drift vault depositor accounts.
const DRIFT_VAULT_DEPOSITOR_SIZE = 272;

Utility functions

stringToChars

Converts a string to a fixed-length character array for on-chain storage.
function stringToChars(name: string, length: number = 32): number[]
name
string
required
String to convert
length
number
Target array length (default: 32)
Example:
import { stringToChars } from '@glamsystems/glam-sdk';

const nameChars = stringToChars("My Fund"); // [77, 121, 32, 70, 117, 110, 100, 0, 0, ...]

charsToString

Converts a character array back to a string.
function charsToString(chars: number[] | Buffer): string
chars
number[] | Buffer
required
Character array to convert
Example:
import { charsToString } from '@glamsystems/glam-sdk';

const name = charsToString([77, 121, 32, 70, 117, 110, 100]); // "My Fund"

toUiAmount

Converts a raw token amount to UI amount with decimals.
function toUiAmount(amount: BN, decimals: number): number
amount
BN
required
Raw token amount
decimals
number
required
Token decimals
Example:
import { toUiAmount } from '@glamsystems/glam-sdk';
import { BN } from '@coral-xyz/anchor';

const uiAmount = toUiAmount(new BN(1_000_000_000), 9); // 1.0 SOL

fromUiAmount

Converts a UI amount to raw token amount.
function fromUiAmount(amount: number | string, decimals: number): BN
amount
number | string
required
UI amount with decimals
decimals
number
required
Token decimals
Example:
import { fromUiAmount } from '@glamsystems/glam-sdk';

const rawAmount = fromUiAmount(1.5, 9); // BN(1_500_000_000)

Build docs developers (and LLMs) love