Skip to main content

Reading User Position Data

Retrieve user positions, balances, and transaction history using the Kamino SDK and API.
Historical vault data is only available via the API.
1

Get User Positions

Retrieves user share balances across all vaults. Uses the SDK to query the user’s positions in every vault they hold shares in.
Using the SDK requires a private RPC connection or the public rate-limited RPC endpoint.
getUserPositions
import { createSolanaRpc, address } from '@solana/kit';
import { KaminoManager } from '@kamino-finance/klend-sdk';

const manager = new KaminoManager(createSolanaRpc('https://api.mainnet-beta.solana.com'));

const user = address('EZC9wzVCvihCsCHEMGADYdsRhcpdRYWzSCZAVegSCfqY');
const userSharesAllVaults = await manager.getUserSharesBalanceAllVaults(user);

userSharesAllVaults.forEach((shares, vault) => {
  console.log(`User shares in ${vault}:`, shares);
});
View Code
2

Get User Vault Position

Retrieves user share balance and token value for a specific vault. Uses the SDK to calculate both shares held and their equivalent token amount.
getUserVaultPosition
import { createSolanaRpc, address } from '@solana/kit';
import { KaminoVault } from '@kamino-finance/klend-sdk';

const vault = new KaminoVault(
  createSolanaRpc('https://api.mainnet-beta.solana.com'), // RPC
  address('HDsayqAsDWy3QvANGqh2yNraqcD8Fnjgh73Mhb3WRS5E') // USDC vault
);

const user = address('EZC9wzVCvihCsCHEMGADYdsRhcpdRYWzSCZAVegSCfqY');

const shares = await vault.getUserShares(user);
const rate = await vault.getExchangeRate();

console.log({
  shares: shares.totalShares.toString(),
  tokens: shares.totalShares.mul(rate).toString(), // the user's position in tokens
});
View Code
3

Get User Vault Transactions

Queries transaction history for a specific user and vault over a time range. Returns time-series data including position changes and transaction details.
getUserVaultTransactions
const kvaultPubkey = 'A2wsxhA7pF4B2UKVfXocb6TAAP9ipfPJam6oMKgDE5BK';
const ownerPubkey = '883AnESJiUVzCnwowgaWCpXp4EGsK4JMVzUUUcjSSs62'; // user

const API_BASE_URL = 'https://api.kamino.finance';

const params = new URLSearchParams({
  start: '2024-01-01T00:00:00.000Z',
  end: '2025-10-01T00:00:00.000Z',
}).toString();

const url = `${API_BASE_URL}/kvaults/users/${ownerPubkey}/vaults/${kvaultPubkey}/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,
    sharesAmount: item.sharesAmount,
    usdAmount: item.usdAmount,
    cumulativeInterestEarnedUsd: item.cumulativeInterestEarnedUsd,
  });
}
View Code
4

Get User Total Metrics History

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 address

const 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,
  });
}
View Code
5

Get User Vault Metrics History

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 address
const ownerPubkey = 'AxqtG9SHDkZTLSWg81Sp7VqAzQpRqXtR9ziJ3VQAS8As'; // user address

const 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,
  });
}
View Code
6

Get User Vault PnL

Retrieves current profit and loss data for a user’s position in a specific vault. Returns PnL metrics in USD, SOL, and token denominations.
getUserVaultPnL
const kvaultPubkey = 'HDsayqAsDWy3QvANGqh2yNraqcD8Fnjgh73Mhb3WRS5E'; // vault address
const ownerPubkey = 'AxqtG9SHDkZTLSWg81Sp7VqAzQpRqXtR9ziJ3VQAS8As'; // user address

const API_BASE_URL = 'https://api.kamino.finance';

const url = `${API_BASE_URL}/kvaults/${kvaultPubkey}/users/${ownerPubkey}/pnl`;
const res = await fetch(url);
if (!res.ok) {
  throw new Error(`Request failed: ${res.status} ${res.statusText}`);
}
const data = await res.json();

console.log({
  totalPnlUsd: data.totalPnl.usd,
  totalPnlSol: data.totalPnl.sol,
  totalPnlToken: data.totalPnl.token,
  totalCostBasisUsd: data.totalCostBasis.usd,
});
View Code
7

Get User Vault PnL History

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 address
const ownerPubkey = 'AxqtG9SHDkZTLSWg81Sp7VqAzQpRqXtR9ziJ3VQAS8As'; // user address

const 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,
  });
}
View Code

Additional Resources