SDK
@esec/sdk reference.
TypeScript client for the cascade-vault Anchor program. Deposit, withdraw, query vault state, subscribe to cycle receipts. Alpha; types stable, runtime API subject to refinement.
Install
npm install @esec/sdk @solana/web3.js @coral-xyz/anchorInitialize
import { EsecClient } from "@esec/sdk";
import { Connection, Keypair } from "@solana/web3.js";
const connection = new Connection("https://api.devnet.solana.com");
const wallet = Keypair.fromSecretKey(/* your secret */);
const cascade = new EsecClient({
connection,
wallet,
cluster: "devnet",
});Methods
deposit
await cascade.deposit({
asset: "SOL" | "USDC" | string, // mint symbol or pubkey
amount: number | bigint, // raw token units (lamports / 1e6 etc.)
});
// Returns: TransactionSignaturewithdraw
await cascade.withdraw({
asset: "SOL" | "USDC" | string,
lpAmount: number | bigint,
});
// Returns: TransactionSignaturegetVault
const vault = await cascade.getVault({ asset: "SOL" });
// Returns:
// {
// address: PublicKey,
// state: "Idle" | "Deployed",
// totalAssets: bigint,
// lpSupply: bigint,
// deployedAmount: bigint, // 0 when Idle
// deployPrice: bigint,
// deployedAtSlot: bigint,
// epochProfit: bigint,
// cumulativeProfit: bigint,
// cumulativeLoss: bigint,
// currentClusterSignal: { ... },
// }getClusters
const clusters = await cascade.getClusters({ asset: "SOL" });
// Returns: Cluster[]
// { triggerPriceLow, triggerPriceHigh, forcedSizeUsd, confidence, protocols }subscribeReceipts
const sub = cascade.subscribeReceipts((receipt) => {
// Fires on every PositionClosed event.
console.log(receipt);
// {
// asset: "SOL",
// deployPrice: 82.40,
// exitPrice: 84.10,
// deployedAmount: 12400e6,
// pnlSigned: 255.44e6,
// reason: "Recovery" | "StopLoss" | "Timeout",
// deploySlot: 312448855,
// exitSlot: 312448902,
// }
});
// Later: sub.unsubscribe();generateReceiptCard
const png = await cascade.generateReceiptCard(receipt);
// Returns: Buffer (1024x1024 PNG, ready to upload to X)
fs.writeFileSync("receipt.png", png);Anchor types
The full IDL is published at target/idl/cascade_vault.json and TypeScript types at target/types/cascade_vault.ts in the GitHub repo. The SDK re-exports these for direct Anchor consumption:
import type { CascadeVault } from "@esec/sdk/types";
import { Program } from "@coral-xyz/anchor";
const program = new Program<CascadeVault>(idl, provider);
// program.account.vault.fetch(...)
// program.methods.deposit(...).accounts({ ... }).rpc()