Learn how to connect HYSP vaults on Solana through Everstake Wallet SDK.
Getting Started
The HYSP Solana SDK provides a simple interface for interacting with yield vaults on Solana. It includes read helpers (APY/holdings/price-per-share, balances) and prepares unsigned transactions for deposits and withdrawals.
Installation
npminstall@everstake/wallet-sdk-hysp-solana
Quick Start
import{HyspSolana}from'@everstake/wallet-sdk-hysp-solana';import{address}from'@solana/kit';import{Decimal}from'decimal.js';// Initialize with token symbolconsthysp=newHyspSolana('USDC');// Or with custom RPCconsthyspCustom=newHyspSolana('USDC','https://your-rpc-endpoint.com');// User addressconstuserAddress=address('YourWalletAddressHere');// Get vault informationconstholdings=awaithysp.getVaultHoldings();constapys=awaithysp.getVaultAPYs();// Create deposit transaction (unsigned)constdepositTx=awaithysp.deposit(userAddress,newDecimal('100'));// Create withdraw transaction (unsigned)constwithdrawTx=awaithysp.withdraw(userAddress,newDecimal('50'));
The SDK returns unsigned transactions; your application is responsible for signing and sending them.
Available Methods
Below are the primary methods exposed by the SDK, with short descriptions to help you choose the right call in your flow
Information Methods
getVaultHoldings()— Returns vault assets/positions to help with monitoring and display.
getVaultAPYs() — Fetches current APY data for the vault.
getExchangeRate() — Returns the tokens-per-share (price-per-share) used to convert shares ↔︎ token amount.
getUserShares() — Retrieves a user’s raw share balance in the vault.
getUserBalance() — Convenience helper that multiplies shares × price-per-share for a user-displayable token balance.
Transaction Methods
deposit() — Builds an unsigned deposit transaction message; sign and broadcast in your app.
withdraw() — Builds an unsigned withdraw (redemption) transaction message; sign and broadcast in your app.
Adding Custom Instructions — You can also compose multiple operations by appending additional instructions in your own code to create atomic, single-transaction flows (e.g., withdraw then transfer).
Get Exchange Rate
The getExchangeRate() method retrieves the current tokens-per-share (price-per-share) for the vault. Use it to convert between shares and the display token amount.
Code Example
Calculate Token Value
Tip: To skip manual math, use getUserBalance(), which returns the display token balance directly.
Get User Shares
The getUserShares() method returns the user’s raw vault share balance (receipt token). Use this when you need the underlying share amount; to display token value, either multiply by the exchange rate or call getUserBalance().
Code Example
Note: getUserShares() returns shares, not the token value.
Use getExchangeRate() to convert, or call getUserBalance() to get the display token amount directly.
Get User Balance
The getUserBalance() method returns the user’s display token balance (shares × price-per-share).
Code Example
See also: getUserShares() and getExchangeRate() if you need raw shares or the conversion rate.
Get Vault APYs
The getVaultAPYs() method retrieves the vault’s yield / APY information as exposed by the underlying venue.
Code Example
Notes: The returned APY shape is defined by the venue SDK and includes the current APY the vault reports.
Get Vault Holdings
The getVaultHoldings() method returns a snapshot of the vault’s current assets/performance metrics and related fields as defined by the venue’s VaultHoldings type.
Code Example
Get Vault Liquidity Amount
The getVaultLiquidityAmount() method returns an estimate of liquidity that can be satisfied immediately by the vault, including liquidity currently deployed in the underlying Money Market (MM).
On Kamino, idle reserves are typically close to zero, and withdrawals are usually fulfilled by withdrawing liquidity from the MM. The exact source of liquidity (idle reserve vs MM) is determined internally and cannot be controlled by the caller.
This value is intended to help integrators reason about instant withdrawal capacity, not to reflect idle vault balances only.
⚠️Important note: The returned amount is an informational estimate and does not guarantee withdrawal execution under all market conditions.
Code Example
Get Vault Liquidity Amount
The getVaultLiquidityAmount() method retrieves the current available liquidity in reserves.
Code Example
Deposit
The deposit() method builds an unsigned transaction to deposit tokens into a vault. Your app is responsible for signing and sending the returned transaction message.
Code Example
Withdraw
The withdraw() method creates a transaction to withdraw tokens from a vault by burning shares.
Withdraw Code Example
Withdraw All Shares Code Example
Add Custom Instructions
The deposit() and withdraw() methods support adding custom Solana instructions via the afterInstructions parameter. This lets you compose atomic flows (e.g., withdraw then transfer USDC) in a single transaction.