VELYS SDK
TypeScript SDK for seamless integration with VELYS liquid staking protocol
Installation
npm install @velys/sdk
# or
yarn add @velys/sdk
# or
pnpm add @velys/sdkInstall the VELYS SDK package using your preferred package manager.
Quick Start
Initialize Client
import { VelysClient } from "@velys/sdk";
import { Connection, PublicKey } from "@solana/web3.js";
// Initialize connection
const connection = new Connection(
"https://api.mainnet-beta.solana.com",
"confirmed"
);
// Create VELYS client
const velys = new VelysClient({
connection,
wallet: yourWalletAdapter,
programId: new PublicKey("VELYS_PROGRAM_ID")
});Stake SOL
// Stake SOL and receive vSOL (liquid staking tokens)
const stakeResult = await velys.stake({
amount: 10, // Amount in SOL
userPublicKey: wallet.publicKey,
});
console.log("Staked successfully:", stakeResult.signature);
console.log("vSOL received:", stakeResult.vSolAmount);Get Staking Info
// Get user's staking position
const stakingInfo = await velys.getStakingInfo(
wallet.publicKey
);
console.log("Staked amount:", stakingInfo.stakedAmount);
console.log("vSOL balance:", stakingInfo.vSolBalance);
console.log("Current APY:", stakingInfo.apy);
console.log("Claimable rewards:", stakingInfo.rewards);Use vSOL in DeFi
// vSOL tokens can be used across DeFi protocols
// Example: Provide liquidity on DEX
const liquidity = await velys.integrations.dex.addLiquidity({
tokenA: velys.vSolMint,
tokenB: USDC_MINT,
amountA: 5, // 5 vSOL
amountB: 500, // 500 USDC
});
// Example: Use as collateral
const collateral = await velys.integrations.lending.deposit({
mint: velys.vSolMint,
amount: 10,
});Unstake SOL
// Request unstaking (may have cooldown period)
const unstakeResult = await velys.unstake({
amount: 5, // Amount of vSOL to unstake
userPublicKey: wallet.publicKey,
});
console.log("Unstake initiated:", unstakeResult.signature);
console.log("Cooldown period:", unstakeResult.cooldownPeriod);
// Claim unstaked SOL after cooldown
const claimResult = await velys.claimUnstaked({
userPublicKey: wallet.publicKey,
});Monitor Events
// Subscribe to staking events
velys.onStakeEvent((event) => {
console.log("Stake event:", event);
});
velys.onUnstakeEvent((event) => {
console.log("Unstake event:", event);
});
velys.onRewardEvent((event) => {
console.log("Reward distributed:", event);
});Key Features
Solana-Native
Built specifically for Solana with full support for native features and optimal performance.
Type-Safe
Complete TypeScript support with full type definitions for all methods and responses.
Composable
Integrate with any DeFi protocol - DEXs, lending platforms, yield aggregators, and more.
Event-Driven
Real-time event subscriptions for monitoring staking operations and protocol updates.
Non-Custodial
You maintain full control of your assets. All operations are executed through your wallet.
Lightweight
Minimal dependencies and optimized bundle size for fast loading and execution.
Best Practices
- •
Always handle errors gracefully
Wrap SDK calls in try-catch blocks and provide user-friendly error messages.
- •
Verify transaction signatures
Always confirm transactions on-chain before updating your UI state.
- •
Use appropriate RPC endpoints
For production apps, use dedicated RPC providers for better reliability and performance.
- •
Implement proper wallet handling
Support multiple wallet adapters and handle connection/disconnection events properly.
- •
Cache data appropriately
Use caching strategies to reduce RPC calls while maintaining data freshness.