bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 73쪽
const response = await fetch(
'https://api.kamino.finance/kamino-market/<MARKET_ADDRESS>/reserves/metrics'
);
const { reserves } = await response.json();
reserves.forEach((reserve: any) => {
console.log({
address: reserve.reserve,
symbol: reserve.symbol,
depositTvl: reserve.metrics.depositTvl,
borrowTvl: reserve.metrics.borrowTvl,
supplyAPY: reserve.metrics.supplyInterestAPY,
borrowAPY: reserve.metrics.borrowInterestAPY,
});
});
```
```bash curl theme={null}
curl https://api.kamino.finance/kamino-market/<MARKET_ADDRESS>/reserves/metrics
```
</CodeGroup>
## Historical reserve metrics
Historical time-series data is API-only. The SDK reads live state; the API serves historical series.
<CodeGroup>
```typescript API theme={null}
const marketPubkey = '<MARKET_ADDRESS>';
const reservePubkey = '<RESERVE_ADDRESS>';
const url = `https://api.kamino.finance/kamino-market/${marketPubkey}/reserves/${reservePubkey}/metrics/history`;
const response = await fetch(url);
const { history } = await response.json();
for (const item of history) {
console.log({
timestamp: item.timestamp,
symbol: item.metrics.symbol,
supplyInterestAPY: item.metrics.supplyInterestAPY,
borrowInterestAPY: item.metrics.borrowInterestAPY,
depositTvl: item.metrics.depositTvl,
borrowTvl: item.metrics.borrowTvl,
});
}
```
```bash curl theme={null}
curl "https://api.kamino.finance/kamino-market/<MARKET_ADDRESS>/reserves/<RESERVE_ADDRESS>/metrics/history"
```
</CodeGroup>
## Rewards data
The Kamino API exposes reward data such as active campaigns and per-user claimable amounts for klend reserves.
### All active reward programs
<CodeGroup>
```typescript API theme={null}
const response = await fetch('https://api.kamino.finance/klend/rewards');
const rewards = await response.json();
console.log('Active KLend rewards:', rewards);
```
```bash curl theme={null}
curl https://api.kamino.finance/klend/rewards
```
</CodeGroup>
### A user's claimable rewards across all reserves
<CodeGroup>
```typescript API theme={null}
const userPubkey = '<USER_WALLET_ADDRESS>';
const response = await fetch(
`https://api.kamino.finance/klend/users/${userPubkey}/rewards`
);
const rewards = await response.json();
console.log('User rewards:', rewards);
```
```bash curl theme={null}
curl https://api.kamino.finance/klend/users/<USER_WALLET_ADDRESS>/rewards
```
</CodeGroup>
### Live farm state from the SDK
For real-time emission rates and on-chain farm balances, read the KFarms `FarmState` directly:
```typescript theme={null}
import { createSolanaRpc, address } from '@solana/kit';
import { KaminoMarket, getMedianSlotDurationInMsFromLastEpochs } from '@kamino-finance/klend-sdk';
import { FarmState } from '@kamino-finance/farms-sdk';
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
const market = await KaminoMarket.load(rpc, address('<MARKET_ADDRESS>'), slotDuration);
for (const reserve of market!.getReserves()) {
const collFarm = reserve.getCollateralFarmAddress();
const debtFarm = reserve.getDebtFarmAddress();
if (collFarm) {
const farmState = await FarmState.fetch(rpc, collFarm);
console.log(`${reserve.symbol} collateral farm:`, farmState);
}
if (debtFarm) {
const farmState = await FarmState.fetch(rpc, debtFarm);
console.log(`${reserve.symbol} debt farm:`, farmState);
}
}
```
For the full APY calculation walkthrough, see [Calculate reserve reward APY](/docs/build/tutorials/borrow/calculate-reserve-reward-apy).
## What the SDK exposes per reserve
`reserve` instances loaded via `market.getReserves()` provide the following getters:
| Method | Returns |
| - | - |
| `reserve.symbol` | Token symbol |
| `reserve.address` | Reserve account pubkey |
| `reserve.getDepositTvl()` | Total USD value deposited |
| `reserve.getBorrowTvl()` | Total USD value borrowed |
| `reserve.totalBorrowAPY(slot)` | Combined borrow APY (curve + host fixed) |
| `reserve.totalSupplyAPY(slot)` | Supply-side APY paid to depositors |
| `reserve.calculateUtilizationRatio()` | Borrowed / deposited, as a fraction |
| `reserve.getCollateralFarmAddress()` | Farm address for the collateral side, or `null` |
| `reserve.getDebtFarmAddress()` | Farm address for the debt side, or `null` |
| `reserve.config` | The on-chain `ReserveConfig` (every editable parameter) |
## Direct RPC reads
For the lowest-level access (minimal dependencies, fastest reads, no SDK abstraction), fetch the on-chain accounts directly via Solana RPC and decode them with the program's IDL or struct definitions.
The relevant accounts:
| Account | What it holds |
| - | - |
| `LendingMarket` | Market-level config + flags |
| `Reserve` | Per-reserve config + live state (liquidity, collateral, withdraw queue) |
| `Obligation` | Per-user position (deposits + borrows) |
| `FarmState` | KFarms reward state for a collateral or debt farm |
See [Programmatic integration](/docs/curators/markets/programmatic-integration) for routing to the SDK and API documentation that covers each surface in depth.
## Reference
<CardGroup>
<Card title="Full API Reference" icon="book" href="/docs/build/api-reference/introduction">
OpenAPI-rendered reference for every endpoint
</Card>
<Card title="SDK examples" icon="github" href="https://github.com/Kamino-Finance/klend-sdk/tree/master/examples">
Working code examples in the klend-sdk repo
</Card>
<Card title="Programmatic integration" icon="code" href="/docs/curators/markets/programmatic-integration">
Where to go for SDK / API / RPC integration docs
</Card>
<Card title="Farms & rewards" icon="sprout" href="/docs/curators/markets/farms-and-rewards">
Curator-side farm management
</Card>
</CardGroup>
# Market Settings
Source: https://kamino.com/docs/curators/markets/market-settings
Configure market-level parameters: name, fees, flags, and global thresholds
Market-level settings live on the `LendingMarket` account itself, separate from per-reserve config. They control the market's name, quote currency, referral fees, and dozens of feature flags and thresholds that apply to every reserve and every position.
This page covers the routine settings. Topic-specific settings such as liquidation tunables, eMode groups, the withdrawal queue, fixed-term rollover windows, and borrow / obligation orders live on their own pages.
<Tabs>
<Tab title="SDK">
## Update market settings via SDK
The SDK exposes `kaminoManager.updateLendingMarketIxs(signer, marketWithAddress, newLendingMarket)` for full market config updates. Fetch the current state, mutate the fields you care about, pass the new state in.
<Steps>
<Step title="Initialize KaminoManager and fetch the market">
```typescript theme={null}
import {
createSolanaRpc,
createSolanaRpcSubscriptions,
address,
pipe,
createTransactionMessage,
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
appendTransactionMessageInstructions,
signTransactionMessageWithSigners,
sendAndConfirmTransactionFactory,
} from '@solana/kit';
import {
KaminoManager,
DEFAULT_RECENT_SLOT_DURATION_MS,
PROGRAM_ID,
MarketWithAddress,
encodeTokenName,
} from '@kamino-finance/klend-sdk';
import { LendingMarket } from '@kamino-finance/klend-sdk/dist/@codegen/klend/accounts';
import { parseKeypairFile } from '@kamino-finance/klend-sdk/dist/utils/signer.js';
const adminSigner = await parseKeypairFile('/path/to/admin.json');
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
const rpcSubscriptions = createSolanaRpcSubscriptions('wss://api.mainnet-beta.solana.com');
const kaminoManager = new KaminoManager(rpc, DEFAULT_RECENT_SLOT_DURATION_MS, PROGRAM_ID);
const marketAddress = address('<MARKET_ADDRESS>');
const marketState = await LendingMarket.fetch(rpc, marketAddress);
if (!marketState) throw new Error('Market not found');
const marketWithAddress: MarketWithAddress = { address: marketAddress, state: marketState };
```
</Step>
<Step title="Mutate the fields you want to change">
```typescript theme={null}
// Build the new state from the current state, change only what you intend to change
const newLendingMarket = { ...marketState };
// Examples — mix and match per your update:
newLendingMarket.name = encodeTokenName('My Market'); // up to 32 bytes UTF-8
newLendingMarket.referralFeeBps = 100; // 1% referral fee
newLendingMarket.borrowDisabled = 1; // pause borrowing
newLendingMarket.minInitialDepositAmount = 1000n; // u64
newLendingMarket.individualAutodeleverageMarginCallPeriodSecs = 86400n; // 24 hours
newLendingMarket.emergencyCouncil = address('<EMERGENCY_PUBKEY>');
```
</Step>
<Step title="Build and submit the update">
```typescript theme={null}
const updateIxs = kaminoManager.updateLendingMarketIxs(
adminSigner,
marketWithAddress,
newLendingMarket,
);
async function buildAndSendTx(ixs: any[]) {
const { value: blockhash } = await rpc.getLatestBlockhash({ commitment: 'finalized' }).send();
const signed = await signTransactionMessageWithSigners(
pipe(
createTransactionMessage({ version: 0 }),
(tx) => setTransactionMessageFeePayerSigner(adminSigner, tx),
(tx) => setTransactionMessageLifetimeUsingBlockhash(blockhash, tx),
(tx) => appendTransactionMessageInstructions(ixs, tx)
)
);
await sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions })(signed, {
commitment: 'confirmed',
});
}
// The SDK splits large updates into multiple transactions for size reasons
for (const ix of updateIxs) {
await buildAndSendTx([ix]);
}
```
The update only emits instructions for fields that actually changed against on-chain state.
</Step>
</Steps>
### Multisig mode
When the market is owned by a multisig, replace the admin signer with `noopSigner(multisigPubkey)`:
```typescript theme={null}
import { noopSigner } from '@kamino-finance/klend-sdk';
const multisigSigner = noopSigner(address('<SQUADS_MULTISIG_PUBKEY>'));
const updateIxs = kaminoManager.updateLendingMarketIxs(multisigSigner, marketWithAddress, newLendingMarket);
// Encode each ix as a base58 transaction and submit it as a Squads proposal
```
</Tab>
<Tab title="API">
<Info>
**Updating market settings is not available via the REST API.** The Kamino API supports reading market state and reserve metrics; market configuration is an admin operation available through the **SDK** or **Kamino CLI**.
</Info>
To update market settings, use the **SDK** or **Kamino CLI** tabs.
For reading market data via API, see [Read market data](/docs/curators/markets/market-data).
</Tab>
<Tab title="Kamino CLI">
## Update market settings via CLI
All non-trivial market changes follow the download → edit → preview → execute cycle.
<Steps>
<Step title="Download the current config">
```bash theme={null}
yarn kamino-manager download-lending-market-config \
--lending-market <MARKET_ADDRESS>
```
Saves to `./configs/<MARKET_ADDRESS>/market-<MARKET_ADDRESS>.json`. This is the canonical, on-chain truth.
</Step>
<Step title="Edit the JSON">
Change only the fields you intend to change. Leave everything else untouched.
</Step>
<Step title="Inspect">
```bash theme={null}
yarn kamino-manager update-lending-market-from-config \
--lending-market <MARKET_ADDRESS> \
--lending-market-config-path ./configs/<MARKET_ADDRESS>/market-<MARKET_ADDRESS>.json \
--mode inspect
```
Open the printed Solana Explorer URL; verify the diff matches your intent.
</Step>
<Step title="Execute or propose">
Hot-wallet-owned: re-run with `--mode execute`.
Multisig-owned: re-run with `--mode multisig --multisig <SQUADS_PUBKEY>`. Submit the printed base58 transaction as a Squads proposal.
</Step>
</Steps>
### Focused commands
For two common updates, focused CLI commands exist that touch fewer fields:
```bash theme={null}
# Rename the market
yarn kamino-manager update-lending-market-name \
--lending-market <MARKET_ADDRESS> \
--new-name "My Market" \
--mode execute
# Promote the cached owner (final step of multisig transfer)
yarn kamino-manager update-lending-market-owner \
--lending-market <MARKET_ADDRESS> \
--mode multisig \
--multisig <SQUADS_MULTISIG_PUBKEY>
```
</Tab>
</Tabs>
## Common edits
### Set or update the market name
The market name is a 32-byte UTF-8 field (`name` on `LendingMarket`).
### Pause borrowing across the market
Set `borrow_disabled: 1` and apply. Existing positions remain; new borrows are rejected program-side until you flip it back. For broader emergency response, see [Emergency controls](/docs/curators/markets/emergency-controls).
### Change the referral fee
`referral_fee_bps` is a u16 (basis points). It defaults to `0`.
### Set the emergency council
The emergency council is a separate pubkey from the `lending_market_owner`. It has authority for `socialize_loss` and similar emergency-only handlers. Set `emergency_council` to a multisig address dedicated to incident response.
### Update minimum deposit and minimum net obligation value
| Field | What it controls |
| - | - |
| `min_initial_deposit_amount` | The minimum amount required for a brand-new deposit to a reserve. Prevents 1-wei spam attacks. |
| `min_net_value_in_obligation_sf` | The minimum USD value an obligation must hold (as a scaled fraction). Stops dust positions from existing. |
<Warning>
Setting `min_net_value_in_obligation_sf` too high causes user-visible failures on partial repays. A common footgun is repaying down to a sub-threshold debt — the program rejects the operation. Document this for your users, or set the threshold low (the protocol-wide default is around `$0.000001`).
</Warning>
### Freeze the market permanently
Set `immutable: 1` and apply. Once committed, the program rejects every owner-initiated update going forward.
<Warning>
`immutable` is one-way. The program has no recovery path.
</Warning>
## Topic-specific settings (covered elsewhere)
| Topic | Page |
| - | - |
| Liquidation tunables | [Liquidations](/docs/curators/markets/liquidations) |
| Auto-deleverage (margin-call grace window) | [Auto-deleverage](/docs/curators/markets/auto-deleverage) |
| Elevation groups | [Elevation groups](/docs/curators/markets/elevation-groups) |
| Withdrawal queue flags | [Withdrawal queue](/docs/curators/markets/withdrawal-queue) |
| Fixed-term rollover windows | [Fixed rate reserves](/docs/curators/markets/fixed-rate-reserves) |
| Borrow orders | [Borrow orders](/docs/curators/markets/borrow-orders) |
| Obligation orders | [Obligation orders](/docs/curators/markets/obligation-orders) |
| Per-reserve settings | [Updating reserves](/docs/curators/markets/reserve-management), [Reserve config reference](/docs/curators/markets/reserve-parameters) |
## Reference
* [Market config reference](/docs/curators/markets/market-config-reference) — every `LendingMarket` field
* [CLI command index](/docs/curators/markets/cli-command-index) — all market-related commands
# Obligation Orders
Source: https://kamino.com/docs/curators/markets/obligation-orders
Price-triggered self-deleverage for borrower positions
Obligation orders are user-set, price-triggered instructions that automatically deleverage a position when a condition is met. They're the on-chain equivalent of a stop-loss: a borrower creates an order saying "if my LTV crosses 75%, repay 30% of my debt by liquidating part of my collateral." Permissionless executors can then submit transactions that trigger the order when the condition becomes true.
This is a tool for sophisticated borrowers (institutions, leveraged vault strategies) who want guaranteed self-deleverage rules separate from the protocol's standard liquidation flow.
## Market-level enablement
| Field | What it does |
| - | - |
| `obligation_order_creation_enabled` | If `1`, borrowers can create new orders on their obligations |
| `obligation_order_execution_enabled` | If `1`, executors can fill orders when conditions are met |
| `price_triggered_liquidation_disabled` | If `1`, blocks all price-triggered liquidations market-wide (incident response) |
## Reserve-level fee
| Field | What it does |
| - | - |
| `protocol_order_execution_fee_pct` | Percent (0–100) of order-execution proceeds routed to the protocol fee account |
<Tabs>
<Tab title="SDK">
## Enable obligation orders via SDK
Curator-side: flip the market flags. User-side: build a price-based order via SDK helpers and submit `setObligationOrder`.
### Curator: enable on the market
```typescript theme={null}
import {
KaminoManager,
DEFAULT_RECENT_SLOT_DURATION_MS,
PROGRAM_ID,
MarketWithAddress,
} from '@kamino-finance/klend-sdk';
import { LendingMarket } from '@kamino-finance/klend-sdk/dist/@codegen/klend/accounts';
import { address } from '@solana/kit';
const kaminoManager = new KaminoManager(rpc, DEFAULT_RECENT_SLOT_DURATION_MS, PROGRAM_ID);
const marketState = await LendingMarket.fetch(rpc, marketAddress);
if (!marketState) throw new Error('Market not found');
const marketWithAddress: MarketWithAddress = { address: marketAddress, state: marketState };
const newLendingMarket = { ...marketState };
newLendingMarket.obligationOrderCreationEnabled = 1;
newLendingMarket.obligationOrderExecutionEnabled = 1;
newLendingMarket.priceTriggeredLiquidationDisabled = 0;
const ixs = kaminoManager.updateLendingMarketIxs(adminSigner, marketWithAddress, newLendingMarket);
// submit each ix in order
```
### Curator: set the per-reserve execution fee
Update `protocolOrderExecutionFeePct` in the reserve config (range 0–100):
```typescript theme={null}
import { Reserve } from '@kamino-finance/klend-sdk/dist/@codegen/klend/accounts';
const reserve = await Reserve.fetch(rpc, reserveAddress);
if (!reserve) throw new Error('Reserve not found');
const newConfig = { ...reserve.config };
newConfig.protocolOrderExecutionFeePct = 1; // 1% of execution proceeds
const updateIxs = await kaminoManager.updateReserveIxs(adminSigner, marketWithAddress, reserveAddress, newConfig);
// submit each chunk in order
```
### Borrower: set a stop-loss order
The SDK provides high-level helpers `createPriceBasedOrder` and `readPriceBasedOrder`, plus `KaminoAction.buildSetObligationOrderIxn` to wrap the on-chain instruction.
```typescript theme={null}
import {
KaminoAction,
KaminoMarket,
KaminoObligation,
createPriceBasedOrder,
readPriceBasedOrder,
OrderType,
OrderActionType,
PriceBasedOrderTriggerType,
getMedianSlotDurationInMsFromLastEpochs,
} from '@kamino-finance/klend-sdk';
import Decimal from 'decimal.js';
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
const kaminoMarket = await KaminoMarket.load(rpc, address('<MARKET_ADDRESS>'), slotDuration);
const kaminoObligation = await KaminoObligation.load(kaminoMarket, address('<OBLIGATION_ADDRESS>'));
const context = {
kaminoMarket,
kaminoObligation,
stablecoins: ['USDC'],
};
// Inspect the current stop-loss
const currentStopLoss = readPriceBasedOrder(context, OrderType.StopLoss);
console.log(currentStopLoss);
// Set a new stop-loss: when collateral price drops below $125, repay all USDC debt
const newStopLoss = createPriceBasedOrder(context, OrderType.StopLoss, {
trigger: {
type: PriceBasedOrderTriggerType.LongStopLoss,
whenCollateralPriceBelow: new Decimal(125),
},
action: {
type: OrderActionType.FullRepay,
},
executionBonusBpsRange: [50, 200], // 0.5% - 2% bonus to executor
});
const ix = KaminoAction.buildSetObligationOrderIxn(
borrowerSigner,
kaminoMarket,
kaminoObligation,
newStopLoss,
);
// Sign and submit
```
A complete working example is at [klend-sdk/examples/klend-examples/example\_obligation\_order.ts](https://github.com/Kamino-Finance/klend-sdk/blob/master/examples/klend-examples/example_obligation_order.ts).
</Tab>
<Tab title="API">
<Info>
**Configuring obligation orders is not available via the REST API.** The market-level flags and reserve-lev프로젝트로 돌아가기