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.
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.
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.
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.
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.
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.
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.
KaminoPosition
Holdings
TokenAmounts
ShareData
StrategyHolder
WithdrawShares
A user’s share holdings in a specific strategy. interface KaminoPosition {
strategy : Address ;
shareMint : Address ;
sharesAmount : Decimal ;
strategyDex : Dex ;
}
Available and invested token values with USD valuations. type Holdings = {
available : TokenAmounts ;
availableUsd : Decimal ;
invested : TokenAmounts ;
investedUsd : Decimal ;
totalSum : Decimal ;
};
Pair of token quantities (A and B amounts). type TokenAmounts = {
a : Decimal ;
b : Decimal ;
};
Current share price with strategy balances. type ShareData = {
price : Decimal ;
balance : StrategyBalances ;
};
A wallet and its share count in a strategy. type StrategyHolder = {
holderPubkey : Address ;
amount : Decimal ;
};
Bundle of instructions for executing share withdrawals. closeSharesAtaIx is optional — it’s only returned when the withdrawal closes the entire position and the shares ATA can be cleaned up. type WithdrawShares = {
prerequisiteIxs : TransactionInstruction [];
withdrawIx : TransactionInstruction ;
closeSharesAtaIx ?: TransactionInstruction ;
};
Additional Resources