@wzrd_sol/sdk
v0.1.2
Published
TypeScript SDK for the WZRD Liquid Attention Protocol — deposit, settle, claim on Solana
Maintainers
Readme
@wzrd_sol/sdk
TypeScript SDK for the Liquid Attention Protocol on Solana.
Builds deposit_market, settle_market, and claim_global transaction instructions that wallets sign directly — no server signing needed.
Install
npm install @wzrd_sol/sdk @solana/web3.jsExample Scripts
From the repo root:
npm run build --workspace=sdk
npm run typecheck:examples --workspace=sdkRunnable examples:
npm run example:deposit --workspace=sdknpm run example:claim --workspace=sdk
Both examples expect:
SOLANA_RPC_URLWZRD_KEYPAIR_PATH
The deposit example also expects:
WZRD_MARKET_IDWZRD_DEPOSIT_USDC
Quick Reference
PDA Derivation
import {
getProtocolStatePDA,
getMarketVaultPDA,
getUserPositionPDA,
getGlobalRootConfigPDA,
getClaimStatePDA,
PROGRAM_ID,
} from '@wzrd_sol/sdk';
const protocolState = getProtocolStatePDA();
const marketVault = getMarketVaultPDA(protocolState, 6); // market ID 6
const position = getUserPositionPDA(marketVault, walletPubkey);Deposit USDC → Receive vLOFI
import { Connection, Keypair, VersionedTransaction, TransactionMessage } from '@solana/web3.js';
import { createDepositMarketIx } from '@wzrd_sol/sdk';
const connection = new Connection('https://api.mainnet-beta.solana.com');
const wallet = Keypair.fromSecretKey(/* your key */);
// Build instructions for a 1 USDC deposit into market 6
const ixs = await createDepositMarketIx(connection, wallet.publicKey, 6, 1_000_000n);
const { blockhash } = await connection.getLatestBlockhash();
const message = new TransactionMessage({
payerKey: wallet.publicKey,
recentBlockhash: blockhash,
instructions: ixs,
}).compileToV0Message();
const tx = new VersionedTransaction(message);
tx.sign([wallet]);
const sig = await connection.sendTransaction(tx);
console.log('Deposit tx:', sig);Claim CCM via Merkle Proof
import { createClaimGlobalIx } from '@wzrd_sol/sdk';
// Fetch proof from the server API
const res = await fetch(`https://api.twzrd.xyz/v1/claims/${wallet.publicKey.toBase58()}`);
const { root_seq, cumulative_total, proof } = await res.json();
const ixs = await createClaimGlobalIx(
connection,
wallet.publicKey,
root_seq,
BigInt(cumulative_total),
proof, // hex-encoded [u8; 32] nodes
);
// Build, sign, send as aboveSettle a Matured Position
import { createSettleMarketIx } from '@wzrd_sol/sdk';
const ixs = await createSettleMarketIx(connection, wallet.publicKey, 6);
// Build, sign, send as abovesettle_market returns USDC from reserve and burns vLOFI. It does not mint CCM; CCM is claimed via merkle proof (claim_global / claim_global_v2).
Read On-Chain State
import { fetchMarketVault, fetchOnChainPosition, fetchTokenBalance } from '@wzrd_sol/sdk';
const vault = await fetchMarketVault(connection, 6);
console.log('Total deposited:', vault?.totalDeposited);
const pos = await fetchOnChainPosition(connection, wallet.publicKey, 6);
console.log('My deposit:', pos?.depositedAmount, 'Multiplier:', pos?.attentionMultiplierBps);Exports
Constants
| Export | Description |
|--------|-------------|
| PROGRAM_ID | Mainnet program ID (GnGz...) |
| DEVNET_PROGRAM_ID | Devnet program ID (GmGX...) |
| TOKEN_PROGRAM_ID | SPL Token program |
| TOKEN_2022_PROGRAM_ID | Token-2022 program (CCM uses this) |
PDA Derivation
| Function | Seeds |
|----------|-------|
| getProtocolStatePDA() | ["protocol_state"] |
| getMarketVaultPDA(protocolState, marketId) | ["market_vault", protocolState, marketId] |
| getUserPositionPDA(marketVault, user) | ["market_position", marketVault, user] |
| getGlobalRootConfigPDA(ccmMint) | ["global_root", ccmMint] |
| getClaimStatePDA(ccmMint, claimer) | ["claim_global", ccmMint, claimer] |
Instruction Builders
| Function | On-chain instruction |
|----------|---------------------|
| createDepositMarketIx(conn, user, marketId, amount) | deposit_market |
| createSettleMarketIx(conn, user, marketId) | settle_market |
| createClaimGlobalIx(conn, claimer, rootSeq, total, proof) | claim_global |
| createInitializeMarketVaultIx(admin, marketId, ...) | initialize_market_vault |
Account Parsers
| Function | Account type |
|----------|-------------|
| parseMarketVault(data) | MarketVault |
| parseProtocolState(data) | ProtocolState |
| parseUserMarketPosition(data) | UserMarketPosition |
| fetchMarketVault(conn, marketId) | Fetch + parse |
| fetchOnChainPosition(conn, user, marketId) | Fetch + parse |
| fetchTokenBalance(conn, ata) | Raw token balance |
Key Addresses
| Asset | Mint | Token Program |
|-------|------|---------------|
| USDC | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v | SPL Token |
| vLOFI | E9Kt33axpCy3ve2PCY9BSrbPhcR9wdDsWQECAahzw2dS | SPL Token |
| CCM | Dxk8mAb3C7AM8JN6tAJfVuSja5yidhZM5sEKW3SRX2BM | Token-2022 |
