Read a user’s vault position with the kvault-interface crate: look up their share balance and value it in underlying tokens using the vault’s current exchange rate (AUM ÷ shares issued).
This only counts shares held in the user’s share ATA. If the vault has a share farm (VaultState::vault_farm is set), most users keep their shares staked in the farm, so a complete implementation must also read the staked balance from vault.vault_farm (Kamino Farms) and add it.
Queries transaction history for a specific user and vault over a time range. Returns time-series data including position changes and transaction details.
Queries cumulative performance metrics for a user across all vaults over a time range. Returns aggregated time-series data including total positions and earnings.
getUserTotalMetricsHistory
const ownerPubkey = 'AxqtG9SHDkZTLSWg81Sp7VqAzQpRqXtR9ziJ3VQAS8As'; // user addressconst API_BASE_URL = 'https://api.kamino.finance';const params = new URLSearchParams({ start: '2024-01-01T00:00:00.000Z', end: '2025-11-20T00:00:00.000Z',}).toString();const url = `${API_BASE_URL}/kvaults/users/${ownerPubkey}/metrics/history?${params}`;const res = await fetch(url);if (!res.ok) { throw new Error(`Request failed: ${res.status} ${res.statusText}`);}const data = await res.json();for (const item of data) { console.log({ createdOn: item.createdOn, usdAmount: item.usdAmount, solAmount: item.solAmount, weightedApy: item.weightedApy, cumulativeInterestEarnedUsd: item.cumulativeInterestEarnedUsd, });}
Retrieves historical performance metrics for a specific user and vault. Returns time-series data including shares, APY, and cumulative interest earned.
getUserVaultMetricsHistory
const kvaultPubkey = 'HDsayqAsDWy3QvANGqh2yNraqcD8Fnjgh73Mhb3WRS5E'; // vault addressconst ownerPubkey = 'AxqtG9SHDkZTLSWg81Sp7VqAzQpRqXtR9ziJ3VQAS8As'; // user addressconst API_BASE_URL = 'https://api.kamino.finance';const url = `${API_BASE_URL}/kvaults/users/${ownerPubkey}/vaults/${kvaultPubkey}/metrics/history`;const res = await fetch(url);if (!res.ok) { throw new Error(`Request failed: ${res.status} ${res.statusText}`);}const data = await res.json();for (const item of data) { console.log({ createdOn: item.createdOn, sharesAmount: item.sharesAmount, apy: item.apy, cumulativeInterestEarnedUsd: item.cumulativeInterestEarnedUsd, });}
Queries historical profit and loss data for a user’s vault position. Returns transaction-level PnL history with cost basis, realized gains, and position values.
getUserVaultPnLHistory
const kvaultPubkey = 'HDsayqAsDWy3QvANGqh2yNraqcD8Fnjgh73Mhb3WRS5E'; // vault addressconst ownerPubkey = 'AxqtG9SHDkZTLSWg81Sp7VqAzQpRqXtR9ziJ3VQAS8As'; // user addressconst API_BASE_URL = 'https://api.kamino.finance';const url = `${API_BASE_URL}/kvaults/users/${ownerPubkey}/vaults/${kvaultPubkey}/pnl/history`;const res = await fetch(url);if (!res.ok) { throw new Error(`Request failed: ${res.status} ${res.statusText}`);}const data = await res.json();for (const item of data.history) { console.log({ timestamp: item.timestamp, pnlUsd: item.pnl?.usd, costBasisUsd: item.costBasis?.usd, positionValueUsd: item.positionValue?.usd, });}