bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 3쪽
mino Lending market. This V2 endpoint supports using stake rate for obligation value calculation when `useStakeRateForObligation` is true.
# Get profit and loss for an obligation
Source: https://kamino.com/docs/build/api-reference/borrow/user-and-loans-data/obligation-pnl
kamino-api.json GET /v2/kamino-market/{marketPubkey}/obligations/{obligationPubkey}/pnl
Get profit and loss (PnL) for a specific obligation. For xSOL pairs, `useStakeRate` can be set to true to calculate the PnL using the stake rate.
# Get all user obligations
Source: https://kamino.com/docs/build/api-reference/borrow/user-and-loans-data/user-obligations
kamino-api.json GET /kamino-market/{marketPubkey}/users/{userPubkey}/obligations
Get all obligations (loans) for a specific user wallet in a Kamino Lending market.
# Get user KLend rewards
Source: https://kamino.com/docs/build/api-reference/borrow/user-and-loans-data/user-rewards
kamino-api.json GET /klend/users/{pubkey}/rewards
Fetches KLend reward data for a specific user and points source
# Distributor codes
Source: https://kamino.com/docs/build/api-reference/distributors
A distributor is a third party that directs deposit flow into Kamino Earn vaults or Kamino Lend reserves. Deposits and withdrawals are attributed to a distributor by a 5-character code carried in the SPL Memo instruction of the transaction.
## Generating codes
### Getting credentials
Registering codes and reading their analytics require API credentials. The Kamino team issues a username and password on request. These are sent as HTTP basic auth on the calls below.
### Registering a code
Each code is registered under a unique name of 1 to 64 characters. The name should describe the purpose of the code, as the distributor is responsible for maintaining the mapping from name to code.
```bash theme={null}
curl -u '<user>:<password>' \
-H 'Content-Type: application/json' \
-d '{"name": "Example Wallet - mobile app"}' \
https://api.kamino.finance/distributors
```
```json theme={null}
{ "code": "abcde" }
```
The code is active immediately. A name that already exists returns `409`.
## Tagging transactions
The code is passed as the `memo` field of the deposit and withdraw endpoints. For Kamino Earn:
[`POST /ktx/kvault/deposit`](/docs/build/api-reference/earn/actions/deposit/kvault-deposit),
[`POST /ktx/kvault/deposit-instructions`](/docs/build/api-reference/earn/actions/deposit/kvault-deposit-instructions),
[`POST /ktx/kvault/withdraw`](/docs/build/api-reference/earn/actions/withdraw/kvault-withdraw) or
[`POST /ktx/kvault/withdraw-instructions`](/docs/build/api-reference/earn/actions/withdraw/kvault-withdraw-instructions):
```json theme={null}
{
"wallet": "<wallet pubkey>",
"kvault": "<kvault address>",
"amount": "0.1234",
"memo": "abcde"
}
```
For Kamino Lend:
[`POST /ktx/klend/deposit`](/docs/build/api-reference/borrow/actions/deposit/klend-deposit) or
[`POST /ktx/klend/deposit-instructions`](/docs/build/api-reference/borrow/actions/deposit/klend-deposit-instructions):
```json theme={null}
{
"wallet": "<wallet pubkey>",
"market": "<market address>",
"reserve": "<reserve address>",
"amount": "0.1234",
"memo": "abcde"
}
```
When the transaction is built manually, an SPL Memo instruction whose data is the code must be included in the same transaction as the deposit or withdraw instruction.
* The memo must be exactly the code. Matching is case-insensitive.
* Use one code per transaction.
* The `memo` field accepts up to 64 UTF-8 bytes. Longer values return `400`.
* Codes use the alphabet `23456789abcdefghjkmnpqrstuvwxyz`, so `0`, `1`, `o`, `l` and `i` never appear.
## Analytics
Four endpoints report the deposits and withdrawals attributed to distributor codes. They are private: send the same basic auth credentials used to register codes, or the call returns `401`. They cover Kamino Earn vaults only; tagged Kamino Lend transactions are not reported yet.
| Endpoint | Scope |
| - | - |
| [`GET /kvaults/vaults/{pubkey}/distributor-transactions`](/docs/build/api-reference/earn/distributors/vault-distributor-transactions) | every tagged transaction on one vault, across all codes |
| [`GET /kvaults/distributors/{code}/transactions`](/docs/build/api-reference/earn/distributors/distributor-transactions) | every transaction tagged with one code, across all vaults |
| [`GET /kvaults/distributors/{code}/vaults/{vault}/transactions`](/docs/build/api-reference/earn/distributors/distributor-vault-transactions) | every transaction tagged with one code on one vault |
| [`GET /kvaults/distributors/{code}/wallets`](/docs/build/api-reference/earn/distributors/distributor-wallets) | per-wallet totals for one code, split by token and direction |
Rules that apply to all four:
* Each flow has a `type`: `deposit` for the `deposit` and `buy` instructions, `withdraw` for the `withdraw`, `withdrawFromAvailable`, `sell` and `redeemInKind` instructions. Admin and crank instructions are never counted, even when their transaction carries a code.
* `type` is an optional query parameter. `type=deposit` or `type=withdraw` returns only that direction; omitted, both are returned.
* `start` and `end` are optional query parameters, given as ISO 8601 strings or epoch milliseconds, and either can be given on its own. A missing `start` means the beginning of history and a missing `end` means now. `start` is inclusive and `end` is exclusive, and `start` must be before `end` once the missing one is filled in, so an `end` before 1970 or a `start` in the future returns `400`.
* On the three code-based endpoints the code is matched case-insensitively, and an unregistered code returns `404`.
* Responses are cached for 60 seconds.
All four endpoints page with a cursor. `limit` accepts 1 to 1000 and defaults to 100. When more rows remain, the response carries a `paginationToken`; the last page has none. Pass it back unchanged on the next call together with the same `start`, `end` and `type`. The transaction endpoints return the newest rows first. On the wallets endpoint the token also pins the `start`, `end` and `type` the first page aggregated over, filling in an omitted bound at the moment of the first page, so later pages total the same set of transactions even while new ones arrive. A wallets token sent with a different `start`, `end` or `type` returns `400`.
```bash theme={null}
curl -u '<user>:<password>' \
'https://api.kamino.finance/kvaults/distributors/abcde/transactions?start=2026-01-01T00:00:00Z&end=2026-02-01T00:00:00Z&limit=2'
```
```json theme={null}
{
"result": [
{
"createdOn": "2026-01-20T14:03:11.000Z",
"tx": "<transaction signature>",
"code": "abcde",
"type": "withdraw",
"instruction": "withdraw",
"wallet": "<wallet pubkey>",
"vault": "<kvault address>",
"tokenMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"tokenSymbol": "USDC",
"amount": "2500"
},
{
"createdOn": "2026-01-18T09:41:57.000Z",
"tx": "<transaction signature>",
"code": "abcde",
"type": "deposit",
"instruction": "deposit",
"wallet": "<wallet pubkey>",
"vault": "<kvault address>",
"tokenMint": "So11111111111111111111111111111111111111112",
"tokenSymbol": "SOL",
"amount": "10.5"
}
],
"paginationToken": "eyJjcmVhdGVkT24iOiIyMDI2LTAxLTE4VDA5OjQxOjU3LjAwMFoiLCJsYXN0SWQiOiI0MjE3In0="
}
```
The three transaction endpoints return one row per instruction, not per transaction, so a transaction with several tagged vault instructions gives one row each. `amount` is a decimal string in the underlying token, not in vault shares, and is always positive; the `type` gives the direction. For `redeemInKind`, which pays out cTokens of a reserve, the cTokens are converted to the underlying token at the reserve exchange rate at that time. `instruction` is the Kamino Earn vault instruction that moved the tokens. `tokenSymbol` is `null` when the token is not known to Kamino.
The wallets endpoint aggregates the same transactions by wallet, ordered by wallet address. Each wallet lists one entry per token and direction, with the total amount moved. A wallet that both deposited and withdrew a token gets two entries for it, one with `type` `deposit` and one with `type` `withdraw`; the two are never netted. The `type` query parameter restricts the totals to one direction.
```bash theme={null}
curl -u '<user>:<password>' \
'https://api.kamino.finance/kvaults/distributors/abcde/wallets?start=2026-01-01T00:00:00Z&end=2026-02-01T00:00:00Z'
```
```json theme={null}
{
"result": [
{
"wallet": "<wallet pubkey>",
"tokens": [
{ "tokenMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "tokenSymbol": "USDC", "type": "deposit", "amount": "4000" },
{ "tokenMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "tokenSymbol": "USDC", "type": "withdraw", "amount": "2500" },
{ "tokenMint": "So11111111111111111111111111111111111111112", "tokenSymbol": "SOL", "type": "deposit", "amount": "10.5" }
]
}
]
}
```
# Get transaction to deposit into a kvault
Source: https://kamino.com/docs/build/api-reference/earn/actions/deposit/kvault-deposit
ktx-api.json POST /ktx/kvault/deposit
Deposit tokens into a specified Kamino Earn Vault. An optional `memo` is added to the transaction as an SPL memo instruction.
# Get instructions to deposit into a kvault
Source: https://kamino.com/docs/build/api-reference/earn/actions/deposit/kvault-deposit-instructions
ktx-api.json POST /ktx/kvault/deposit-instructions
Instructions to deposit tokens into a specified Kamino Earn Vault. Additionally includes lookup tables to use to compress transaction size. An optional `memo` is added as an SPL memo instruction.
# Get transaction to withdraw from a kvault
Source: https://kamino.com/docs/build/api-reference/earn/actions/withdraw/kvault-withdraw
ktx-api.json POST /ktx/kvault/withdraw
Withdraw tokens from a specified Kamino Earn Vault. An optional `memo` is added as an SPL memo instruction.
# Get instructions to withdraw from a kvault
Source: https://kamino.com/docs/build/api-reference/earn/actions/withdraw/kvault-withdraw-instructions
ktx-api.json POST /ktx/kvault/withdraw-instructions
Instructions to withdraw tokens from a specified Kamino Earn Vault. Includes lookup tables for transaction compression. An optional `memo` is added as an SPL memo instruction.
# Get transactions for a distributor code
Source: https://kamino.com/docs/build/api-reference/earn/distributors/distributor-transactions
kamino-api.json GET /kvaults/distributors/{code}/transactions
Cursor-paginated list of deposits and withdrawals, across every Kamino Earn vault, whose transaction carried this distributor code, newest first. One row per instruction. Private (authorized) API access only, please add a basic auth header to your request.
# Get transactions for a distributor code in a vault
Source: https://kamino.com/docs/build/api-reference/earn/distributors/distributor-vault-transactions
kamino-api.json GET /kvaults/distributors/{code}/vaults/{vault}/transactions
Cursor-paginated list of deposits into and withdrawals out of one Kamino Earn vault whose transaction carried this distributor code, newest first. One row per instruction. Private (authorized) API access only, please add a basic auth header to your request.
# Get wallet totals for a distributor code
Source: https://kamino.com/docs/build/api-reference/earn/distributors/distributor-wallets
kamino-api.json GET /kvaults/distributors/{code}/wallets
For each wallet that transacted under this distributor code in the range: the total amount per token and direction, deposits and withdrawals as separate lines. Private (authorized) API access only, please add a basic auth header to your request.
# Get distributor transactions of a vault
Source: https://kamino.com/docs/build/api-reference/earn/distributors/vault-distributor-transactions
kamino-api.json GET /kvaults/vaults/{pubkey}/distributor-transactions
Cursor-paginated list of deposits into and withdrawals out of a Kamino Earn vault whose transaction carried a distributor code, newest first. One row per instruction, so a transaction with several gives several rows. Private (authorized) API access only, please add a basic auth header to your request.
# Get historical user metrics for all KVault positions
Source: https://kamino.com/docs/build/api-reference/earn/user-data/user-metrics-history
kamino-api.json GET /kvaults/users/{pubkey}/metrics/history
Get historical timeseries of total usd/sol/interest/apy for all user Kamino Earn Vault positions
# Get all user KVault positions
Source: https://kamino.com/docs/build/api-reference/earn/user-data/user-positions
kamino-api.json GET /kvaults/users/{pubkey}/positions
Get a list of user positions for each Kamino Earn Vault the user has currently deposited into. Returns staked and unstaked shares.
# Get user KVault transactions
Source: https://kamino.com/docs/build/api-reference/earn/user-data/user-transactions
kamino-api.json GET /kvaults/users/{pubkey}/transactions
Get all Kamino Earn Vault transactions for a given user
# Get historical user metrics for a single KVault
Source: https://kamino.com/docs/build/api-reference/earn/user-data/user-vault-metrics-history
kamino-api.json GET /kvaults/users/{userPubkey}/vaults/{vaultPubkey}/metrics/history
Get historical timeseries for one vault position. Automatic selection picks minute rows for ranges up to 2 days, hourly rows for ranges under 32 days, and daily rows otherwise, returning finer rows for positions younger than those windows, measured from the first resampled bucket. frequency=minute is limited to ranges of at most 32 days. frequency=day&view=chart returns only UTC daily bucket timestamps, USD balances and cumulative USD interest. The newest daily bucket may be partial; use the summary endpoint for the latest balance. Open-ended histories can be up to five minutes plus processing time old.
# Get user KVault PnL
Source: https://kamino.com/docs/build/api-reference/earn/user-data/user-vault-pnl
kamino-api.json GET /kvaults/users/{userPubkey}/vaults/{vaultPubkey}/pnl
Get current PnL and cost basis of user vault position
# Get user KVault PnL history
Source: https://kamino.com/docs/build/api-reference/earn/user-data/user-vault-pnl-history
kamino-api.json GET /kvaults/users/{userPubkey}/vaults/{vaultPubkey}/pnl/history
Get PnL and cost basis history of user vault position
# Get user position for a specific KVault
Source: https://kamino.com/docs/build/api-reference/earn/user-data/user-vault-position
kamino-api.json GET /kvaults/users/{userPubkey}/positions/{vaultPubkey}
Get a single user position for a Kamino Earn Vault the user currently has currently deposited into. Returns staked and unstaked shares.
# Get historical KVault allocation volume
Source: https://kamino.com/docs/build/api-reference/earn/vault-data/vault-allocation-history
kamino-api.json GET /kvaults/vaults/{pubkey}/allocation-volume/history
Get historical Kamino Earn Vault allocation volume for a given vault and date range (max 1 year)
# Get KVault by address
Source: https://kamino.com/docs/build/api-reference/earn/vault-data/vault-detail
kamino-api.json GET /kvaults/vaults/{pubkey}
Get a single Kamino Earn Vault by the KVault account address
# Get current KVault metrics
Source: https://kamino.com/docs/build/api-reference/earn/vault-data/vault-metrics
kamino-api.json GET /kvaults/vaults/{pubkey}/metrics
Get current Kamino Earn Vault metrics for a given vault
# Get historical KVault metrics
Source: https://kamino.com/docs/build/api-reference/earn/vault-data/vault-metrics-history
kamino-api.json GET /kvaults/vaults/{pubkey}/metrics/history
Get historical Kamino Earn Vault metrics for a given vault, between an optional range of dates
# Get icon for KVault token
Source: https://kamino.com/docs/build/api-reference/earn/vault-data/vault-mint-image
kamino-api.json GET /kvaults/mints/{pubkey}/metadata/image.svg
Get the SVG icon for a given Kamino Earn Vault receipt token mint
# Get metadata for KVault token
Source: https://kamino.com/docs/build/api-reference/earn/vault-data/vault-mint-metadata
kamino-api.json GET /kvaults/mints/{pubkey}/metadata
Get metadata for a given Kamino Earn Vault receipt token mint
# Get all kvaults
Source: https://kamino.com/docs/build/api-reference/earn/vault-data/vaults-list
kamino-api.json GET /kvaults/vaults
Get Kamino Earn Vaults. Omit type for all on-chain vaults. Use live or privateCredit for CDN-listed vaults.
# Get all KVault season rewards
Source: https://kamino.com/docs/build/api-reference/earn/vault-data/vaults-rewards
kamino-api.json GET /kvaults/rewards
Get all active season points rewards for each Kamino Earn Vault
# Get summary of the KVault program earnings
Source: https://kamino.com/docs/build/api-reference/earn/vault-data/vaults-summary
kamino-api.json GET /kvaults/summary
Get an aggregated all-time summary of all Kamino Earn Vault rewards and interest earned, in SOL and USD
# Kamino API
Source: https://kamino.com/docs/build/api-reference/introduction
Access comprehensive data for Kamino Earn vaults, lending markets, user positions, and transaction endpoints to seamlessly integrate yield strategies and borrowing functionality into your applications.
## Base URL
All Kamino API requests use the following base URL:
```bash theme={null}
https://api.kamino.finance
```
## Distributor codes
Third parties that direct deposits into Kamino can tag their deposits and withdrawals with a distributor code and read back the attributed flow. See [Distributor codes](/docs/build/api-reference/distributors).
# Swap
Source: https://kamino.com/docs/build/api-reference/kswap/swap
kswap-api.json GET /kswap/swap/
Get the best route and a pre-built transaction for swapping between two tokens on Solana via Kamino's swap aggregator. The response includes the serialized transaction, expected output amount, minimum output after slippage, and which router was selected.
Get the best route and transaction for swapping between two tokens on Solana via Kamino's swap aggregator.
## Example
<Steps>
<Step>
### Import Dependencies
```typescript theme={null}
import {
createSolanaRpc,
createSolanaRpcSubscriptions,
pipe,
getTransactionDecoder,
getCompiledTransactionMessageDecoder,
decompileTransactionMessageFetchingLookupTables,
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
addSignersToTransactionMessage,
signTransactionMessageWithSigners,
sendAndConfirmTransactionFactory,
getSignatureFromTransaction,
isTransactionWithinSizeLimit,
} from '@solana/kit';
import { parseKeypairFile } from '@kamino-finance/klend-sdk/dist/utils/signer';
```
</Step>
<Step>
### Configure and Initialize
```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 signer = await parseKeypairFile(KEYPAIR_FILE);
const rpc = createSolanaRpc(RPC_ENDPOINT);
const rpcSubscriptions = createSolanaRpcSubscriptions(WS_ENDPOINT);
```
</Step>
<Step>
### Fetch Swap Transaction
Call the KSwap API to get the best route and a pre-built transaction. This example swaps 1 SOL to USDC with 50bps max slippage.
```typescript theme={null}
const SOL = 'So11111111111111111111111111111111111111112';
const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
const params = new URLSearchParams({
tokenIn: SOL,
tokenOut: USDC,
amountIn: '1000000000', // 1 SOL in lamports
maxSlippageBps: '50',
wallet: signer.address,
});
const res = await fetch(`${API_BASE_URL}/kswap/swap/?${params}`);
const { data } = await res.json();
console.log(`Router: ${data.routerType}, Expected out: ${data.expectedAmountOut}`);
const encodedTransaction = data.transaction;
```
</Step>
<Step>
### Decode, Sign, and Send
Decode the base64 transaction, sign it locally, and submit to the network.
```typescrip프로젝트로 돌아가기