Skip to main content

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

BuilderDescription
initializeProtocolInitialize the protocol singleton
setProtocolPausePause/unpause the protocol
createVaultCreate a new vault
updateAllocationQueue allocation changes
applyAllocationUpdateValidate pending allocation state
pauseVaultPause/unpause a vault
registerDepositAddressRegister depositor escrow + position
processDepositVaultProcess a deposit through global reserve
withdrawVaultWithdraw proportional assets
rebalanceTrigger a rebalance
rebalanceSwapBegin / rebalanceSwapEndCross-mint swap pair
collectFeesCollect management fees
accruePointsTrigger points accrual
createDca / executeDca / updateDca / cancelDcaDCA operations
initGlobalAssetReserveCreate a reserve
setAllocationMarketReserveMap allocation to reserve
initVaultReservePositionCreate vault reserve position
refreshGlobalVaultValuationsOracle refresh
moveVaultReserveLiquiditySame-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