bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 48쪽
for multiple product identifier addresses in a single request.
# Register a new vault with its on-chain LUT
Source: https://kamino.com/docs/build/lookup-tables/register-a-new-vault-with-its-on-chain-lut
/kamino-api.json post /luts/managed/new-vault
Verifies the vault and LUT exist on-chain, then registers the vault product and LUT entry. Private (authorized) API access only, please add a basic auth header to your request.
# Get cumulative wallet Multiply earnings history
Source: https://kamino.com/docs/build/multiply/get-cumulative-wallet-multiply-earnings-history
/kamino-api.json get /owners/{pubkey}/multiply/pnl/history
UTC cumulative daily or ISO-week points. The generation parameter is internal-only. Controlled by an off, internal, or on gate.
# Get lifetime wallet Multiply earnings
Source: https://kamino.com/docs/build/multiply/get-lifetime-wallet-multiply-earnings
/kamino-api.json get /owners/{pubkey}/multiply/pnl
Cumulative native earnings over Multiply and MultiplyFixedRate lifecycles. Controlled by an off, internal, or on gate. The generation parameter is internal-only.
# Get filtered owner net value history
Source: https://kamino.com/docs/build/other/get-filtered-owner-net-value-history
/kamino-api.json get /owners/{pubkey}/net-values/history/filtered
USD interval net revenue of selected products; distinct from Multiply SOL-basis earnings at /owners/{wallet}/multiply/pnl.
# Get Kamino oracle prices
Source: https://kamino.com/docs/build/other/get-kamino-oracle-prices
/kamino-api.json get /oracles/prices
Fetches all oracle prices for all public Klend Market assets
# Get owner net value history
Source: https://kamino.com/docs/build/other/get-owner-net-value-history
/kamino-api.json get /owners/{pubkey}/net-values/history
Fetches the historical USD values for an owner across all Kamino products — Lending, Strategies, Vaults, and Staking.
# Get recent Solana slot duration
Source: https://kamino.com/docs/build/other/get-recent-solana-slot-duration
/kamino-api.json get /slots/duration
Fetches the duration of a recent Solana slot (in milliseconds) derived from RPC performance samples over approximately the last hour
# Get SOFR rate history
Source: https://kamino.com/docs/build/other/get-sofr-rate-history
/kamino-api.json get /benchmark-rates/sofr/history
Returns daily SOFR rates published by the New York Fed from 2023 onwards, including the compounded SOFR index and 30/90/180-day compounded averages. The rate can be null for the latest date because the index is published one business day ahead of the rate. Supports filtering by date range (whole days, inclusive).
# Get Solana epochs metadata
Source: https://kamino.com/docs/build/other/get-solana-epochs-metadata
/kamino-api.json get /epochs
Fetches all epoch start and end times, first/last slot numbers, and epoch identifiers
# Get USD benchmark lending rates
Source: https://kamino.com/docs/build/other/get-usd-benchmark-lending-rates
/kamino-api.json get /benchmark-rates/usd
Returns USD benchmark lending rates aggregated across multiple protocols. Data is sourced from Allez and cached. Supports filtering by date range and downsampling by frequency.
# Get pending farm rewards for a wallet
Source: https://kamino.com/docs/build/portfolio/get-pending-farm-rewards-for-a-wallet
/kamino-api.json get /portfolio/{pubkey}/rewards
Returns pending farm reward source rows across Kamino products. USD reward totals are composed on the client from price data.
# Get portfolio source data for a wallet
Source: https://kamino.com/docs/build/portfolio/get-portfolio-source-data-for-a-wallet
/kamino-api.json get /portfolio/{pubkey}
Returns source position rows across Kamino products (lending, multiply, leverage, liquidity, earn, private credit, staking). Portfolio totals, counts, fees, historical PnL, and display-only rollups are intentionally left to client composition or their dedicated endpoints.
# Get token USD price history
Source: https://kamino.com/docs/build/prices/get-token-usd-price-history
/kamino-api.json get /v2/prices/{mint}/history
Returns one unrounded spot price in USD per bucket, preferring the most recently observed spot token ID throughout the request and filling its missing buckets from other spot IDs. Timestamps are bucket starts; gaps are possible. Start is inclusive and defaults to full history; end is exclusive and defaults to now.
# Get private credit metrics
Source: https://kamino.com/docs/build/private-credit/get-private-credit-metrics
/kamino-api.json get /kvaults/private-credit/metrics
Returns current aggregate metrics and active loans for private credit vaults
# Get private credit metrics history
Source: https://kamino.com/docs/build/private-credit/get-private-credit-metrics-history
/kamino-api.json get /kvaults/private-credit/metrics/history
Returns timeseries of private credit metrics. Frequency is automatically selected based on date range.
# Borrow with the API
Source: https://kamino.com/docs/build/recipes/borrow/borrow-via-api
The API generates the unsigned transaction, and the client signs it securely
Borrow assets from a Kamino reserve using the API. The API builds the transaction, and you sign it locally keeping your keys secure.
## Borrow via the API
<Steps>
<Step>
### Import Dependencies
Import the required packages for Solana RPC communication, transaction handling, and Kamino SDK utilities.
```typescript theme={null}
import {
createSolanaRpc,
createSolanaRpcSubscriptions,
getTransactionDecoder,
getCompiledTransactionMessageDecoder,
decompileTransactionMessageFetchingLookupTables,
pipe,
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
addSignersToTransactionMessage,
signTransactionMessageWithSigners,
sendAndConfirmTransactionFactory,
getSignatureFromTransaction,
} from '@solana/kit';
import { parseKeypairFile } from '@kamino-finance/klend-sdk/dist/utils/signer';
```
</Step>
<Step>
### Configure and Initialize
Set up the configuration and initialize RPC connections.
```typescript theme={null}
const KEYPAIR_FILE = '/path/to/your/keypair.json';
const API_BASE_URL = 'https://api.kamino.finance';
const RPC_ENDPOINT = 'https://api.mainnet-beta.solana.com';
const WS_ENDPOINT = 'wss://api.mainnet-beta.solana.com';
const MAIN_MARKET = '7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF';
const SOL_RESERVE = 'd4A2prbA2whesmvHaL88BH6Ewn5N4bTSU2Ze8P6Bc4Q';
const signer = await parseKeypairFile(KEYPAIR_FILE);
const rpc = createSolanaRpc(RPC_ENDPOINT);
const rpcSubscriptions = createSolanaRpcSubscriptions(WS_ENDPOINT);
```
</Step>
<Step>
### Call the Kamino API
Make a POST request to the Kamino API to build the borrow transaction.
```typescript theme={null}
const res = await fetch(`${API_BASE_URL}/ktx/klend/borrow`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
wallet: signer.address,
market: MAIN_MARKET,
reserve: SOL_RESERVE,
amount: '0.02',
}),
});
const data = await res.json();
if (!res.ok) {
console.error('Response error:', data);
}
const encodedTransaction = data.transaction;
```
<Info>
The API returns a pre-built transaction encoded in base64 format ready for signing.
</Info>
</Step>
<Step>
### Decode Transaction
Decode the base64-encoded transaction and extract the message bytes.
```typescript theme={null}
const txBuffer = Buffer.from(encodedTransaction, 'base64');
const txMessageBytes = getTransactionDecoder().decode(txBuffer).messageBytes;
const compiledMessage = getCompiledTransactionMessageDecoder().decode(txMessageBytes);
```
</Step>
<Step>
### Resolve Address Lookup Tables and Sign
Fetch the latest blockhash, decompile the transaction to resolve Address Lookup Tables, and sign.
```typescript theme={null}
const { value: latestBlockhash } = await rpc.getLatestBlockhash({
commitment: 'finalized'
}).send();
const signedTransaction = await pipe(
await decompileTransactionMessageFetchingLookupTables(compiledMessage, rpc),
tx => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
tx => setTransactionMessageFeePayerSigner(signer, tx),
tx => addSignersToTransactionMessage([signer], tx),
tx => signTransactionMessageWithSigners(tx)
);
const signature = getSignatureFromTransaction(signedTransaction);
```
<Info>
`decompileTransactionMessageFetchingLookupTables` fetches the lookup table data from the blockchain and resolves all address references. This is required for transactions that use ALTs.
</Info>
</Step>
<Step>
### Send and Confirm Transaction
Submit the signed transaction to the Solana network.
```typescript theme={null}
const sendAndConfirm = sendAndConfirmTransactionFactory({
rpc,
rpcSubscriptions,
});
await sendAndConfirm(signedTransaction, {
commitment: 'confirmed',
skipPreflight: false,
});
console.log('Borrow successful! Signature:', signature);
```
<Check>
Your borrow is complete! The API built the transaction, you signed it locally (keeping your keys secure), and it was successfully submitted to the network.
</Check>
</Step>
</Steps>
# Deposit with the API
Source: https://kamino.com/docs/build/recipes/borrow/deposit-via-api
The API generates the unsigned transaction, and the client signs it securely
Deposit collateral into a Kamino reserve using the API. The API builds the transaction, and you sign it locally keeping your keys secure.
## Deposit via the API
<Steps>
<Step>
### Import Dependencies
Import the required packages for Solana RPC communication, transaction handling, and Kamino SDK utilities.
```typescript theme={null}
import {
createSolanaRpc,
createSolanaRpcSubscriptions,
getTransactionDecoder,
getCompiledTransactionMessageDecoder,
decompileTransactionMessageFetchingLookupTables,
pipe,
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
addSignersToTransactionMessage,
signTransactionMessageWithSigners,
sendAndConfirmTransactionFactory,
getSignatureFromTransaction,
} from '@solana/kit';
import { parseKeypairFile } from '@kamino-finance/klend-sdk/dist/utils/signer';
```
</Step>
<Step>
### Configure and Initialize
Set up the configuration and initialize RPC connections.
```typescript theme={null}
const KEYPAIR_FILE = '/path/to/your/keypair.json';
const API_BASE_URL = 'https://api.kamino.finance';
const RPC_ENDPOINT = 'https://api.mainnet-beta.solana.com';
const WS_ENDPOINT = 'wss://api.mainnet-beta.solana.com';
const MAIN_MARKET = '7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF';
const CASH_RESERVE = 'ApQkX32ULJUzszZDe986aobLDLMNDoGQK8tRm6oD6SsA';
const signer = await parseKeypairFile(KEYPAIR_FILE);
const rpc = createSolanaRpc(RPC_ENDPOINT);
const rpcSubscriptions = createSolanaRpcSubscriptions(WS_ENDPOINT);
```
</Step>
<Step>
### Call the Kamino API
Make a POST request to the Kamino API to build the deposit transaction.
```typescript theme={null}
const res = await fetch(`${API_BASE_URL}/ktx/klend/deposit`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
wallet: signer.address,
market: MAIN_MARKET,
reserve: CASH_RESERVE,
amount: '2.0',
}),
});
const data = await res.json();
if (!res.ok) {
console.error('Response error:', data);
}
const encodedTransaction = data.transaction;
```
<Info>
The API returns a pre-built transaction encoded in base64 format ready for signing.
</Info>
</Step>
<Step>
### Decode Transaction
Decode the base64-encoded transaction and extract the message bytes.
```typescript theme={null}
const txBuffer = Buffer.from(encodedTransaction, 'base64');
const txMessageBytes = getTransactionDecoder().decode(txBuffer).messageBytes;
const compiledMessage = getCompiledTransactionMessageDecoder().decode(txMessageBytes);
```
</Step>
<Step>
### Resolve Address Lookup Tables and Sign
Fetch the latest blockhash, decompile the transaction to resolve Address Lookup Tables, and sign.
```typescript theme={null}
const { value: latestBlockhash } = await rpc.getLatestBlockhash({
commitment: 'finalized'
}).send();
const signedTransaction = await pipe(
await decompileTransactionMessageFetchingLookupTables(compiledMessage, rpc),
tx => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
tx => setTransactionMessageFeePayerSigner(signer, tx),
tx => addSignersToTransactionMessage([signer], tx),
tx => signTransactionMessageWithSigners(tx)
);
const signature = getSignatureFromTransaction(signedTransaction);
```
<Info>
`decompileTransactionMessageFetchingLookupTables` fetches the lookup table data from the blockchain and resolves all address references. This is required for transactions that use ALTs.
</Info>
</Step>
<Step>
### Send and Confirm Transaction
Submit the signed transaction to the Solana network.
```typescript theme={null}
const sendAndConfirm = sendAndConfirmTransactionFactory({
rpc,
rpcSubscriptions,
});
await sendAndConfirm(signedTransaction, {
commitment: 'confirmed',
skipPreflight: false,
});
console.log('Success! Signature:', signature);
```
<Check>
Your deposit is complete! The API built the transaction, you signed it locally (keeping your keys secure), and it was successfully submitted to the network.
</Check>
</Step>
</Steps>
# Get Market Reserve APYs
Source: https://kamino.com/docs/build/recipes/borrow/get-market-reserve-apys
Fetch Kamino market reserve borrow and supply APY data using the API or SDK
## Borrow & Supply APY Calculation
A reserve is a single asset lending pool within a market. All deposits of an asset enter the same reserve, and all borrowing draws from that pool.
Variable rates are driven by utilization, the fraction of deposits currently borrowed:
```
Utilization = Borrowed / Total Deposited
```
As utilization increases, borrow rates rise. As utilization decreases, borrow rates fall.
Supply APY is derived from borrower interest and depends on both the borrow rate and utilization:
```
Supply APY ≈ Borrow Rate × Utilization × (1 − Protocol Spread)
```
Not all deposited capital is borrowed at any given time, so supply APY is always lower than the borrow rate. Higher utilization means more of the pool is earning interest, which increases lender yield.
Reserves are isolated pools. The same asset in different markets has different borrowers, collateral, and risk profiles, and therefore different rates.
<Tabs>
<Tab title="API">
<Steps>
<Step>
### Fetch All Markets
Retrieve the list of all lending markets on Kamino.
```typescript theme={null}
const API_BASE_URL = 'https://api.kamino.finance';
const response = await fetch(`${API_BASE_URL}/v2/kamino-market`);
const markets = await response.json();
```
<Info>
The `/v2/kamino-market` endpoint returns all lending markets including SOL/BTC Market, JLP Market, Altcoins Market, and Prime Market.
</Info>
</Step>
<Step>
### Get Reserve APYs for Each Market
For each market, fetch the APY metrics for all reserves (USDC, SOL, wETH, etc.).
```typescript theme={null}
const allMarketReserves = await Promise.all(
markets.map(async (market) => {
const response = await fetch(
`${API_BASE_URL}/kamino-market/${market.lendingMarket}/reserves/metrics`
);
const reserves = await response.json();
return { market, reserves };
})
);
allMarketReserves.forEach(({ market, reserves }) => {
console.log(`\n${market.name}:`);
reserves.forEach((reserve) => {
console.log(`\n${reserve.liquidityToken}:`);
console.log(` Supply APY: ${(reserve.supplyApy * 100).toFixed(2)}%`);
console.log(` Borrow APY: ${(reserve.borrowApy * 100).toFixed(2)}%`);
console.log(` Total Deposits: $${reserve.totalSupplyUsd}`);
console.log(` Total Borrowed: $${reserve.totalBorrowUsd}`);
});
});
```
<Info>
The `/kamino-market/{pubkey}/reserves/metrics` endpoint returns comprehensive metrics for each reserve including APYs, total deposits, and borrows.
</Info>
</Step>
</Steps>
</Tab>
<Tab title="SDK">
<Steps>
<Step>
### Import Dependencies
Import the required packages for Solana RPC communication and Kamino SDK.
```typescript theme={null}
import { createSolanaRpc } from '@solana/kit';
import { address } from '@solana/kit';
import { KaminoMarket, DEFAULT_RECENT_SLOT_DURATION_MS } from '@kamino-finance/klend-sdk';
```
</Step>
<Step>
### Get Current Slot
Fetch the current Solana slot (block number) for APY calculations.
```typescript theme={null}
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
const slot = await rpc.getSlot().send();
console.log(`Current slot: ${slot}`);
```
<Info>
**What is a slot?**
A slot is Solana's block number — like a timestamp but for blockchain state. The SDK uses it to calculate APY based on the current on-chain state. Think of it as "calculate APY as of right now."
</Info>
</Step>
<Step>
### Load a Market
Load a specific lending market using its public key.
```typescript theme={null}
const marketAddress = address('7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF');
const market = await KaminoMarket.load(rpc, marketAddress, DEFAULT_RECENT_SLOT_DURATION_MS);
```
</Step>
<Step>
### Get All Reserves
Retrieve all reserves (asset pools) in the market.
```typescript theme={null}
const reserves = market.getReserves();
```
</Step>
<Step>
### Calculate APYs for Each Reserve
Loop through each reserve and calculate its borrow and supply APYs.
```typescript theme={null}
for (const reserve of reserves) {
// Get the reserve's token symbol
const symbol = reserve.stats.symbol || reserve.stats.mintAddress.toString().slice(0, 8);
// Calculate APYs using current slot (convert to percentage form)
const borrowAPY = reserve.totalBorrowAPY(slot) * 100;
const supplyAPY = reserve.totalSupplyAPY(slot) * 100;
// Get additional metrics (utilization as a percentage)
const utilization = reserve.calculateUtilizationRatio();
const totalDeposits = reserve.getDepositTvl();
const totalBorrows = reserve.getBorrowTvl();
console.log(`\n${symbol}:`);
console.log(` Supply APY: ${supplyAPY.toFixed(2)}%`);
console.log(` Borrow APY: ${borrowAPY.toFixed(2)}%`);
console.log(` Utilization: ${utilization.toFixed(2)}%`);
console.log(` Total Deposits: ${totalDeposits.toFixed(2)}`);
console.log(` Total Borrowed: ${totalBorrows.toFixed(2)}`);
}
```
<Info>
The `reserve.totalBorrowAPY(slot)` and `reserve.totalSupplyAPY(slot)` methods calculate APY based on the current interest rate, utilization, and compounding frequency at the specified slot.
</Info>
<Check>
You've successfully calculated borrow and supply APYs across all reserves using the Kamino SDK.
</Check>
</Step>
</Steps>
</Tab>
</Tabs>
# Repay with the API
Source: https://kamino.com/docs/build/recipes/borrow/repay-via-api
The API generates the unsigned transaction, and the client signs it securely
Repay borrowed assets into a Kamino reserve using the API. The API builds the transaction, and you sign it locally keeping your keys secure.
## Repay via the API
<Steps>
<Step>
### Import Dependencies
Import the required packages for Solana RPC communication, transaction handling, and Kamino SDK utilities.
```typescript theme={null}
import {
createSolanaRpc,
createSolanaRpcSubscriptions,
getTransactionDecoder,
getCompiledTransactionMessageDecoder,
decompileTransactionMessageFetchingLookupTables,
pipe,
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
addSignersToTransactionMessage,
signTransactionMessageWithSigners,
sendAndConfirmTransactionFactory,
getSignatureFromTransaction,
} from '@solana/kit';
import { parseKeypairFile } from '@kamino-finance/klend-sdk';
```
</Step>
<Step>
### Configure and Initialize
Set up the configuration and initialize RPC connections.
```typescript theme={null}
const KEYPAIR_FILE = '/path/to/your/keypair.json';
const API_BASE_URL = 'https://api.kamino.finance';
const RPC_ENDP프로젝트로 돌아가기