Skip to main content

Documentation Index

Fetch the complete documentation index at: https://kamino.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

Reading User Position Data

Retrieve user holdings, profit and loss, fees and rewards, and transaction history using the Kamino API.
Historical user data is only available via the API. For the TypeScript shapes returned by the methods below, see Position Types.

Get User Positions

Live read of a wallet’s positions with USD value calculated from each strategy’s share price.
getUserPositions
import { createSolanaRpc, address } from '@solana/kit';
import { Kamino } from '@kamino-finance/kliquidity-sdk';

const RPC_ENDPOINT = 'https://api.mainnet-beta.solana.com';
const WALLET = address('YOUR_WALLET_ADDRESS'); // user address

const rpc = createSolanaRpc(RPC_ENDPOINT);
const kamino = new Kamino('mainnet-beta', rpc);

const positions = await kamino.getUserPositions(WALLET);

console.log(`Wallet: ${WALLET}`);
console.log(`Positions: ${positions.length}`);

for (const p of positions) {
  const shareData = await kamino.getStrategyShareData(p.strategy);
  const usdValue = p.sharesAmount.mul(shareData.price);
  console.log({
    strategy: p.strategy.toString(),
    dex: p.strategyDex,
    shareMint: p.shareMint.toString(),
    sharesAmount: p.sharesAmount.toString(),
    sharePriceUsd: shareData.price.toString(),
    valueUsd: usdValue.toString(),
  });
}
View Code

Get User PnL

Returns current profit and loss data for a user’s position in a specific strategy. Returns USD, SOL, and token denominations.
getUserPnl
const strategyPubkey = '2H4xebnp2M9JYgPPfUw58uUQahWF8f1YTNxwwtmdqVYV'; // strategy address
const walletPubkey = 'YOUR_WALLET_ADDRESS'; // user address

const url = `https://api.kamino.finance/v2/strategies/${strategyPubkey}/shareholders/${walletPubkey}/pnl?env=mainnet-beta`;
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

Get User PnL History

Returns time-series PnL snapshots for charting a user’s position over time.
getUserPnlHistory
const strategyPubkey = '2H4xebnp2M9JYgPPfUw58uUQahWF8f1YTNxwwtmdqVYV'; // strategy address
const walletPubkey = 'YOUR_WALLET_ADDRESS'; // user address

const url = `https://api.kamino.finance/v2/strategies/${strategyPubkey}/shareholders/${walletPubkey}/pnl/history?env=mainnet-beta`;
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,
    positionValueUsd: item.positionValue?.usd,
  });
}
View Code

Get User Fees and Rewards

Returns cumulative fees and rewards earned by the user in a specific strategy.
getUserFeesAndRewards
const strategyPubkey = '2H4xebnp2M9JYgPPfUw58uUQahWF8f1YTNxwwtmdqVYV'; // strategy address
const walletPubkey = 'YOUR_WALLET_ADDRESS'; // user address

const url = `https://api.kamino.finance/strategies/${strategyPubkey}/shareholders/${walletPubkey}/fees-and-rewards?env=mainnet-beta`;
const res = await fetch(url);
if (!res.ok) {
  throw new Error(`Request failed: ${res.status} ${res.statusText}`);
}
const data = await res.json();

console.log(data);
View Code

Get User Rewards History

Returns historical rewards earned by a wallet across all strategies.
getUserRewardsHistory
const walletPubkey = 'YOUR_WALLET_ADDRESS'; // user address

const url = `https://api.kamino.finance/strategies/shareholders/${walletPubkey}/rewards/history?env=mainnet-beta`;
const res = await fetch(url);
if (!res.ok) {
  throw new Error(`Request failed: ${res.status} ${res.statusText}`);
}
const data = await res.json();

console.log(data);
View Code

Get User Transactions

Deposit, withdrawal, and claim transaction history for a wallet across all strategies.
getUserTransactions
const walletPubkey = 'YOUR_WALLET_ADDRESS'; // user address

const url = `https://api.kamino.finance/v2/shareholders/${walletPubkey}/transactions?env=mainnet-beta`;
const res = await fetch(url);
if (!res.ok) {
  throw new Error(`Request failed: ${res.status} ${res.statusText}`);
}
const data = await res.json();

for (const tx of data.transactions) {
  console.log({
    timestamp: tx.timestamp,
    type: tx.type,
    strategy: tx.strategy,
    amountUsd: tx.amountUsd,
  });
}
View Code

Position Types

TypeScript shapes returned by the Kliquidity SDK for user position reads.
A user’s share holdings in a specific strategy.
interface KaminoPosition {
  strategy: Address;
  shareMint: Address;
  sharesAmount: Decimal;
  strategyDex: Dex;
}

Additional Resources

API Examples

SDK Examples