TypeScript SDK
The @oblivion/client package provides typed instruction builders, PDA helpers, and performance utilities for interacting with the Oblivion program.
Early Access
The SDK is not publicly available yet. To request access, contact us at oblivion@oblivion.id.
PDA Helpers
Derive program addresses for any account:
import {
protocolPda,
vaultPda,
depositorPositionPda,
globalAssetReservePda,
vaultReservePositionPda,
dcaSchedulePda,
depositAuthorityPda,
depositorPda,
} from '@oblivion/client'
const [protocol] = protocolPda()
const [vault] = vaultPda(1) // vault ID 1
const [position] = depositorPositionPda(vaultKey, ownerKey)
const [reserve] = globalAssetReservePda(usdcMint, 0) // reserve class 0
const [vrp] = vaultReservePositionPda(vaultKey, reserveKey)
const [dca] = dcaSchedulePda(vaultKey, ownerKey, 1) // schedule ID 1
Instruction Builders
All builders return Anchor method objects that you can .rpc() or pass to sendAnchorMethodWithPriorityFees:
import { createVault, registerDepositAddress, processDepositVault } from '@oblivion/client'
import { sendAnchorMethodWithPriorityFees } from '@oblivion/client'
// Create a vault
const method = createVault(program, {
name: 'My Strategy',
description: 'Balanced DeFi portfolio',
allocations: [
{ mint: usdcMint, targetWeightBps: 6000, strategy: { idle: {} } },
{ mint: solMint, targetWeightBps: 4000, strategy: { idle: {} } },
],
rebalanceThresholdBps: 500,
rebalanceCadence: { monthly: {} },
curatorFeeShareBps: 8000,
maxSlippageBps: 100,
usdcMint,
curator: wallet.publicKey,
shareMint: shareMintKeypair.publicKey,
vault: vaultKeypair.publicKey,
vaultAuthority: vaultAuthorityPda(vaultKeypair.publicKey)[0],
})
const sig = await sendAnchorMethodWithPriorityFees(connection, wallet, method)
Available Builders
| Builder | Description |
|---|---|
initializeProtocol | Initialize the protocol singleton |
setProtocolPause | Pause/unpause the protocol |
createVault | Create a new vault |
updateAllocation | Queue allocation changes |
applyAllocationUpdate | Validate pending allocation state |
pauseVault | Pause/unpause a vault |
registerDepositAddress | Register depositor escrow + position |
processDepositVault | Process a deposit through global reserve |
withdrawVault | Withdraw proportional assets |
rebalance | Trigger a rebalance |
rebalanceSwapBegin / rebalanceSwapEnd | Cross-mint swap pair |
collectFees | Collect management fees |
accruePoints | Trigger points accrual |
createDca / executeDca / updateDca / cancelDca | DCA operations |
initGlobalAssetReserve | Create a reserve |
setAllocationMarketReserve | Map allocation to reserve |
initVaultReservePosition | Create vault reserve position |
refreshGlobalVaultValuations | Oracle refresh |
moveVaultReserveLiquidity | Same-mint reserve transfer |
Transaction Helpers
The SDK provides simulation-first transaction sending with automatic compute unit sizing:
import { sendAnchorMethodWithPriorityFees } from '@oblivion/client'
const sig = await sendAnchorMethodWithPriorityFees(
connection,
wallet,
method,
{
priorityFeeMicroLamports: 5000, // optional fixed fee
computeUnitMarginBps: 1500, // 15% margin over simulated CU
}
)
Performance Helpers
Calculate vault and position metrics:
import {
sharePrice,
positionValueUsd,
allTimeReturn,
annualizedReturn,
realizedPnl,
unrealizedPnl,
} from '@oblivion/client'
const price = sharePrice(vault) // USD per share
const value = positionValueUsd(vault, position) // position value in USD
const returnPct = allTimeReturn(vault) // total return %
const irr = annualizedReturn(vault) // annualized return %
RPC Pool
Multi-endpoint RPC with automatic failover:
import { RpcPool, parseRpcUrls } from '@oblivion/client'
const urls = parseRpcUrls('https://rpc1.example.com,https://rpc2.example.com')
const pool = new RpcPool(urls)
const connection = pool.getConnection() // random healthy endpoint