SDK for Elemental Vault V2 (ELE6) - Multi-mint vault with swap adapters
npm install @elmntl/vaults-v2SDK for Elemental Vault V2 (ELE6) - Multi-mint vault with swap adapters on Solana.
``bash`
npm install @elmntl/vaults-v2or
pnpm add @elmntl/vaults-v2
`typescript
import { Connection, PublicKey } from "@solana/web3.js";
import { AnchorProvider, Wallet } from "@coral-xyz/anchor";
import { ElementalV2Context, Pool, Position } from "@elmntl/vaults-v2";
// Initialize
const connection = new Connection("https://api.mainnet-beta.solana.com");
const provider = new AnchorProvider(connection, wallet, {});
const ctx = new ElementalV2Context(provider);
// Load pool
const poolAddress = new PublicKey("7cXYCSLPQqJDLeUQMYgJ2crM7KiCs9g7z71qvGVjS7F8");
const pool = await ctx.loadPool(poolAddress);
console.log(APR: ${pool.aprPercent}%);TVL: ${pool.currentSupply}
console.log();Max Supply: ${pool.maxSupply}
console.log();
// Load user position
const position = await ctx.loadPosition(pool);
console.log(Status: ${position.status});Deposited: ${position.amount}
console.log();Claimable: ${position.claimableAmount}
console.log();
// Deposit
const depositTx = await ctx.deposit(position, "100"); // 100 tokens
// Deactivate (request withdrawal)
const deactivateTx = await ctx.deactivate(position, "50"); // 50 tokens
// Withdraw (after cooldown)
const withdrawTx = await ctx.withdraw(position);
`
Main entry point for interacting with the Elemental V2 vault program.
#### Pool Operations
- loadPool(address: PublicKey): Promise - Load a single poolloadPools(addresses: PublicKey[]): Promise
- - Load multiple pools
#### Position Operations
- loadPosition(pool: Pool, owner?: PublicKey): Promise - Load user positionloadPositions(pools: Pool[], owner?: PublicKey): Promise
- - Load multiple positions
#### Actions
- deposit(position, amount, minOutput?) - Deposit tokens into the vaultdeactivate(position, amount)
- - Request withdrawal (starts cooldown)claim(position)
- - Claim accumulated rewardswithdraw(position)
- - Withdraw tokens (after cooldown)fundFaucet(pool, amount)
- - Fund the withdrawal faucet (admin)updateEpoch(pool)
- - Advance the epochupdateConfig(pool, params)
- - Update pool configuration (admin)
Wrapper for pool account data with helper methods.
#### Properties
- address - Pool public keyaprPercent
- - APR as percentage string (e.g., "10.00")currentSupply
- - Current TVL (human-readable)maxSupply
- - Maximum supply capepochIndex
- - Current epoch numberepochDuration
- - Epoch duration in millisecondsnextEpochDate
- - Date of next epochadapterType
- - Swap adapter type (Direct, OnRe, Jupiter, External)
Wrapper for position account data.
#### Properties
- status - Position status: "inactive", "queued", "farming", "unstaking", "unstaked", "claiming", "claimed"amount
- - Currently staked amountclaimableAmount
- - Rewards available to claimwithdrawableAmount
- - Amount ready to withdrawunstakingAmount
- - Amount in cooldowncanDeposit
- , canUnstake, canWithdraw, canClaim - Action availability
- Program ID: ELE6rYCZUaegWxVhWM4ef9pXZBAgGUVaVKkTbDvX6BMU`
- Network: Solana Mainnet
MIT