@arcium-hq/staking
v0.13.1
Published
TypeScript SDK for the Arcium staking program
Downloads
141
Maintainers
Readme
When To Use
- Deriving staking PDAs (primary stake, delegated stake, delegation master, pool) from TypeScript
- Building staking transactions (stake, delegate, claim, finalize) for a wallet to sign
- Reading typed staking account state and a wallet's delegated positions
Requirements
- Node.js
>=20.18.0 @anchor-lang/core^1.0.2
Installation
npm install @arcium-hq/staking @anchor-lang/core @solana/web3.jsQuick Start
import {
getStakingProgram,
getPrimaryStakeAccInfo,
getUserStakePositions,
buildInitPrimaryStakeIx,
} from "@arcium-hq/staking";
// `provider` is an `AnchorProvider` you've already constructed.
const program = getStakingProgram(provider);
const owner = provider.wallet.publicKey;
// Read on-chain state (null when the account does not exist).
const primary = await getPrimaryStakeAccInfo(program, owner);
const positions = await getUserStakePositions(program, owner);
// Build an instruction; your wallet signs and sends it.
const ix = await buildInitPrimaryStakeIx({
program,
from: owner,
amount: 1_000n,
feeBasisPoints: 100,
});Main Exports
| Area | Description |
|------|-------------|
| PDA helpers | Derive staking pool, primary/delegated stake, master, and cross-program clock/cluster addresses. |
| Instruction builders | build*Ix for every staking instruction; each returns a TransactionInstruction. |
| Account readers | get*AccInfo (single), get*AccInfos (all), and getUserStakePositions. |
| Offset helpers | generateStakeOffset and assertValidStakeOffset for delegated u128 offsets. |
| IDL exports | Bundled staking IDL, generated types, and derived program/mint addresses. |
Notes
- Builders return
TransactionInstructions — the wallet controls signing and sending. - Program id, ARX mint, and token program ids are derived from the bundled IDL; there are no hardcoded addresses.
- Reward claim builders require a caller-supplied
MTProofandRewardBatch; proof discovery needs an off-chain indexer and is out of scope for this SDK. bind_primary_stakeis deliberately not exposed: it can only be invoked via CPI from the Arcium program, so a directly built transaction can never satisfy its signer requirement.
