Skip to main content
Clients for native staking and stake pool operations.

StakePoolClient

Client for interacting with stake pools (liquid staking tokens).

Constructor

new StakePoolClient(
  base: BaseClient,
  stake: StakeClient,
  marinade: MarinadeClient
)
base
BaseClient
required
Base client instance
stake
StakeClient
required
Stake client instance
marinade
MarinadeClient
required
Marinade client instance

Methods

depositSol

Deposits SOL to a stake pool and receives pool tokens.
await client.stakePool.depositSol(
  stakePool: PublicKey,
  amount: BN,
  txOptions?: TxOptions
): Promise<TransactionSignature>
stakePool
PublicKey
required
Stake pool address
amount
BN
required
Amount of SOL to deposit in lamports

depositStake

Deposits a stake account to a stake pool.
await client.stakePool.depositStake(
  stakePool: PublicKey,
  stakeAccount: PublicKey,
  txOptions?: TxOptions
): Promise<TransactionSignature>
stakeAccount
PublicKey
required
Stake account to deposit

withdrawStake

Withdraws pool tokens for a stake account.
await client.stakePool.withdrawStake(
  stakePool: PublicKey,
  amount: BN,
  deactivate?: boolean,
  txOptions?: TxOptions
): Promise<TransactionSignature>
amount
BN
required
Amount of pool tokens to withdraw
deactivate
boolean
default:"false"
Whether to deactivate the stake account immediately

unstake

Unstakes any liquid staking token (LST) back to native stake.
await client.stakePool.unstake(
  asset: PublicKey,
  amount: number | BN,
  deactivate?: boolean,
  txOptions?: TxOptions
): Promise<TransactionSignature>
asset
PublicKey
required
LST mint address (e.g., mSOL, JitoSOL, bSOL)
amount
number | BN
required
Amount of LST to unstake
deactivate
boolean
default:"false"
Whether to deactivate the stake account immediately

Data Fetching

getStakePoolAccountData

Fetches stake pool account data.
await client.stakePool.getStakePoolAccountData(
  stakePool: PublicKey
): Promise<StakePoolAccountData>
Returns: Stake pool configuration and state

getStakeAccountVoter

Gets the vote account for a stake account.
await client.stakePool.getStakeAccountVoter(
  stakeAccount: PublicKey
): Promise<PublicKey | null>

StakeClient

Client for native staking operations.

Constructor

new StakeClient(
  base: BaseClient
)
base
BaseClient
required
Base client instance

Methods

initializeAndDelegateStake

Creates a new stake account, initializes it, and delegates to a validator.
await client.stake.initializeAndDelegateStake(
  vote: PublicKey,
  amount: BN,
  txOptions?: TxOptions
): Promise<TransactionSignature>
vote
PublicKey
required
Vote account address of the validator
amount
BN
required
Amount to stake in lamports

deactivate

Deactivates one or more stake accounts.
await client.stake.deactivate(
  stakeAccounts: PublicKey[],
  txOptions?: TxOptions
): Promise<TransactionSignature>
stakeAccounts
PublicKey[]
required
Array of stake accounts to deactivate

withdraw

Withdraws from deactivated stake accounts.
await client.stake.withdraw(
  stakeAccounts: PublicKey[],
  txOptions?: TxOptions
): Promise<TransactionSignature>
stakeAccounts
PublicKey[]
required
Array of deactivated stake accounts to withdraw from

merge

Merges two stake accounts.
await client.stake.merge(
  destinationStake: PublicKey,
  sourceStake: PublicKey,
  txOptions?: TxOptions
): Promise<TransactionSignature>
destinationStake
PublicKey
required
Destination stake account
sourceStake
PublicKey
required
Source stake account (will be closed)

split

Splits a stake account into two.
await client.stake.split(
  existingStake: PublicKey,
  lamports: BN,
  txOptions?: TxOptions
): Promise<{
  newStake: PublicKey;
  txSig: TransactionSignature;
}>
existingStake
PublicKey
required
Existing stake account to split
lamports
BN
required
Amount to split into the new stake account
Returns: Object containing the new stake account address and transaction signature

move

Moves stake from one account to another.
await client.stake.move(
  sourceStake: PublicKey,
  destinationStake: PublicKey,
  amount: BN,
  txOptions?: TxOptions
): Promise<TransactionSignature>
sourceStake
PublicKey
required
Source stake account
destinationStake
PublicKey
required
Destination stake account
amount
BN
required
Amount to move in lamports

Helper Methods

createStakeAccount

Creates a new empty stake account.
await client.stake.createStakeAccount(
  signer: PublicKey
): Promise<[PublicKey, TransactionInstruction]>
Returns: Tuple of [stakeAccountAddress, createInstruction]

getStakeAccountVoter

Gets the vote account a stake account is delegated to.
await client.stake.getStakeAccountVoter(
  stakeAccount: PublicKey
): Promise<PublicKey | null>

Example

import { BN } from '@coral-xyz/anchor';
import { PublicKey } from '@solana/web3.js';
import { GlamClient } from '@glam/anchor';

const client = new GlamClient();

// Native staking to a validator
const voteAccount = new PublicKey('...');
const stakeSig = await client.stake.initializeAndDelegateStake(
  voteAccount,
  new BN(10_000_000_000) // 10 SOL
);

// Deposit SOL to a stake pool
const stakePoolAddress = new PublicKey('...');
const depositSig = await client.stakePool.depositSol(
  stakePoolAddress,
  new BN(5_000_000_000) // 5 SOL
);

// Unstake mSOL back to native stake
const MSOL = new PublicKey('mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So');
const unstakeSig = await client.stakePool.unstake(
  MSOL,
  new BN(1_000_000_000), // 1 mSOL
  true // deactivate immediately
);

// Split a stake account
const stakeAccount = new PublicKey('...');
const { newStake, txSig } = await client.stake.split(
  stakeAccount,
  new BN(2_000_000_000) // Split 2 SOL into new account
);
console.log('New stake account:', newStake.toBase58());

Build docs developers (and LLMs) love