bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 4쪽
t theme={null}
const txBuffer = Buffer.from(encodedTransaction, 'base64');
const txMessageBytes = getTransactionDecoder().decode(txBuffer).messageBytes;
const compiledMessage = getCompiledTransactionMessageDecoder().decode(txMessageBytes);
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)
);
if (!isTransactionWithinSizeLimit(signedTransaction)) {
throw new Error('Transaction exceeds size limit');
}
const signature = getSignatureFromTransaction(signedTransaction);
await sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions })(signedTransaction, {
commitment: 'confirmed',
skipPreflight: true,
});
console.log('Swap successful! Signature:', signature);
```
</Step>
</Steps>
# Get strategy fees and rewards
Source: https://kamino.com/docs/build/api-reference/liquidity/strategy-data/strategies-fees-and-rewards
kamino-extra-api.json GET /strategies/fees-and-rewards
Get fees and rewards earned across all strategies over a chosen time period.
# Get all strategies
Source: https://kamino.com/docs/build/api-reference/liquidity/strategy-data/strategies-list
kamino-extra-api.json GET /strategies
Get all Kamino Liquidity strategies with addresses, pool metadata, and status.
# Get total strategy TVL
Source: https://kamino.com/docs/build/api-reference/liquidity/strategy-data/strategies-tvl
kamino-extra-api.json GET /strategies/tvl
Get aggregate total value locked across all live Kamino Liquidity strategies.
# Get strategy metrics
Source: https://kamino.com/docs/build/api-reference/liquidity/strategy-data/strategy-metrics
kamino-extra-api.json GET /strategies/{pubkey}/metrics
Get real-time metrics for a specific strategy including share price, TVL, APY breakdown, and token balances.
# Get strategy historical metrics
Source: https://kamino.com/docs/build/api-reference/liquidity/strategy-data/strategy-metrics-history
kamino-extra-api.json GET /v2/strategies/{pubkey}/history
Get time-series data for a strategy including share price, TVL, fees, rewards, and token prices.
# Get user fees and rewards
Source: https://kamino.com/docs/build/api-reference/liquidity/user-data/user-fees-and-rewards
kamino-extra-api.json GET /strategies/{strategyPubkey}/shareholders/{walletPubkey}/fees-and-rewards
Get cumulative fees and rewards earned by a user in a specific strategy.
# Get user PnL
Source: https://kamino.com/docs/build/api-reference/liquidity/user-data/user-pnl
kamino-extra-api.json GET /v2/strategies/{strategyPubkey}/shareholders/{walletPubkey}/pnl
Get current profit and loss for a user position in a specific strategy.
# Get user PnL history
Source: https://kamino.com/docs/build/api-reference/liquidity/user-data/user-pnl-history
kamino-extra-api.json GET /v2/strategies/{strategyPubkey}/shareholders/{walletPubkey}/pnl/history
Get time-series PnL snapshots for a user position in a specific strategy.
# Get user rewards history
Source: https://kamino.com/docs/build/api-reference/liquidity/user-data/user-rewards-history
kamino-extra-api.json GET /strategies/shareholders/{walletPubkey}/rewards/history
Get historical rewards earned by a wallet across all Kamino Liquidity strategies.
# Get user transactions
Source: https://kamino.com/docs/build/api-reference/liquidity/user-data/user-transactions
kamino-extra-api.json GET /v2/shareholders/{walletPubkey}/transactions
Get deposit, withdrawal, and claim transaction history for a wallet across all strategies.
# Find Lookup Tables for addresses
Source: https://kamino.com/docs/build/api-reference/luts/find-minimal
kamino-api.json POST /luts/find-minimal
Finds the smallest set of Lookup Table (LUT) addresses that together cover all the provided Solana addresses. Optionally verifies active LUTs on-chain.
# Get managed LUTs for a product
Source: https://kamino.com/docs/build/api-reference/luts/managed
kamino-api.json GET /luts/managed
Returns active lookup table addresses associated with a given product identifier address.
# Get managed LUTs for multiple products
Source: https://kamino.com/docs/build/api-reference/luts/managed-batch
kamino-api.json GET /luts/managed/batch
Returns active lookup table addresses for multiple product identifier addresses in a single request.
# Get managed LUTs by product type
Source: https://kamino.com/docs/build/api-reference/luts/managed-product-type
kamino-api.json GET /luts/managed/product-type/{productType}
Returns all active lookup table addresses grouped by product for a given product type.
# Register a new vault with its on-chain LUT
Source: https://kamino.com/docs/build/api-reference/luts/new-vault
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 oracle prices
Source: https://kamino.com/docs/build/api-reference/oracle/oracle-prices
kamino-api.json GET /oracles/prices
Fetches all oracle prices for all public Klend Market assets
# Get token prices
Source: https://kamino.com/docs/build/api-reference/oracle/token-prices
kamino-extra-api.json GET /prices
Get the USD price for tokens tracked by Kamino, keyed by mint address and token symbol.
# Get token price history
Source: https://kamino.com/docs/build/api-reference/oracle/token-prices-history
kamino-extra-api.json GET /prices/history
Get the historical USD price for a token tracked by Kamino. Returns an array of `[price, timestamp]` pairs ordered oldest to newest, where `price` is the USD price as a string and `timestamp` is a Unix time in seconds.
# Get pending farm rewards for a wallet
Source: https://kamino.com/docs/build/api-reference/portfolio/portfolio-rewards
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/api-reference/portfolio/portfolio-source-data
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 farm management history
Source: https://kamino.com/docs/build/api-reference/rewards/farm-management-history
kamino-api.json GET /farms/{farmPubkey}/management-history
Get management instructions for a specific farm (with pagination).
# Get farm transactions
Source: https://kamino.com/docs/build/api-reference/rewards/farm-transactions
kamino-api.json GET /farms/{farmPubkey}/transactions
Get transactions for a specific farm (with pagination).
# Get user farm transactions
Source: https://kamino.com/docs/build/api-reference/rewards/user-transactions
kamino-api.json GET /farms/users/{pubkey}/transactions
Get all farms program transactions for a given user (with pagination).
# Get tokens
Source: https://kamino.com/docs/build/api-reference/tokens/token-list
kamino-extra-api.json GET /tokens-api/tokens
Get metadata and market data for tokens known to Kamino. Returns mint address, symbol, name, decimals, logo, verification status, 24-hour trading volume, and market cap. Without filters the endpoint returns the top 20 tokens by trading volume.
# Get Market Reserve APYs
Source: https://kamino.com/docs/build/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>
# Borrow Overview
Source: https://kamino.com/docs/build/borrow/index
<div>
<div>
<div>
<div>
<div>
<img alt="" />
<div>
# Borrow &<br />Lend
</div>
<div>
<p>
Integrate borrow and lending markets, and build leveraged positions with Multiply.
</p>
</div>
</div>
<div>
<div>
<div>
<div>
\$2.7B
</div>
<div>
Market Size
</div>
</div>
<div>
<div>
\$1B
</div>
<div>
Active Borrows
</div>
</div>
<div>
<div>
<Icon icon="circle-check" />
18+
</div>
<div>
Audits
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
## How It Works
<p>
A high-level view of the Borrow model.
</p>
</div>
<div>
<div>
<div>
<img alt="Deposit icon" />
</div>
### Deposit
<p>
User supplies collateral tokens. An obligation is created to track their position and enable borrowing capacity.
</p>
</div>
<div>
<div>
<img alt="Borrow icon" />
</div>
### Borrow
<p>
User borrows assets against collateral. LTV ratio determines borrow limit. Interest accrues on borrowed amount.
</p>
</div>
<div>
<div>
<img alt="Repay icon" />
</div>
### Repay
<p>
User repays borrowed assets plus interest. Reduces debt, improves health factor, and unlocks collateral for withdrawal.
</p>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
## Borrow Integration Model
<p>
Built for seamless integration. Borrow centers on three core layers of composability.
</p>
</div>
<div>
<div>
<a href="#bim-markets">Markets & Reserves</a>
<a href="#bim-transactions">Transactions</a>
<a href="#bim-positions">Positions & Health</a>
</div>
<div>
<div>
<img alt="Layer 1, Markets and Reserves: browse reserves to supply and borrow capital and understand each market's conditions before routing users" />
</div>
<div>
<img alt="Layer 2, Transactions: turn lending actions into signable flows, from account setup to obligation management and transaction construction" />
</div>
<div>
<img alt="Layer 3, Positions and Health: bring account health into focus across the borrow lifecycle to keep users within healthy borrowing ranges" />
</div>
</div>
</div>
<div>
<div>
<h3>Markets & Reserves</h3>
<p>Browse reserves to supply and borrow capital, and understand the conditions of each market before routing users.</p>
<p><span>Best Tools:</span> REST API, TypeScript SDK</p>
<p><span>Available Market Data:</span> supply APY, borrow APY, utilization, liquidity, market configuration, reserve metadata, reward farms, and bonus yield.</p>
</div>
<div>
<h3>Transactions</h3>
<p>Turn lending actions into signable flows, from account setup to obligation management and transaction construction.</p>
<p><span>Best Tools:</span> TypeScript SDK, REST API, Rust Interface Crate</p>
<p><span>Available Transaction Flows:</span> user account setup, obligation account creation, transaction construction, flash loans.</p>
</div>
<div>
<h3>Positions & Health</h3>
<p>Bring account health into focus across the borrow lifecycle, helping users stay within healthy borrowing ranges.</p>
<p><span>Best Tools:</span> TypeScript SDK, REST API</p>
<p><span>Available Position Data:</span> obligations, user PnL, portfolio value, collateral balances, debt balances, LTV, health factors, borrowing capacity, liquidation thresholds, and position history.</p>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
## Start Building
<p>
Explore guides, tutorials, and API references.
</p>
</div>
<div>
<a href="/docs/build/borrow/tutorials/deposit-and-borrow">
<div>
<Icon icon="book" />
</div>
### SDK Tutorials
<p>
Step-by-step guides for building with Kamino lending markets.
</p>
<div>
View Tutorials
<Icon icon="arrow-right" />
</div>
</a>
<a href="/docs/build/borrow/recipes/deposit-via-api">
<div>
<Icon icon="flask" />
</div>
### API Recipes
<p>
Quick code examples for common lending operations via API.
</p>
<div>
View Recipes
<Icon icon="arrow-right" />
</div>
</a>
<a href="/docs/build/borrow/tutorials/rust/deposit-and-borrow">
<div>
<Icon icon="crab" />
</div>
### Rust Tutorials
<p>
Deposit, borrow, repay, and withdraw using the klend-interface Rust crate.
</p>
<div>
View Tutorials
<Icon icon="arrow-right" />
</div>
</a>
<a href="/docs/build/borrow/multiply/leverage-concepts">
<div>
<Icon icon="chart-line-up" />
</div>
### Multiply Integration
<p>
Build leveraged positions with flash loans and swaps.
</p>
<div>
Learn More
<Icon icon="arrow-right" />
</div>
</a>
</div>
</div>
</div>
</div>
# Market Data and Metrics
Source: https://kamino.com/docs/build/borrow/market-data-metrics
Learn how to access market data including supply APY, borrow APY, TVL, and utilization rates for lending reserves
## Get Market Information
Retrieve market-wide TVL metrics for deposits and borrows.
<Tabs>
<Tab title="TypeScript">
```typescript theme={null}
import { createSolanaRpc, address } from '@solana/kit';
import { KaminoMarket } from '@kamino-finance/klend-sdk';
const slotDuration = 400; // ms
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
const marketPubkey = address('7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF');
const market = await KaminoMarket.load(rpc, marketPubkey, slotDuration);
console.log({
deposits: market!.getTotalDepositTVL(),
borrows: market!.getTotalBorrowTVL(),
});
```
<a>
<Icon icon="github" />
<span>View Code</span>
</a>
</Tab>
</Tabs>
## Get Reserve Supply and Borrow APY
Fetch historical supply APY and borrow APY data for a specific reserve over time.
<Tabs>
<Tab title="TypeScript">
```typescript theme={null}
const API_BASE_URL = 'https://api.kamino.finance';
const marketPubkey = '7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF';
const reservePubkey = '37Jk2zkz23vkAYBT66HM2gaqJuNg2nYLsCreQAVt5MWK';
const url = `${API_BASE_URL}/kamino-market/${marketPubkey}/reserves/${reservePubkey}/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.history) {
console.log({
timestamp: item.timestamp,
supplyInterestAPY: item.metrics.supplyInterestAPY,
borrowInterestAPY: item.metrics.borrowInterestAPY,
depositTvl: item.metrics.depositTvl,
borrowTvl: item.metrics.borrowTvl,
});
}
```
<a>
<Icon icon="github" />
<span>View Code</span>
</a>
</Tab>
</Tabs>
## Get Reserve Information
Check detailed metrics for all reserves including supply APY, borrow APY, deposit TVL, borrow TVL, and utilization rates.
<Tabs>
<Tab title="TypeScript">
```typescript theme={null}
import { createSolanaRpc, address } from '@solana/kit';
import { KaminoMarket } from '@kamino-finance/klend-sdk';
const rpc = createSolanaRpc프로젝트로 돌아가기