# Kamino Lending decoder (Carbon 2.0)

> Decode Kamino Lending instructions, accounts and events in Rust with the carbon-kamino-lending-decoder crate.

`carbon-kamino-lending-decoder` decodes the instructions, accounts and events of the Kamino Lending program (`KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD`): 63 instructions, 10 account types, 5 events. It is generated with Codama from the program's IDL; see [decoders](https://carbon.sevenlabs.org/concepts/decoders.md) for how decoders plug into a pipeline.

|                  |                                                                                                                       |
| ---------------- | --------------------------------------------------------------------------------------------------------------------- |
| Crate            | [`carbon-kamino-lending-decoder`](https://crates.io/crates/carbon-kamino-lending-decoder/2.0.0) 2.0.0                 |
| Install          | `cargo add carbon-kamino-lending-decoder@2.0.0`                                                                       |
| Program ID       | `KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD` (`carbon_kamino_lending_decoder::PROGRAM_ID`)                           |
| Category         | [Lending](https://carbon.sevenlabs.org/decoders/lending.md)                                                           |
| Decoder          | `carbon_kamino_lending_decoder::KaminoLendingDecoder`                                                                 |
| Instruction enum | `instructions::KaminoLendingInstruction`                                                                              |
| Account enum     | `accounts::KaminoLendingAccount`                                                                                      |
| Event enum       | `instructions::CpiEvent`                                                                                              |
| Features         | `serde`, `postgres`, `graphql` (none enabled by default)                                                              |
| API docs         | [docs.rs/carbon-kamino-lending-decoder/2.0.0](https://docs.rs/carbon-kamino-lending-decoder/2.0.0)                    |
| Source           | [decoders/kamino-lending-decoder](https://github.com/sevenlabs-hq/carbon/tree/v2.0.0/decoders/kamino-lending-decoder) |

Other lending decoders: [Jupiter Lend](https://carbon.sevenlabs.org/decoders/jupiter-lend.md), [Kamino Vault](https://carbon.sevenlabs.org/decoders/kamino-vault.md), [marginfi v2](https://carbon.sevenlabs.org/decoders/marginfi-v2.md), [Meteora Vault](https://carbon.sevenlabs.org/decoders/meteora-vault.md), [Sharky](https://carbon.sevenlabs.org/decoders/sharky.md). To decode several in one pipeline, see [lending decoders](https://carbon.sevenlabs.org/decoders/lending.md).

The `serde` feature derives `Serialize`/`Deserialize` on every type, `postgres` adds tables and processors for [Postgres](https://carbon.sevenlabs.org/guides/postgres.md), and `graphql` adds a schema for the [GraphQL server](https://carbon.sevenlabs.org/guides/graphql.md).

## Usage

This program crawls recent Kamino Lending transactions from the public RPC and prints every decoded `RefreshReserve` instruction. Add the dependencies:

```sh
cargo add carbon-core@2.0.0 carbon-kamino-lending-decoder@2.0.0 carbon-rpc-transaction-crawler-datasource@2.0.0 carbon-log-metrics@2.0.0 env_logger tokio --features tokio/full
```

`src/main.rs`:

```rust
use {
    carbon_core::{
        error::CarbonResult, instruction::InstructionProcessorInputType, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_kamino_lending_decoder::{
        instructions::KaminoLendingInstruction, KaminoLendingDecoder, PROGRAM_ID,
    },
    carbon_rpc_transaction_crawler_datasource::{ConnectionConfig, Filters, RpcTransactionCrawler},
    std::sync::Arc,
};

#[tokio::main]
async fn main() -> CarbonResult<()> {
    env_logger::init();

    // Fetches the program's recent transactions over JSON-RPC, newest first.
    let datasource = RpcTransactionCrawler::new(
        "https://api.mainnet-beta.solana.com".to_string(),
        PROGRAM_ID,
        ConnectionConfig::default(),
        Filters::new(None, None, None),
        None,
    );

    Pipeline::builder()
        .datasource(datasource)
        .metrics(Arc::new(LogMetrics::new()))
        .instruction(KaminoLendingDecoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

impl Processor<InstructionProcessorInputType<'_, KaminoLendingInstruction>> for InstructionLogger {
    async fn process(
        &mut self,
        input: &InstructionProcessorInputType<'_, KaminoLendingInstruction>,
    ) -> CarbonResult<()> {
        let signature = input.metadata.transaction_metadata.signature;
        if let KaminoLendingInstruction::RefreshReserve { data, accounts, .. } = input.decoded_instruction {
            println!("refresh_reserve {signature}: {data:?} reserve={}", accounts.reserve);
        }
        Ok(())
    }
}
```

```sh
RUST_LOG=info cargo run
```

Each `RefreshReserve` instruction prints one line with the transaction signature and the decoded `RefreshReserve` data. The public endpoint rate-limits requests, so the first lines can take a while; use your own RPC URL for anything beyond a test. See [stream with RPC](https://carbon.sevenlabs.org/guides/stream-with-rpc.md) for the crawler options.

Events published with Anchor's `emit_cpi!` arrive as the `CpiEvent` instruction. Match them with `KaminoLendingInstruction::CpiEvent { data: CpiEvent::BorrowOrderCancelEvent(event), .. }` (import `instructions::CpiEvent`); see [Events](#events). If `CpiEvent` never arrives, the program logs its events with `emit!` instead: decode them with [`decode_log_events`](https://carbon.sevenlabs.org/concepts/instructions.md#log-events).

### Decode accounts

The transaction crawler emits transactions only. To decode accounts, use a datasource that emits account updates. This program subscribes to the program's accounts with `programSubscribe` on the public WebSocket endpoint and prints every decoded `Reserve` account as it changes. Add the datasource and the Solana RPC types it takes:

```sh
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2
```

`src/main.rs`:

```rust
use {
    carbon_core::{
        account::AccountProcessorInputType, error::CarbonResult, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_kamino_lending_decoder::{
        accounts::KaminoLendingAccount, KaminoLendingDecoder, PROGRAM_ID,
    },
    carbon_rpc_program_subscribe_datasource::{Filters, RpcProgramSubscribe},
    solana_client::rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, UiAccountEncoding},
    std::sync::Arc,
};

#[tokio::main]
async fn main() -> CarbonResult<()> {
    env_logger::init();

    // Streams every change to an account owned by the program (programSubscribe).
    let config = RpcProgramAccountsConfig {
        account_config: RpcAccountInfoConfig {
            encoding: Some(UiAccountEncoding::Base64),
            ..Default::default()
        },
        ..Default::default()
    };
    let datasource = RpcProgramSubscribe::new(
        "wss://api.mainnet-beta.solana.com".to_string(),
        Filters::new(PROGRAM_ID, Some(config)),
    );

    Pipeline::builder()
        .datasource(datasource)
        .metrics(Arc::new(LogMetrics::new()))
        .account(KaminoLendingDecoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

impl Processor<AccountProcessorInputType<'_, KaminoLendingAccount>> for AccountLogger {
    async fn process(
        &mut self,
        input: &AccountProcessorInputType<'_, KaminoLendingAccount>,
    ) -> CarbonResult<()> {
        if let KaminoLendingAccount::Reserve(reserve) = &input.decoded_account.data {
            println!("reserve {}: {reserve:?}", input.metadata.pubkey);
        }
        Ok(())
    }
}
```

```sh
RUST_LOG=info cargo run
```

Each update to a `Reserve` account prints its address and decoded fields; the program runs until you stop it. Cargo resolves `solana-client` to 4.2.2, the exact version the datasource pins, so both use the same `RpcProgramAccountsConfig` type. To load every existing account once instead of streaming changes, see [load account state](https://carbon.sevenlabs.org/guides/load-account-state.md).

## Instructions

Variants of `KaminoLendingInstruction`. Each is `KaminoLendingInstruction::<Variant> { program_id, data, accounts }`, where `data` and `accounts` are the types listed under the variant, exported from `carbon_kamino_lending_decoder::instructions`. Discriminators are the leading bytes of the instruction data, in hex.

**How an instruction decodes.** The decoder returns a variant only when all of these hold; otherwise the instruction is skipped and no processor is called:

1. The instruction's program ID is `KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD`.
2. The data starts with the variant's discriminator, and the rest deserializes into its data type.
3. The instruction has at least as many accounts as the variant requires (the "Required accounts" count under each variant).

**Accounts.** They are matched by position, in the order listed. An account marked _optional_ is `None` only when the instruction ends before it; Anchor programs pass the program ID as a placeholder for an omitted optional account, so check for `Some(PROGRAM_ID)` too. Accounts after the listed ones are in `accounts.remaining` as `AccountMeta`s. The decoder doesn't record whether an account signed or was writable: read that from `input.raw_instruction.accounts[i].is_signer` and `.is_writable`, which follow the same order. It doesn't check signer, writable, owner or PDA constraints either; the program enforced those when the transaction executed, so a decoded instruction from a successful transaction already satisfied them.

### `AbortObligationOwnershipTransfer`

Discriminator `67d95341a405c3e3` · data `AbortObligationOwnershipTransfer` · accounts `AbortObligationOwnershipTransferInstructionAccounts`.

No data fields.

Required accounts: 3; extras go to `remaining`.

Fields of `AbortObligationOwnershipTransferInstructionAccounts`, in account order:

| #  | Field                        | Type               |
| -- | ---------------------------- | ------------------ |
| 0  | `owner`                      | `Pubkey`           |
| 1  | `obligation`                 | `Pubkey`           |
| 2  | `instruction_sysvar_account` | `Pubkey`           |
| 3… | `remaining`                  | `Vec<AccountMeta>` |

### `AcceptObligationOwnership`

Discriminator `f98246b097bbef06` · data `AcceptObligationOwnership` · accounts `AcceptObligationOwnershipInstructionAccounts`.

No data fields.

Required accounts: 3; extras go to `remaining`.

Fields of `AcceptObligationOwnershipInstructionAccounts`, in account order:

| #  | Field                        | Type               |
| -- | ---------------------------- | ------------------ |
| 0  | `pending_owner`              | `Pubkey`           |
| 1  | `obligation`                 | `Pubkey`           |
| 2  | `instruction_sysvar_account` | `Pubkey`           |
| 3… | `remaining`                  | `Vec<AccountMeta>` |

### `ApproveObligationOwnershipTransfer`

Discriminator `3de3e72ec47c3ca1` · data `ApproveObligationOwnershipTransfer` · accounts `ApproveObligationOwnershipTransferInstructionAccounts`.

No data fields.

Required accounts: 4; extras go to `remaining`.

Fields of `ApproveObligationOwnershipTransferInstructionAccounts`, in account order:

| #  | Field           | Type               |
| -- | --------------- | ------------------ |
| 0  | `global_admin`  | `Pubkey`           |
| 1  | `global_config` | `Pubkey`           |
| 2  | `obligation`    | `Pubkey`           |
| 3  | `pending_owner` | `Pubkey`           |
| 4… | `remaining`     | `Vec<AccountMeta>` |

### `BorrowObligationLiquidity`

Discriminator `797f12cc49f5e141` · data `BorrowObligationLiquidity` · accounts `BorrowObligationLiquidityInstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 12; extras go to `remaining`.

Fields of `BorrowObligationLiquidityInstructionAccounts`, in account order:

| #   | Field                                   | Type               |
| --- | --------------------------------------- | ------------------ |
| 0   | `owner`                                 | `Pubkey`           |
| 1   | `obligation`                            | `Pubkey`           |
| 2   | `lending_market`                        | `Pubkey`           |
| 3   | `lending_market_authority`              | `Pubkey`           |
| 4   | `borrow_reserve`                        | `Pubkey`           |
| 5   | `borrow_reserve_liquidity_mint`         | `Pubkey`           |
| 6   | `reserve_source_liquidity`              | `Pubkey`           |
| 7   | `borrow_reserve_liquidity_fee_receiver` | `Pubkey`           |
| 8   | `user_destination_liquidity`            | `Pubkey`           |
| 9   | `referrer_token_state`                  | `Option<Pubkey>`   |
| 10  | `token_program`                         | `Pubkey`           |
| 11  | `instruction_sysvar_account`            | `Pubkey`           |
| 12… | `remaining`                             | `Vec<AccountMeta>` |

### `BorrowObligationLiquidityV2`

Discriminator `a1808ff5abc7c206` · data `BorrowObligationLiquidityV2` · accounts `BorrowObligationLiquidityV2InstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 15; extras go to `remaining`.

Fields of `BorrowObligationLiquidityV2InstructionAccounts`, in account order:

| #   | Field                                   | Type               |
| --- | --------------------------------------- | ------------------ |
| 0   | `owner`                                 | `Pubkey`           |
| 1   | `obligation`                            | `Pubkey`           |
| 2   | `lending_market`                        | `Pubkey`           |
| 3   | `lending_market_authority`              | `Pubkey`           |
| 4   | `borrow_reserve`                        | `Pubkey`           |
| 5   | `borrow_reserve_liquidity_mint`         | `Pubkey`           |
| 6   | `reserve_source_liquidity`              | `Pubkey`           |
| 7   | `borrow_reserve_liquidity_fee_receiver` | `Pubkey`           |
| 8   | `user_destination_liquidity`            | `Pubkey`           |
| 9   | `referrer_token_state`                  | `Option<Pubkey>`   |
| 10  | `token_program`                         | `Pubkey`           |
| 11  | `instruction_sysvar_account`            | `Pubkey`           |
| 12  | `obligation_farm_user_state`            | `Option<Pubkey>`   |
| 13  | `reserve_farm_state`                    | `Option<Pubkey>`   |
| 14  | `farms_program`                         | `Pubkey`           |
| 15… | `remaining`                             | `Vec<AccountMeta>` |

### `CancelWithdrawTicket`

Discriminator `b4537a2c78d32f16` · data `CancelWithdrawTicket` · accounts `CancelWithdrawTicketInstructionAccounts`.

| Field                         | Type  |
| ----------------------------- | ----- |
| `ticket_sequence_number`      | `u64` |
| `collateral_amount_to_cancel` | `u64` |

Required accounts: 9; extras go to `remaining`.

Fields of `CancelWithdrawTicketInstructionAccounts`, in account order:

| #  | Field                           | Type               |
| -- | ------------------------------- | ------------------ |
| 0  | `owner`                         | `Pubkey`           |
| 1  | `lending_market`                | `Pubkey`           |
| 2  | `lending_market_authority`      | `Pubkey`           |
| 3  | `reserve`                       | `Pubkey`           |
| 4  | `reserve_collateral_mint`       | `Pubkey`           |
| 5  | `owner_queued_collateral_vault` | `Pubkey`           |
| 6  | `user_destination_collateral`   | `Pubkey`           |
| 7  | `collateral_token_program`      | `Pubkey`           |
| 8  | `withdraw_ticket`               | `Pubkey`           |
| 9… | `remaining`                     | `Vec<AccountMeta>` |

### `CloneReserveConfig`

Discriminator `f405c671110a4721` · data `CloneReserveConfig` · accounts `CloneReserveConfigInstructionAccounts`.

| Field            | Type                                                                |
| ---------------- | ------------------------------------------------------------------- |
| `customizations` | [`ReserveConfigCustomizationArgs`](#reserveconfigcustomizationargs) |

Required accounts: 4; extras go to `remaining`.

Fields of `CloneReserveConfigInstructionAccounts`, in account order:

| #  | Field                   | Type               |
| -- | ----------------------- | ------------------ |
| 0  | `signer`                | `Pubkey`           |
| 1  | `target_lending_market` | `Pubkey`           |
| 2  | `source_reserve`        | `Pubkey`           |
| 3  | `target_reserve`        | `Pubkey`           |
| 4… | `remaining`             | `Vec<AccountMeta>` |

### `DeleteReferrerStateAndShortUrl`

Discriminator `99b9631ce4b3bb96` · data `DeleteReferrerStateAndShortUrl` · accounts `DeleteReferrerStateAndShortUrlInstructionAccounts`.

No data fields.

Required accounts: 5; extras go to `remaining`.

Fields of `DeleteReferrerStateAndShortUrlInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `referrer`       | `Pubkey`           |
| 1  | `referrer_state` | `Pubkey`           |
| 2  | `short_url`      | `Pubkey`           |
| 3  | `rent`           | `Pubkey`           |
| 4  | `system_program` | `Pubkey`           |
| 5… | `remaining`      | `Vec<AccountMeta>` |

### `DepositAndWithdraw`

Discriminator `8d99270f403d5854` · data `DepositAndWithdraw` · accounts `DepositAndWithdrawInstructionAccounts`.

| Field                        | Type  |
| ---------------------------- | ----- |
| `liquidity_amount`           | `u64` |
| `withdraw_collateral_amount` | `u64` |

Required accounts: 20; extras go to `remaining`.

Fields of `DepositAndWithdrawInstructionAccounts`, in account order:

| #   | Field                                     | Type               |
| --- | ----------------------------------------- | ------------------ |
| 0   | `owner`                                   | `Pubkey`           |
| 1   | `obligation`                              | `Pubkey`           |
| 2   | `lending_market`                          | `Pubkey`           |
| 3   | `lending_market_authority`                | `Pubkey`           |
| 4   | `reserve`                                 | `Pubkey`           |
| 5   | `reserve_liquidity_mint`                  | `Pubkey`           |
| 6   | `reserve_liquidity_supply`                | `Pubkey`           |
| 7   | `reserve_collateral_mint`                 | `Pubkey`           |
| 8   | `reserve_destination_deposit_collateral`  | `Pubkey`           |
| 9   | `user_source_liquidity`                   | `Pubkey`           |
| 10  | `placeholder_user_destination_collateral` | `Option<Pubkey>`   |
| 11  | `collateral_token_program`                | `Pubkey`           |
| 12  | `liquidity_token_program`                 | `Pubkey`           |
| 13  | `instruction_sysvar_account`              | `Pubkey`           |
| 14  | `withdraw_reserve`                        | `Pubkey`           |
| 15  | `reserve_source_collateral`               | `Pubkey`           |
| 16  | `user_destination_liquidity`              | `Pubkey`           |
| 17  | `obligation_farm_user_state`              | `Option<Pubkey>`   |
| 18  | `reserve_farm_state`                      | `Option<Pubkey>`   |
| 19  | `farms_program`                           | `Pubkey`           |
| 20… | `remaining`                               | `Vec<AccountMeta>` |

### `DepositObligationCollateral`

Discriminator `6cd1044815167685` · data `DepositObligationCollateral` · accounts `DepositObligationCollateralInstructionAccounts`.

| Field               | Type  |
| ------------------- | ----- |
| `collateral_amount` | `u64` |

Required accounts: 8; extras go to `remaining`.

Fields of `DepositObligationCollateralInstructionAccounts`, in account order:

| #  | Field                            | Type               |
| -- | -------------------------------- | ------------------ |
| 0  | `owner`                          | `Pubkey`           |
| 1  | `obligation`                     | `Pubkey`           |
| 2  | `lending_market`                 | `Pubkey`           |
| 3  | `deposit_reserve`                | `Pubkey`           |
| 4  | `reserve_destination_collateral` | `Pubkey`           |
| 5  | `user_source_collateral`         | `Pubkey`           |
| 6  | `token_program`                  | `Pubkey`           |
| 7  | `instruction_sysvar_account`     | `Pubkey`           |
| 8… | `remaining`                      | `Vec<AccountMeta>` |

### `DepositObligationCollateralV2`

Discriminator `8991975ea7710491` · data `DepositObligationCollateralV2` · accounts `DepositObligationCollateralV2InstructionAccounts`.

| Field               | Type  |
| ------------------- | ----- |
| `collateral_amount` | `u64` |

Required accounts: 12; extras go to `remaining`.

Fields of `DepositObligationCollateralV2InstructionAccounts`, in account order:

| #   | Field                            | Type               |
| --- | -------------------------------- | ------------------ |
| 0   | `owner`                          | `Pubkey`           |
| 1   | `obligation`                     | `Pubkey`           |
| 2   | `lending_market`                 | `Pubkey`           |
| 3   | `deposit_reserve`                | `Pubkey`           |
| 4   | `reserve_destination_collateral` | `Pubkey`           |
| 5   | `user_source_collateral`         | `Pubkey`           |
| 6   | `token_program`                  | `Pubkey`           |
| 7   | `instruction_sysvar_account`     | `Pubkey`           |
| 8   | `lending_market_authority`       | `Pubkey`           |
| 9   | `obligation_farm_user_state`     | `Option<Pubkey>`   |
| 10  | `reserve_farm_state`             | `Option<Pubkey>`   |
| 11  | `farms_program`                  | `Pubkey`           |
| 12… | `remaining`                      | `Vec<AccountMeta>` |

### `DepositReserveLiquidity`

Discriminator `a9c91e7e06cd6644` · data `DepositReserveLiquidity` · accounts `DepositReserveLiquidityInstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 12; extras go to `remaining`.

Fields of `DepositReserveLiquidityInstructionAccounts`, in account order:

| #   | Field                         | Type               |
| --- | ----------------------------- | ------------------ |
| 0   | `owner`                       | `Pubkey`           |
| 1   | `reserve`                     | `Pubkey`           |
| 2   | `lending_market`              | `Pubkey`           |
| 3   | `lending_market_authority`    | `Pubkey`           |
| 4   | `reserve_liquidity_mint`      | `Pubkey`           |
| 5   | `reserve_liquidity_supply`    | `Pubkey`           |
| 6   | `reserve_collateral_mint`     | `Pubkey`           |
| 7   | `user_source_liquidity`       | `Pubkey`           |
| 8   | `user_destination_collateral` | `Pubkey`           |
| 9   | `collateral_token_program`    | `Pubkey`           |
| 10  | `liquidity_token_program`     | `Pubkey`           |
| 11  | `instruction_sysvar_account`  | `Pubkey`           |
| 12… | `remaining`                   | `Vec<AccountMeta>` |

### `DepositReserveLiquidityAndObligationCollateral`

Discriminator `81c70402de271a2e` · data `DepositReserveLiquidityAndObligationCollateral` · accounts `DepositReserveLiquidityAndObligationCollateralInstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 14; extras go to `remaining`.

Fields of `DepositReserveLiquidityAndObligationCollateralInstructionAccounts`, in account order:

| #   | Field                                     | Type               |
| --- | ----------------------------------------- | ------------------ |
| 0   | `owner`                                   | `Pubkey`           |
| 1   | `obligation`                              | `Pubkey`           |
| 2   | `lending_market`                          | `Pubkey`           |
| 3   | `lending_market_authority`                | `Pubkey`           |
| 4   | `reserve`                                 | `Pubkey`           |
| 5   | `reserve_liquidity_mint`                  | `Pubkey`           |
| 6   | `reserve_liquidity_supply`                | `Pubkey`           |
| 7   | `reserve_collateral_mint`                 | `Pubkey`           |
| 8   | `reserve_destination_deposit_collateral`  | `Pubkey`           |
| 9   | `user_source_liquidity`                   | `Pubkey`           |
| 10  | `placeholder_user_destination_collateral` | `Option<Pubkey>`   |
| 11  | `collateral_token_program`                | `Pubkey`           |
| 12  | `liquidity_token_program`                 | `Pubkey`           |
| 13  | `instruction_sysvar_account`              | `Pubkey`           |
| 14… | `remaining`                               | `Vec<AccountMeta>` |

### `DepositReserveLiquidityAndObligationCollateralV2`

Discriminator `d8e0bf1bcc9766af` · data `DepositReserveLiquidityAndObligationCollateralV2` · accounts `DepositReserveLiquidityAndObligationCollateralV2InstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 17; extras go to `remaining`.

Fields of `DepositReserveLiquidityAndObligationCollateralV2InstructionAccounts`, in account order:

| #   | Field                                     | Type               |
| --- | ----------------------------------------- | ------------------ |
| 0   | `owner`                                   | `Pubkey`           |
| 1   | `obligation`                              | `Pubkey`           |
| 2   | `lending_market`                          | `Pubkey`           |
| 3   | `lending_market_authority`                | `Pubkey`           |
| 4   | `reserve`                                 | `Pubkey`           |
| 5   | `reserve_liquidity_mint`                  | `Pubkey`           |
| 6   | `reserve_liquidity_supply`                | `Pubkey`           |
| 7   | `reserve_collateral_mint`                 | `Pubkey`           |
| 8   | `reserve_destination_deposit_collateral`  | `Pubkey`           |
| 9   | `user_source_liquidity`                   | `Pubkey`           |
| 10  | `placeholder_user_destination_collateral` | `Option<Pubkey>`   |
| 11  | `collateral_token_program`                | `Pubkey`           |
| 12  | `liquidity_token_program`                 | `Pubkey`           |
| 13  | `instruction_sysvar_account`              | `Pubkey`           |
| 14  | `obligation_farm_user_state`              | `Option<Pubkey>`   |
| 15  | `reserve_farm_state`                      | `Option<Pubkey>`   |
| 16  | `farms_program`                           | `Pubkey`           |
| 17… | `remaining`                               | `Vec<AccountMeta>` |

### `EnqueueToWithdraw`

Discriminator `8671a0cf5a4bd5db` · data `EnqueueToWithdraw` · accounts `EnqueueToWithdrawInstructionAccounts`.

| Field                    | Type                                            |
| ------------------------ | ----------------------------------------------- |
| `collateral_amount`      | `u64`                                           |
| `progress_callback_type` | [`ProgressCallbackType`](#progresscallbacktype) |

Required accounts: 15; extras go to `remaining`.

Fields of `EnqueueToWithdrawInstructionAccounts`, in account order:

| #   | Field                               | Type               |
| --- | ----------------------------------- | ------------------ |
| 0   | `owner`                             | `Pubkey`           |
| 1   | `lending_market`                    | `Pubkey`           |
| 2   | `lending_market_authority`          | `Pubkey`           |
| 3   | `reserve`                           | `Pubkey`           |
| 4   | `user_source_collateral_ta`         | `Pubkey`           |
| 5   | `user_destination_liquidity_ta`     | `Pubkey`           |
| 6   | `reserve_liquidity_mint`            | `Pubkey`           |
| 7   | `reserve_collateral_mint`           | `Pubkey`           |
| 8   | `collateral_token_program`          | `Pubkey`           |
| 9   | `withdraw_ticket`                   | `Pubkey`           |
| 10  | `owner_queued_collateral_vault`     | `Pubkey`           |
| 11  | `system_program`                    | `Pubkey`           |
| 12  | `progress_callback_custom_account0` | `Option<Pubkey>`   |
| 13  | `progress_callback_custom_account1` | `Option<Pubkey>`   |
| 14  | `instruction_sysvar_account`        | `Pubkey`           |
| 15… | `remaining`                         | `Vec<AccountMeta>` |

### `FillBorrowOrder`

Discriminator `6604a74c83aa5d13` · data `FillBorrowOrder` · accounts `FillBorrowOrderInstructionAccounts`.

No data fields.

Required accounts: 17; extras go to `remaining`.

Fields of `FillBorrowOrderInstructionAccounts`, in account order:

| #   | Field                                   | Type               |
| --- | --------------------------------------- | ------------------ |
| 0   | `payer`                                 | `Pubkey`           |
| 1   | `obligation`                            | `Pubkey`           |
| 2   | `lending_market`                        | `Pubkey`           |
| 3   | `lending_market_authority`              | `Pubkey`           |
| 4   | `borrow_reserve`                        | `Pubkey`           |
| 5   | `borrow_reserve_liquidity_mint`         | `Pubkey`           |
| 6   | `reserve_source_liquidity`              | `Pubkey`           |
| 7   | `borrow_reserve_liquidity_fee_receiver` | `Pubkey`           |
| 8   | `user_destination_liquidity`            | `Pubkey`           |
| 9   | `referrer_token_state`                  | `Option<Pubkey>`   |
| 10  | `token_program`                         | `Pubkey`           |
| 11  | `instruction_sysvar_account`            | `Pubkey`           |
| 12  | `obligation_farm_user_state`            | `Option<Pubkey>`   |
| 13  | `reserve_farm_state`                    | `Option<Pubkey>`   |
| 14  | `farms_program`                         | `Pubkey`           |
| 15  | `event_authority`                       | `Pubkey`           |
| 16  | `program`                               | `Pubkey`           |
| 17… | `remaining`                             | `Vec<AccountMeta>` |

### `FlashBorrowReserveLiquidity`

Discriminator `87e734a70734d4c1` · data `FlashBorrowReserveLiquidity` · accounts `FlashBorrowReserveLiquidityInstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 12; extras go to `remaining`.

Fields of `FlashBorrowReserveLiquidityInstructionAccounts`, in account order:

| #   | Field                            | Type               |
| --- | -------------------------------- | ------------------ |
| 0   | `user_transfer_authority`        | `Pubkey`           |
| 1   | `lending_market_authority`       | `Pubkey`           |
| 2   | `lending_market`                 | `Pubkey`           |
| 3   | `reserve`                        | `Pubkey`           |
| 4   | `reserve_liquidity_mint`         | `Pubkey`           |
| 5   | `reserve_source_liquidity`       | `Pubkey`           |
| 6   | `user_destination_liquidity`     | `Pubkey`           |
| 7   | `reserve_liquidity_fee_receiver` | `Pubkey`           |
| 8   | `referrer_token_state`           | `Option<Pubkey>`   |
| 9   | `referrer_account`               | `Option<Pubkey>`   |
| 10  | `sysvar_info`                    | `Pubkey`           |
| 11  | `token_program`                  | `Pubkey`           |
| 12… | `remaining`                      | `Vec<AccountMeta>` |

### `FlashRepayReserveLiquidity`

Discriminator `b97500cb60f5b4ba` · data `FlashRepayReserveLiquidity` · accounts `FlashRepayReserveLiquidityInstructionAccounts`.

| Field                      | Type  |
| -------------------------- | ----- |
| `liquidity_amount`         | `u64` |
| `borrow_instruction_index` | `u8`  |

Required accounts: 12; extras go to `remaining`.

Fields of `FlashRepayReserveLiquidityInstructionAccounts`, in account order:

| #   | Field                            | Type               |
| --- | -------------------------------- | ------------------ |
| 0   | `user_transfer_authority`        | `Pubkey`           |
| 1   | `lending_market_authority`       | `Pubkey`           |
| 2   | `lending_market`                 | `Pubkey`           |
| 3   | `reserve`                        | `Pubkey`           |
| 4   | `reserve_liquidity_mint`         | `Pubkey`           |
| 5   | `reserve_destination_liquidity`  | `Pubkey`           |
| 6   | `user_source_liquidity`          | `Pubkey`           |
| 7   | `reserve_liquidity_fee_receiver` | `Pubkey`           |
| 8   | `referrer_token_state`           | `Option<Pubkey>`   |
| 9   | `referrer_account`               | `Option<Pubkey>`   |
| 10  | `sysvar_info`                    | `Pubkey`           |
| 11  | `token_program`                  | `Pubkey`           |
| 12… | `remaining`                      | `Vec<AccountMeta>` |

### `IdlMissingTypes`

Discriminator `8250269950d4b6fd` · data `IdlMissingTypes` · accounts `IdlMissingTypesInstructionAccounts`.

| Field                                | Type                                                                |
| ------------------------------------ | ------------------------------------------------------------------- |
| `reserve_farm_kind`                  | [`ReserveFarmKind`](#reservefarmkind)                               |
| `fee_calculation`                    | [`FeeCalculation`](#feecalculation)                                 |
| `reserve_status`                     | [`ReserveStatus`](#reservestatus)                                   |
| `update_config_mode`                 | [`UpdateConfigMode`](#updateconfigmode)                             |
| `update_lending_market_config_value` | [`UpdateLendingMarketConfigValue`](#updatelendingmarketconfigvalue) |
| `update_lending_market_config_mode`  | [`UpdateLendingMarketMode`](#updatelendingmarketmode)               |

Required accounts: 4; extras go to `remaining`.

Fields of `IdlMissingTypesInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `signer`         | `Pubkey`           |
| 1  | `global_config`  | `Pubkey`           |
| 2  | `lending_market` | `Pubkey`           |
| 3  | `reserve`        | `Pubkey`           |
| 4… | `remaining`      | `Vec<AccountMeta>` |

### `InitFarmsForReserve`

Discriminator `da063ee90121e852` · data `InitFarmsForReserve` · accounts `InitFarmsForReserveInstructionAccounts`.

| Field  | Type |
| ------ | ---- |
| `mode` | `u8` |

Required accounts: 10; extras go to `remaining`.

Fields of `InitFarmsForReserveInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `lending_market_owner`     | `Pubkey`           |
| 1   | `lending_market`           | `Pubkey`           |
| 2   | `lending_market_authority` | `Pubkey`           |
| 3   | `reserve`                  | `Pubkey`           |
| 4   | `farms_program`            | `Pubkey`           |
| 5   | `farms_global_config`      | `Pubkey`           |
| 6   | `farm_state`               | `Pubkey`           |
| 7   | `farms_vault_authority`    | `Pubkey`           |
| 8   | `rent`                     | `Pubkey`           |
| 9   | `system_program`           | `Pubkey`           |
| 10… | `remaining`                | `Vec<AccountMeta>` |

### `InitGlobalConfig`

Discriminator `8c88d630570078ff` · data `InitGlobalConfig` · accounts `InitGlobalConfigInstructionAccounts`.

No data fields.

Required accounts: 5; extras go to `remaining`.

Fields of `InitGlobalConfigInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `payer`          | `Pubkey`           |
| 1  | `global_config`  | `Pubkey`           |
| 2  | `program_data`   | `Pubkey`           |
| 3  | `system_program` | `Pubkey`           |
| 4  | `rent`           | `Pubkey`           |
| 5… | `remaining`      | `Vec<AccountMeta>` |

### `InitiateObligationOwnershipTransfer`

Discriminator `7f2a51da93ab4c99` · data `InitiateObligationOwnershipTransfer` · accounts `InitiateObligationOwnershipTransferInstructionAccounts`.

| Field       | Type     |
| ----------- | -------- |
| `new_owner` | `Pubkey` |

Required accounts: 3; extras go to `remaining`.

Fields of `InitiateObligationOwnershipTransferInstructionAccounts`, in account order:

| #  | Field                        | Type               |
| -- | ---------------------------- | ------------------ |
| 0  | `owner`                      | `Pubkey`           |
| 1  | `obligation`                 | `Pubkey`           |
| 2  | `instruction_sysvar_account` | `Pubkey`           |
| 3… | `remaining`                  | `Vec<AccountMeta>` |

### `InitLendingMarket`

Discriminator `22a2740e65895eef` · data `InitLendingMarket` · accounts `InitLendingMarketInstructionAccounts`.

| Field            | Type       |
| ---------------- | ---------- |
| `quote_currency` | `[u8; 32]` |

Required accounts: 5; extras go to `remaining`.

Fields of `InitLendingMarketInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `lending_market_owner`     | `Pubkey`           |
| 1  | `lending_market`           | `Pubkey`           |
| 2  | `lending_market_authority` | `Pubkey`           |
| 3  | `system_program`           | `Pubkey`           |
| 4  | `rent`                     | `Pubkey`           |
| 5… | `remaining`                | `Vec<AccountMeta>` |

### `InitObligation`

Discriminator `fb0ae74c1b0b9f60` · data `InitObligation` · accounts `InitObligationInstructionAccounts`.

| Field  | Type                                        |
| ------ | ------------------------------------------- |
| `args` | [`InitObligationArgs`](#initobligationargs) |

Required accounts: 9; extras go to `remaining`.

Fields of `InitObligationInstructionAccounts`, in account order:

| #  | Field                 | Type               |
| -- | --------------------- | ------------------ |
| 0  | `obligation_owner`    | `Pubkey`           |
| 1  | `fee_payer`           | `Pubkey`           |
| 2  | `obligation`          | `Pubkey`           |
| 3  | `lending_market`      | `Pubkey`           |
| 4  | `seed1_account`       | `Pubkey`           |
| 5  | `seed2_account`       | `Pubkey`           |
| 6  | `owner_user_metadata` | `Pubkey`           |
| 7  | `rent`                | `Pubkey`           |
| 8  | `system_program`      | `Pubkey`           |
| 9… | `remaining`           | `Vec<AccountMeta>` |

### `InitObligationFarmsForReserve`

Discriminator `883f0fbad398a8a4` · data `InitObligationFarmsForReserve` · accounts `InitObligationFarmsForReserveInstructionAccounts`.

| Field  | Type |
| ------ | ---- |
| `mode` | `u8` |

Required accounts: 11; extras go to `remaining`.

Fields of `InitObligationFarmsForReserveInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `payer`                    | `Pubkey`           |
| 1   | `owner`                    | `Pubkey`           |
| 2   | `obligation`               | `Pubkey`           |
| 3   | `lending_market_authority` | `Pubkey`           |
| 4   | `reserve`                  | `Pubkey`           |
| 5   | `reserve_farm_state`       | `Pubkey`           |
| 6   | `obligation_farm`          | `Pubkey`           |
| 7   | `lending_market`           | `Pubkey`           |
| 8   | `farms_program`            | `Pubkey`           |
| 9   | `rent`                     | `Pubkey`           |
| 10  | `system_program`           | `Pubkey`           |
| 11… | `remaining`                | `Vec<AccountMeta>` |

### `InitReferrerStateAndShortUrl`

Discriminator `a513197f64371f5a` · data `InitReferrerStateAndShortUrl` · accounts `InitReferrerStateAndShortUrlInstructionAccounts`.

| Field       | Type     |
| ----------- | -------- |
| `short_url` | `String` |

Required accounts: 6; extras go to `remaining`.

Fields of `InitReferrerStateAndShortUrlInstructionAccounts`, in account order:

| #  | Field                    | Type               |
| -- | ------------------------ | ------------------ |
| 0  | `referrer`               | `Pubkey`           |
| 1  | `referrer_state`         | `Pubkey`           |
| 2  | `referrer_short_url`     | `Pubkey`           |
| 3  | `referrer_user_metadata` | `Pubkey`           |
| 4  | `rent`                   | `Pubkey`           |
| 5  | `system_program`         | `Pubkey`           |
| 6… | `remaining`              | `Vec<AccountMeta>` |

### `InitReferrerTokenState`

Discriminator `742d42943a0dda73` · data `InitReferrerTokenState` · accounts `InitReferrerTokenStateInstructionAccounts`.

No data fields.

Required accounts: 7; extras go to `remaining`.

Fields of `InitReferrerTokenStateInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `payer`                | `Pubkey`           |
| 1  | `lending_market`       | `Pubkey`           |
| 2  | `reserve`              | `Pubkey`           |
| 3  | `referrer`             | `Pubkey`           |
| 4  | `referrer_token_state` | `Pubkey`           |
| 5  | `rent`                 | `Pubkey`           |
| 6  | `system_program`       | `Pubkey`           |
| 7… | `remaining`            | `Vec<AccountMeta>` |

### `InitReserve`

Discriminator `8af547e19904032b` · data `InitReserve` · accounts `InitReserveInstructionAccounts`.

No data fields.

Required accounts: 14; extras go to `remaining`.

Fields of `InitReserveInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `signer`                    | `Pubkey`           |
| 1   | `lending_market`            | `Pubkey`           |
| 2   | `lending_market_authority`  | `Pubkey`           |
| 3   | `reserve`                   | `Pubkey`           |
| 4   | `reserve_liquidity_mint`    | `Pubkey`           |
| 5   | `reserve_liquidity_supply`  | `Pubkey`           |
| 6   | `fee_receiver`              | `Pubkey`           |
| 7   | `reserve_collateral_mint`   | `Pubkey`           |
| 8   | `reserve_collateral_supply` | `Pubkey`           |
| 9   | `initial_liquidity_source`  | `Pubkey`           |
| 10  | `rent`                      | `Pubkey`           |
| 11  | `liquidity_token_program`   | `Pubkey`           |
| 12  | `collateral_token_program`  | `Pubkey`           |
| 13  | `system_program`            | `Pubkey`           |
| 14… | `remaining`                 | `Vec<AccountMeta>` |

### `InitUserMetadata`

Discriminator `75a9b045c5170fa2` · data `InitUserMetadata` · accounts `InitUserMetadataInstructionAccounts`.

| Field               | Type     |
| ------------------- | -------- |
| `user_lookup_table` | `Pubkey` |

Required accounts: 6; extras go to `remaining`.

Fields of `InitUserMetadataInstructionAccounts`, in account order:

| #  | Field                    | Type               |
| -- | ------------------------ | ------------------ |
| 0  | `owner`                  | `Pubkey`           |
| 1  | `fee_payer`              | `Pubkey`           |
| 2  | `user_metadata`          | `Pubkey`           |
| 3  | `referrer_user_metadata` | `Option<Pubkey>`   |
| 4  | `rent`                   | `Pubkey`           |
| 5  | `system_program`         | `Pubkey`           |
| 6… | `remaining`              | `Vec<AccountMeta>` |

### `LiquidateObligationAndRedeemReserveCollateral`

Discriminator `b1479abce2854a37` · data `LiquidateObligationAndRedeemReserveCollateral` · accounts `LiquidateObligationAndRedeemReserveCollateralInstructionAccounts`.

| Field                                      | Type  |
| ------------------------------------------ | ----- |
| `liquidity_amount`                         | `u64` |
| `min_acceptable_received_liquidity_amount` | `u64` |
| `max_allowed_ltv_override_percent`         | `u64` |

Required accounts: 20; extras go to `remaining`.

Fields of `LiquidateObligationAndRedeemReserveCollateralInstructionAccounts`, in account order:

| #   | Field                                     | Type               |
| --- | ----------------------------------------- | ------------------ |
| 0   | `liquidator`                              | `Pubkey`           |
| 1   | `obligation`                              | `Pubkey`           |
| 2   | `lending_market`                          | `Pubkey`           |
| 3   | `lending_market_authority`                | `Pubkey`           |
| 4   | `repay_reserve`                           | `Pubkey`           |
| 5   | `repay_reserve_liquidity_mint`            | `Pubkey`           |
| 6   | `repay_reserve_liquidity_supply`          | `Pubkey`           |
| 7   | `withdraw_reserve`                        | `Pubkey`           |
| 8   | `withdraw_reserve_liquidity_mint`         | `Pubkey`           |
| 9   | `withdraw_reserve_collateral_mint`        | `Pubkey`           |
| 10  | `withdraw_reserve_collateral_supply`      | `Pubkey`           |
| 11  | `withdraw_reserve_liquidity_supply`       | `Pubkey`           |
| 12  | `withdraw_reserve_liquidity_fee_receiver` | `Pubkey`           |
| 13  | `user_source_liquidity`                   | `Pubkey`           |
| 14  | `user_destination_collateral`             | `Pubkey`           |
| 15  | `user_destination_liquidity`              | `Pubkey`           |
| 16  | `collateral_token_program`                | `Pubkey`           |
| 17  | `repay_liquidity_token_program`           | `Pubkey`           |
| 18  | `withdraw_liquidity_token_program`        | `Pubkey`           |
| 19  | `instruction_sysvar_account`              | `Pubkey`           |
| 20… | `remaining`                               | `Vec<AccountMeta>` |

### `LiquidateObligationAndRedeemReserveCollateralV2`

Discriminator `a2a1238f1ebbb967` · data `LiquidateObligationAndRedeemReserveCollateralV2` · accounts `LiquidateObligationAndRedeemReserveCollateralV2InstructionAccounts`.

| Field                                      | Type  |
| ------------------------------------------ | ----- |
| `liquidity_amount`                         | `u64` |
| `min_acceptable_received_liquidity_amount` | `u64` |
| `max_allowed_ltv_override_percent`         | `u64` |

Required accounts: 23; extras go to `remaining`.

Fields of `LiquidateObligationAndRedeemReserveCollateralV2InstructionAccounts`, in account order:

| #   | Field                                     | Type               |
| --- | ----------------------------------------- | ------------------ |
| 0   | `liquidator`                              | `Pubkey`           |
| 1   | `obligation`                              | `Pubkey`           |
| 2   | `lending_market`                          | `Pubkey`           |
| 3   | `lending_market_authority`                | `Pubkey`           |
| 4   | `repay_reserve`                           | `Pubkey`           |
| 5   | `repay_reserve_liquidity_mint`            | `Pubkey`           |
| 6   | `repay_reserve_liquidity_supply`          | `Pubkey`           |
| 7   | `withdraw_reserve`                        | `Pubkey`           |
| 8   | `withdraw_reserve_liquidity_mint`         | `Pubkey`           |
| 9   | `withdraw_reserve_collateral_mint`        | `Pubkey`           |
| 10  | `withdraw_reserve_collateral_supply`      | `Pubkey`           |
| 11  | `withdraw_reserve_liquidity_supply`       | `Pubkey`           |
| 12  | `withdraw_reserve_liquidity_fee_receiver` | `Pubkey`           |
| 13  | `user_source_liquidity`                   | `Pubkey`           |
| 14  | `user_destination_collateral`             | `Pubkey`           |
| 15  | `user_destination_liquidity`              | `Pubkey`           |
| 16  | `collateral_token_program`                | `Pubkey`           |
| 17  | `repay_liquidity_token_program`           | `Pubkey`           |
| 18  | `withdraw_liquidity_token_program`        | `Pubkey`           |
| 19  | `instruction_sysvar_account`              | `Pubkey`           |
| 20  | `obligation_farm_user_state`              | `Option<Pubkey>`   |
| 21  | `reserve_farm_state`                      | `Option<Pubkey>`   |
| 22  | `farms_program`                           | `Pubkey`           |
| 23… | `remaining`                               | `Vec<AccountMeta>` |

### `MarkObligationForDeleveraging`

Discriminator `a423b6130074f37f` · data `MarkObligationForDeleveraging` · accounts `MarkObligationForDeleveragingInstructionAccounts`.

| Field                           | Type |
| ------------------------------- | ---- |
| `autodeleverage_target_ltv_pct` | `u8` |

Required accounts: 3; extras go to `remaining`.

Fields of `MarkObligationForDeleveragingInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `lending_market_owner` | `Pubkey`           |
| 1  | `obligation`           | `Pubkey`           |
| 2  | `lending_market`       | `Pubkey`           |
| 3… | `remaining`            | `Vec<AccountMeta>` |

### `RecoverInvalidTicketCollateral`

Discriminator `1c30b0669fced2f6` · data `RecoverInvalidTicketCollateral` · accounts `RecoverInvalidTicketCollateralInstructionAccounts`.

| Field                    | Type  |
| ------------------------ | ----- |
| `ticket_sequence_number` | `u64` |

Required accounts: 11; extras go to `remaining`.

Fields of `RecoverInvalidTicketCollateralInstructionAccounts`, in account order:

| #   | Field                           | Type               |
| --- | ------------------------------- | ------------------ |
| 0   | `payer`                         | `Pubkey`           |
| 1   | `lending_market`                | `Pubkey`           |
| 2   | `lending_market_authority`      | `Pubkey`           |
| 3   | `reserve`                       | `Pubkey`           |
| 4   | `reserve_collateral_mint`       | `Pubkey`           |
| 5   | `owner_queued_collateral_vault` | `Pubkey`           |
| 6   | `user_source_collateral`        | `Pubkey`           |
| 7   | `collateral_token_program`      | `Pubkey`           |
| 8   | `withdraw_ticket`               | `Pubkey`           |
| 9   | `withdraw_ticket_owner`         | `Pubkey`           |
| 10  | `instruction_sysvar_account`    | `Pubkey`           |
| 11… | `remaining`                     | `Vec<AccountMeta>` |

### `RedeemFees`

Discriminator `d727b429ad2ef8dc` · data `RedeemFees` · accounts `RedeemFeesInstructionAccounts`.

No data fields.

Required accounts: 7; extras go to `remaining`.

Fields of `RedeemFeesInstructionAccounts`, in account order:

| #  | Field                            | Type               |
| -- | -------------------------------- | ------------------ |
| 0  | `reserve`                        | `Pubkey`           |
| 1  | `reserve_liquidity_mint`         | `Pubkey`           |
| 2  | `reserve_liquidity_fee_receiver` | `Pubkey`           |
| 3  | `reserve_supply_liquidity`       | `Pubkey`           |
| 4  | `lending_market`                 | `Pubkey`           |
| 5  | `lending_market_authority`       | `Pubkey`           |
| 6  | `token_program`                  | `Pubkey`           |
| 7… | `remaining`                      | `Vec<AccountMeta>` |

### `RedeemReserveCollateral`

Discriminator `ea75b57db98edc1d` · data `RedeemReserveCollateral` · accounts `RedeemReserveCollateralInstructionAccounts`.

| Field               | Type  |
| ------------------- | ----- |
| `collateral_amount` | `u64` |

Required accounts: 12; extras go to `remaining`.

Fields of `RedeemReserveCollateralInstructionAccounts`, in account order:

| #   | Field                        | Type               |
| --- | ---------------------------- | ------------------ |
| 0   | `owner`                      | `Pubkey`           |
| 1   | `lending_market`             | `Pubkey`           |
| 2   | `reserve`                    | `Pubkey`           |
| 3   | `lending_market_authority`   | `Pubkey`           |
| 4   | `reserve_liquidity_mint`     | `Pubkey`           |
| 5   | `reserve_collateral_mint`    | `Pubkey`           |
| 6   | `reserve_liquidity_supply`   | `Pubkey`           |
| 7   | `user_source_collateral`     | `Pubkey`           |
| 8   | `user_destination_liquidity` | `Pubkey`           |
| 9   | `collateral_token_program`   | `Pubkey`           |
| 10  | `liquidity_token_program`    | `Pubkey`           |
| 11  | `instruction_sysvar_account` | `Pubkey`           |
| 12… | `remaining`                  | `Vec<AccountMeta>` |

### `RefreshObligation`

Discriminator `218493e497c04859` · data `RefreshObligation` · accounts `RefreshObligationInstructionAccounts`.

No data fields.

Required accounts: 2; extras go to `remaining`.

Fields of `RefreshObligationInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `lending_market` | `Pubkey`           |
| 1  | `obligation`     | `Pubkey`           |
| 2… | `remaining`      | `Vec<AccountMeta>` |

### `RefreshObligationFarmsForReserve`

Discriminator `8c90fd150a4af803` · data `RefreshObligationFarmsForReserve` · accounts `RefreshObligationFarmsForReserveInstructionAccounts`.

| Field  | Type |
| ------ | ---- |
| `mode` | `u8` |

Required accounts: 10; extras go to `remaining`.

Fields of `RefreshObligationFarmsForReserveInstructionAccounts`, in account order:

| #   | Field                        | Type               |
| --- | ---------------------------- | ------------------ |
| 0   | `crank`                      | `Pubkey`           |
| 1   | `obligation`                 | `Pubkey`           |
| 2   | `lending_market_authority`   | `Pubkey`           |
| 3   | `reserve`                    | `Pubkey`           |
| 4   | `reserve_farm_state`         | `Pubkey`           |
| 5   | `obligation_farm_user_state` | `Pubkey`           |
| 6   | `lending_market`             | `Pubkey`           |
| 7   | `farms_program`              | `Pubkey`           |
| 8   | `rent`                       | `Pubkey`           |
| 9   | `system_program`             | `Pubkey`           |
| 10… | `remaining`                  | `Vec<AccountMeta>` |

### `RefreshReserve`

Discriminator `02da8aeb4fc91966` · data `RefreshReserve` · accounts `RefreshReserveInstructionAccounts`.

No data fields.

Required accounts: 2 (6 listed); extras go to `remaining`.

Fields of `RefreshReserveInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `reserve`                  | `Pubkey`           |
| 1  | `lending_market`           | `Pubkey`           |
| 2  | `pyth_oracle`              | `Option<Pubkey>`   |
| 3  | `switchboard_price_oracle` | `Option<Pubkey>`   |
| 4  | `switchboard_twap_oracle`  | `Option<Pubkey>`   |
| 5  | `scope_prices`             | `Option<Pubkey>`   |
| 6… | `remaining`                | `Vec<AccountMeta>` |

### `RefreshReservesBatch`

Discriminator `906e1a67a2ccfc93` · data `RefreshReservesBatch` · accounts `RefreshReservesBatchInstructionAccounts`.

| Field                | Type   |
| -------------------- | ------ |
| `skip_price_updates` | `bool` |

No named accounts.

### `RepayAndWithdrawAndRedeem`

Discriminator `0236980394606dda` · data `RepayAndWithdrawAndRedeem` · accounts `RepayAndWithdrawAndRedeemInstructionAccounts`.

| Field                        | Type  |
| ---------------------------- | ----- |
| `repay_amount`               | `u64` |
| `withdraw_collateral_amount` | `u64` |

Required accounts: 21; extras go to `remaining`.

Fields of `RepayAndWithdrawAndRedeemInstructionAccounts`, in account order:

| #   | Field                                     | Type               |
| --- | ----------------------------------------- | ------------------ |
| 0   | `owner`                                   | `Pubkey`           |
| 1   | `obligation`                              | `Pubkey`           |
| 2   | `lending_market`                          | `Pubkey`           |
| 3   | `repay_reserve`                           | `Pubkey`           |
| 4   | `reserve_liquidity_mint`                  | `Pubkey`           |
| 5   | `reserve_destination_liquidity`           | `Pubkey`           |
| 6   | `user_source_liquidity`                   | `Pubkey`           |
| 7   | `token_program`                           | `Pubkey`           |
| 8   | `instruction_sysvar_account`              | `Pubkey`           |
| 9   | `lending_market_authority`                | `Pubkey`           |
| 10  | `withdraw_reserve`                        | `Pubkey`           |
| 11  | `reserve_source_collateral`               | `Pubkey`           |
| 12  | `reserve_collateral_mint`                 | `Pubkey`           |
| 13  | `reserve_liquidity_supply`                | `Pubkey`           |
| 14  | `user_destination_liquidity`              | `Pubkey`           |
| 15  | `placeholder_user_destination_collateral` | `Option<Pubkey>`   |
| 16  | `collateral_token_program`                | `Pubkey`           |
| 17  | `liquidity_token_program`                 | `Pubkey`           |
| 18  | `obligation_farm_user_state`              | `Option<Pubkey>`   |
| 19  | `reserve_farm_state`                      | `Option<Pubkey>`   |
| 20  | `farms_program`                           | `Pubkey`           |
| 21… | `remaining`                               | `Vec<AccountMeta>` |

### `RepayObligationLiquidity`

Discriminator `91b20de14cf09348` · data `RepayObligationLiquidity` · accounts `RepayObligationLiquidityInstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 9; extras go to `remaining`.

Fields of `RepayObligationLiquidityInstructionAccounts`, in account order:

| #  | Field                           | Type               |
| -- | ------------------------------- | ------------------ |
| 0  | `owner`                         | `Pubkey`           |
| 1  | `obligation`                    | `Pubkey`           |
| 2  | `lending_market`                | `Pubkey`           |
| 3  | `repay_reserve`                 | `Pubkey`           |
| 4  | `reserve_liquidity_mint`        | `Pubkey`           |
| 5  | `reserve_destination_liquidity` | `Pubkey`           |
| 6  | `user_source_liquidity`         | `Pubkey`           |
| 7  | `token_program`                 | `Pubkey`           |
| 8  | `instruction_sysvar_account`    | `Pubkey`           |
| 9… | `remaining`                     | `Vec<AccountMeta>` |

### `RepayObligationLiquidityV2`

Discriminator `74aed54cb435d290` · data `RepayObligationLiquidityV2` · accounts `RepayObligationLiquidityV2InstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 13; extras go to `remaining`.

Fields of `RepayObligationLiquidityV2InstructionAccounts`, in account order:

| #   | Field                           | Type               |
| --- | ------------------------------- | ------------------ |
| 0   | `owner`                         | `Pubkey`           |
| 1   | `obligation`                    | `Pubkey`           |
| 2   | `lending_market`                | `Pubkey`           |
| 3   | `repay_reserve`                 | `Pubkey`           |
| 4   | `reserve_liquidity_mint`        | `Pubkey`           |
| 5   | `reserve_destination_liquidity` | `Pubkey`           |
| 6   | `user_source_liquidity`         | `Pubkey`           |
| 7   | `token_program`                 | `Pubkey`           |
| 8   | `instruction_sysvar_account`    | `Pubkey`           |
| 9   | `obligation_farm_user_state`    | `Option<Pubkey>`   |
| 10  | `reserve_farm_state`            | `Option<Pubkey>`   |
| 11  | `lending_market_authority`      | `Pubkey`           |
| 12  | `farms_program`                 | `Pubkey`           |
| 13… | `remaining`                     | `Vec<AccountMeta>` |

### `RequestElevationGroup`

Discriminator `2477fb8122f00793` · data `RequestElevationGroup` · accounts `RequestElevationGroupInstructionAccounts`.

| Field             | Type |
| ----------------- | ---- |
| `elevation_group` | `u8` |

Required accounts: 3; extras go to `remaining`.

Fields of `RequestElevationGroupInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `owner`          | `Pubkey`           |
| 1  | `obligation`     | `Pubkey`           |
| 2  | `lending_market` | `Pubkey`           |
| 3… | `remaining`      | `Vec<AccountMeta>` |

### `RolloverFixedTermBorrow`

Discriminator `551e9be1e0ba8d94` · data `RolloverFixedTermBorrow` · accounts `RolloverFixedTermBorrowInstructionAccounts`.

No data fields.

Required accounts: 13; extras go to `remaining`.

Fields of `RolloverFixedTermBorrowInstructionAccounts`, in account order:

| #   | Field                             | Type               |
| --- | --------------------------------- | ------------------ |
| 0   | `payer`                           | `Pubkey`           |
| 1   | `obligation`                      | `Pubkey`           |
| 2   | `lending_market`                  | `Pubkey`           |
| 3   | `lending_market_authority`        | `Pubkey`           |
| 4   | `source_borrow_reserve`           | `Pubkey`           |
| 5   | `target_borrow_reserve`           | `Pubkey`           |
| 6   | `liquidity_mint`                  | `Pubkey`           |
| 7   | `source_borrow_reserve_liquidity` | `Pubkey`           |
| 8   | `target_borrow_reserve_liquidity` | `Pubkey`           |
| 9   | `token_program`                   | `Pubkey`           |
| 10  | `obligation_farm_user_state`      | `Option<Pubkey>`   |
| 11  | `reserve_farm_state`              | `Option<Pubkey>`   |
| 12  | `farms_program`                   | `Pubkey`           |
| 13… | `remaining`                       | `Vec<AccountMeta>` |

### `SeedDepositOnInitReserve`

Discriminator `fec5e476b7ce3ee2` · data `SeedDepositOnInitReserve` · accounts `SeedDepositOnInitReserveInstructionAccounts`.

No data fields.

Required accounts: 7; extras go to `remaining`.

Fields of `SeedDepositOnInitReserveInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `signer`                   | `Pubkey`           |
| 1  | `lending_market`           | `Pubkey`           |
| 2  | `reserve`                  | `Pubkey`           |
| 3  | `reserve_liquidity_mint`   | `Pubkey`           |
| 4  | `reserve_liquidity_supply` | `Pubkey`           |
| 5  | `initial_liquidity_source` | `Pubkey`           |
| 6  | `liquidity_token_program`  | `Pubkey`           |
| 7… | `remaining`                | `Vec<AccountMeta>` |

### `SetBorrowOrder`

Discriminator `b1ba2d3deb5b448b` · data `SetBorrowOrder` · accounts `SetBorrowOrderInstructionAccounts`.

| Field                                        | Type                                              |
| -------------------------------------------- | ------------------------------------------------- |
| `order_config`                               | [`BorrowOrderConfigArgs`](#borroworderconfigargs) |
| `min_expected_current_remaining_debt_amount` | `u64`                                             |

Required accounts: 9; extras go to `remaining`.

Fields of `SetBorrowOrderInstructionAccounts`, in account order:

| #  | Field                        | Type               |
| -- | ---------------------------- | ------------------ |
| 0  | `owner`                      | `Pubkey`           |
| 1  | `obligation`                 | `Pubkey`           |
| 2  | `lending_market`             | `Pubkey`           |
| 3  | `reserve`                    | `Pubkey`           |
| 4  | `filled_debt_destination`    | `Pubkey`           |
| 5  | `debt_liquidity_mint`        | `Pubkey`           |
| 6  | `instruction_sysvar_account` | `Pubkey`           |
| 7  | `event_authority`            | `Pubkey`           |
| 8  | `program`                    | `Pubkey`           |
| 9… | `remaining`                  | `Vec<AccountMeta>` |

### `SetObligationOrder`

Discriminator `5101639cd3534e2e` · data `SetObligationOrder` · accounts `SetObligationOrderInstructionAccounts`.

| Field   | Type                                  |
| ------- | ------------------------------------- |
| `index` | `u8`                                  |
| `order` | [`ObligationOrder`](#obligationorder) |

Required accounts: 3; extras go to `remaining`.

Fields of `SetObligationOrderInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `owner`          | `Pubkey`           |
| 1  | `obligation`     | `Pubkey`           |
| 2  | `lending_market` | `Pubkey`           |
| 3… | `remaining`      | `Vec<AccountMeta>` |

### `SocializeLoss`

Discriminator `f54b5b00ec611303` · data `SocializeLoss` · accounts `SocializeLossInstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 5; extras go to `remaining`.

Fields of `SocializeLossInstructionAccounts`, in account order:

| #  | Field                        | Type               |
| -- | ---------------------------- | ------------------ |
| 0  | `lending_market_owner`       | `Pubkey`           |
| 1  | `obligation`                 | `Pubkey`           |
| 2  | `lending_market`             | `Pubkey`           |
| 3  | `reserve`                    | `Pubkey`           |
| 4  | `instruction_sysvar_account` | `Pubkey`           |
| 5… | `remaining`                  | `Vec<AccountMeta>` |

### `SocializeLossV2`

Discriminator `ee5f62dcbb28cc9a` · data `SocializeLossV2` · accounts `SocializeLossV2InstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `liquidity_amount` | `u64` |

Required accounts: 9; extras go to `remaining`.

Fields of `SocializeLossV2InstructionAccounts`, in account order:

| #  | Field                        | Type               |
| -- | ---------------------------- | ------------------ |
| 0  | `lending_market_owner`       | `Pubkey`           |
| 1  | `obligation`                 | `Pubkey`           |
| 2  | `lending_market`             | `Pubkey`           |
| 3  | `reserve`                    | `Pubkey`           |
| 4  | `instruction_sysvar_account` | `Pubkey`           |
| 5  | `obligation_farm_user_state` | `Option<Pubkey>`   |
| 6  | `reserve_farm_state`         | `Option<Pubkey>`   |
| 7  | `lending_market_authority`   | `Pubkey`           |
| 8  | `farms_program`              | `Pubkey`           |
| 9… | `remaining`                  | `Vec<AccountMeta>` |

### `TopupReserveRewards`

> _From the program's IDL:_
>
> Sponsor a reserve's rewards distribution by topping up its `rewards_amount_available` budget.

Discriminator `3fff82d36ed858ad` · data `TopupReserveRewards` · accounts `TopupReserveRewardsInstructionAccounts`.

| Field    | Type  |
| -------- | ----- |
| `amount` | `u64` |

Required accounts: 7; extras go to `remaining`.

Fields of `TopupReserveRewardsInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `signer`                   | `Pubkey`           |
| 1  | `lending_market`           | `Pubkey`           |
| 2  | `reserve`                  | `Pubkey`           |
| 3  | `reserve_liquidity_mint`   | `Pubkey`           |
| 4  | `reserve_liquidity_supply` | `Pubkey`           |
| 5  | `source_liquidity`         | `Pubkey`           |
| 6  | `liquidity_token_program`  | `Pubkey`           |
| 7… | `remaining`                | `Vec<AccountMeta>` |

### `UpdateGlobalConfig`

Discriminator `a45482bd6f3afac8` · data `UpdateGlobalConfig` · accounts `UpdateGlobalConfigInstructionAccounts`.

| Field   | Type                                                |
| ------- | --------------------------------------------------- |
| `mode`  | [`UpdateGlobalConfigMode`](#updateglobalconfigmode) |
| `value` | `Vec<u8>`                                           |

Required accounts: 2; extras go to `remaining`.

Fields of `UpdateGlobalConfigInstructionAccounts`, in account order:

| #  | Field           | Type               |
| -- | --------------- | ------------------ |
| 0  | `global_admin`  | `Pubkey`           |
| 1  | `global_config` | `Pubkey`           |
| 2… | `remaining`     | `Vec<AccountMeta>` |

### `UpdateGlobalConfigAdmin`

Discriminator `b85717c19ceeaf77` · data `UpdateGlobalConfigAdmin` · accounts `UpdateGlobalConfigAdminInstructionAccounts`.

No data fields.

Required accounts: 2; extras go to `remaining`.

Fields of `UpdateGlobalConfigAdminInstructionAccounts`, in account order:

| #  | Field           | Type               |
| -- | --------------- | ------------------ |
| 0  | `pending_admin` | `Pubkey`           |
| 1  | `global_config` | `Pubkey`           |
| 2… | `remaining`     | `Vec<AccountMeta>` |

### `UpdateLendingMarket`

Discriminator `d19d35d261b41f2d` · data `UpdateLendingMarket` · accounts `UpdateLendingMarketInstructionAccounts`.

| Field   | Type       |
| ------- | ---------- |
| `mode`  | `u64`      |
| `value` | `[u8; 72]` |

Required accounts: 2; extras go to `remaining`.

Fields of `UpdateLendingMarketInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `signer`         | `Pubkey`           |
| 1  | `lending_market` | `Pubkey`           |
| 2… | `remaining`      | `Vec<AccountMeta>` |

### `UpdateLendingMarketOwner`

Discriminator `76e00a3ec4e6b859` · data `UpdateLendingMarketOwner` · accounts `UpdateLendingMarketOwnerInstructionAccounts`.

No data fields.

Required accounts: 2; extras go to `remaining`.

Fields of `UpdateLendingMarketOwnerInstructionAccounts`, in account order:

| #  | Field                         | Type               |
| -- | ----------------------------- | ------------------ |
| 0  | `lending_market_owner_cached` | `Pubkey`           |
| 1  | `lending_market`              | `Pubkey`           |
| 2… | `remaining`                   | `Vec<AccountMeta>` |

### `UpdateObligationConfig`

Discriminator `5298d545fa009dbc` · data `UpdateObligationConfig` · accounts `UpdateObligationConfigInstructionAccounts`.

| Field   | Type                                                        |
| ------- | ----------------------------------------------------------- |
| `mode`  | [`UpdateObligationConfigMode`](#updateobligationconfigmode) |
| `value` | `Vec<u8>`                                                   |

Required accounts: 5; extras go to `remaining`.

Fields of `UpdateObligationConfigInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `owner`           | `Pubkey`           |
| 1  | `obligation`      | `Pubkey`           |
| 2  | `borrow_reserve`  | `Option<Pubkey>`   |
| 3  | `deposit_reserve` | `Option<Pubkey>`   |
| 4  | `lending_market`  | `Pubkey`           |
| 5… | `remaining`       | `Vec<AccountMeta>` |

### `UpdateReserveConfig`

Discriminator `3d9464468f6b110d` · data `UpdateReserveConfig` · accounts `UpdateReserveConfigInstructionAccounts`.

| Field                              | Type                                    |
| ---------------------------------- | --------------------------------------- |
| `mode`                             | [`UpdateConfigMode`](#updateconfigmode) |
| `value`                            | `Vec<u8>`                               |
| `skip_config_integrity_validation` | `bool`                                  |

Required accounts: 4; extras go to `remaining`.

Fields of `UpdateReserveConfigInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `signer`         | `Pubkey`           |
| 1  | `global_config`  | `Pubkey`           |
| 2  | `lending_market` | `Pubkey`           |
| 3  | `reserve`        | `Pubkey`           |
| 4… | `remaining`      | `Vec<AccountMeta>` |

### `WithdrawObligationCollateral`

Discriminator `2574cd67f3c05cc6` · data `WithdrawObligationCollateral` · accounts `WithdrawObligationCollateralInstructionAccounts`.

| Field               | Type  |
| ------------------- | ----- |
| `collateral_amount` | `u64` |

Required accounts: 9; extras go to `remaining`.

Fields of `WithdrawObligationCollateralInstructionAccounts`, in account order:

| #  | Field                         | Type               |
| -- | ----------------------------- | ------------------ |
| 0  | `owner`                       | `Pubkey`           |
| 1  | `obligation`                  | `Pubkey`           |
| 2  | `lending_market`              | `Pubkey`           |
| 3  | `lending_market_authority`    | `Pubkey`           |
| 4  | `withdraw_reserve`            | `Pubkey`           |
| 5  | `reserve_source_collateral`   | `Pubkey`           |
| 6  | `user_destination_collateral` | `Pubkey`           |
| 7  | `token_program`               | `Pubkey`           |
| 8  | `instruction_sysvar_account`  | `Pubkey`           |
| 9… | `remaining`                   | `Vec<AccountMeta>` |

### `WithdrawObligationCollateralAndRedeemReserveCollateral`

Discriminator `4b5d5ddc2296dac4` · data `WithdrawObligationCollateralAndRedeemReserveCollateral` · accounts `WithdrawObligationCollateralAndRedeemReserveCollateralInstructionAccounts`.

| Field               | Type  |
| ------------------- | ----- |
| `collateral_amount` | `u64` |

Required accounts: 14; extras go to `remaining`.

Fields of `WithdrawObligationCollateralAndRedeemReserveCollateralInstructionAccounts`, in account order:

| #   | Field                                     | Type               |
| --- | ----------------------------------------- | ------------------ |
| 0   | `owner`                                   | `Pubkey`           |
| 1   | `obligation`                              | `Pubkey`           |
| 2   | `lending_market`                          | `Pubkey`           |
| 3   | `lending_market_authority`                | `Pubkey`           |
| 4   | `withdraw_reserve`                        | `Pubkey`           |
| 5   | `reserve_liquidity_mint`                  | `Pubkey`           |
| 6   | `reserve_source_collateral`               | `Pubkey`           |
| 7   | `reserve_collateral_mint`                 | `Pubkey`           |
| 8   | `reserve_liquidity_supply`                | `Pubkey`           |
| 9   | `user_destination_liquidity`              | `Pubkey`           |
| 10  | `placeholder_user_destination_collateral` | `Option<Pubkey>`   |
| 11  | `collateral_token_program`                | `Pubkey`           |
| 12  | `liquidity_token_program`                 | `Pubkey`           |
| 13  | `instruction_sysvar_account`              | `Pubkey`           |
| 14… | `remaining`                               | `Vec<AccountMeta>` |

### `WithdrawObligationCollateralAndRedeemReserveCollateralV2`

Discriminator `eb34779895c51407` · data `WithdrawObligationCollateralAndRedeemReserveCollateralV2` · accounts `WithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionAccounts`.

| Field               | Type  |
| ------------------- | ----- |
| `collateral_amount` | `u64` |

Required accounts: 17; extras go to `remaining`.

Fields of `WithdrawObligationCollateralAndRedeemReserveCollateralV2InstructionAccounts`, in account order:

| #   | Field                                     | Type               |
| --- | ----------------------------------------- | ------------------ |
| 0   | `owner`                                   | `Pubkey`           |
| 1   | `obligation`                              | `Pubkey`           |
| 2   | `lending_market`                          | `Pubkey`           |
| 3   | `lending_market_authority`                | `Pubkey`           |
| 4   | `withdraw_reserve`                        | `Pubkey`           |
| 5   | `reserve_liquidity_mint`                  | `Pubkey`           |
| 6   | `reserve_source_collateral`               | `Pubkey`           |
| 7   | `reserve_collateral_mint`                 | `Pubkey`           |
| 8   | `reserve_liquidity_supply`                | `Pubkey`           |
| 9   | `user_destination_liquidity`              | `Pubkey`           |
| 10  | `placeholder_user_destination_collateral` | `Option<Pubkey>`   |
| 11  | `collateral_token_program`                | `Pubkey`           |
| 12  | `liquidity_token_program`                 | `Pubkey`           |
| 13  | `instruction_sysvar_account`              | `Pubkey`           |
| 14  | `obligation_farm_user_state`              | `Option<Pubkey>`   |
| 15  | `reserve_farm_state`                      | `Option<Pubkey>`   |
| 16  | `farms_program`                           | `Pubkey`           |
| 17… | `remaining`                               | `Vec<AccountMeta>` |

### `WithdrawObligationCollateralV2`

Discriminator `caf97572e7c02f8a` · data `WithdrawObligationCollateralV2` · accounts `WithdrawObligationCollateralV2InstructionAccounts`.

| Field               | Type  |
| ------------------- | ----- |
| `collateral_amount` | `u64` |

Required accounts: 12; extras go to `remaining`.

Fields of `WithdrawObligationCollateralV2InstructionAccounts`, in account order:

| #   | Field                         | Type               |
| --- | ----------------------------- | ------------------ |
| 0   | `owner`                       | `Pubkey`           |
| 1   | `obligation`                  | `Pubkey`           |
| 2   | `lending_market`              | `Pubkey`           |
| 3   | `lending_market_authority`    | `Pubkey`           |
| 4   | `withdraw_reserve`            | `Pubkey`           |
| 5   | `reserve_source_collateral`   | `Pubkey`           |
| 6   | `user_destination_collateral` | `Pubkey`           |
| 7   | `token_program`               | `Pubkey`           |
| 8   | `instruction_sysvar_account`  | `Pubkey`           |
| 9   | `obligation_farm_user_state`  | `Option<Pubkey>`   |
| 10  | `reserve_farm_state`          | `Option<Pubkey>`   |
| 11  | `farms_program`               | `Pubkey`           |
| 12… | `remaining`                   | `Vec<AccountMeta>` |

### `WithdrawProtocolFee`

Discriminator `9ec99ebd215da267` · data `WithdrawProtocolFee` · accounts `WithdrawProtocolFeeInstructionAccounts`.

| Field    | Type  |
| -------- | ----- |
| `amount` | `u64` |

Required accounts: 8; extras go to `remaining`.

Fields of `WithdrawProtocolFeeInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `global_config`            | `Pubkey`           |
| 1  | `lending_market`           | `Pubkey`           |
| 2  | `reserve`                  | `Pubkey`           |
| 3  | `reserve_liquidity_mint`   | `Pubkey`           |
| 4  | `lending_market_authority` | `Pubkey`           |
| 5  | `fee_vault`                | `Pubkey`           |
| 6  | `fee_collector_ata`        | `Pubkey`           |
| 7  | `token_program`            | `Pubkey`           |
| 8… | `remaining`                | `Vec<AccountMeta>` |

### `WithdrawQueuedLiquidity`

Discriminator `4295bbc94abfae78` · data `WithdrawQueuedLiquidity` · accounts `WithdrawQueuedLiquidityInstructionAccounts`.

No data fields.

Required accounts: 19; extras go to `remaining`.

Fields of `WithdrawQueuedLiquidityInstructionAccounts`, in account order:

| #   | Field                               | Type               |
| --- | ----------------------------------- | ------------------ |
| 0   | `payer`                             | `Pubkey`           |
| 1   | `lending_market`                    | `Pubkey`           |
| 2   | `lending_market_authority`          | `Pubkey`           |
| 3   | `reserve`                           | `Pubkey`           |
| 4   | `reserve_liquidity_mint`            | `Pubkey`           |
| 5   | `reserve_collateral_mint`           | `Pubkey`           |
| 6   | `reserve_liquidity_supply`          | `Pubkey`           |
| 7   | `owner_queued_collateral_vault`     | `Pubkey`           |
| 8   | `user_destination_liquidity`        | `Pubkey`           |
| 9   | `collateral_token_program`          | `Pubkey`           |
| 10  | `liquidity_token_program`           | `Pubkey`           |
| 11  | `withdraw_ticket`                   | `Pubkey`           |
| 12  | `withdraw_ticket_owner`             | `Pubkey`           |
| 13  | `associated_token_program`          | `Pubkey`           |
| 14  | `system_program`                    | `Pubkey`           |
| 15  | `progress_callback_program`         | `Option<Pubkey>`   |
| 16  | `progress_callback_custom_account0` | `Option<Pubkey>`   |
| 17  | `progress_callback_custom_account1` | `Option<Pubkey>`   |
| 18  | `instruction_sysvar_account`        | `Pubkey`           |
| 19… | `remaining`                         | `Vec<AccountMeta>` |

### `WithdrawReferrerFees`

Discriminator `ab7679c9e98c17e4` · data `WithdrawReferrerFees` · accounts `WithdrawReferrerFeesInstructionAccounts`.

No data fields.

Required accounts: 9; extras go to `remaining`.

Fields of `WithdrawReferrerFeesInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `referrer`                 | `Pubkey`           |
| 1  | `referrer_token_state`     | `Pubkey`           |
| 2  | `reserve`                  | `Pubkey`           |
| 3  | `reserve_liquidity_mint`   | `Pubkey`           |
| 4  | `reserve_supply_liquidity` | `Pubkey`           |
| 5  | `referrer_token_account`   | `Pubkey`           |
| 6  | `lending_market`           | `Pubkey`           |
| 7  | `lending_market_authority` | `Pubkey`           |
| 8  | `token_program`            | `Pubkey`           |
| 9… | `remaining`                | `Vec<AccountMeta>` |

### `CpiEvent`

Anchor self-CPI that carries one of the program's [events](#events). `data` is the `CpiEvent` enum.

Discriminator `e445a52e51cb9a1d` · data `CpiEvent` · accounts `CpiEventInstructionAccounts`.

Required accounts: 2; extras go to `remaining`.

Fields of `CpiEventInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `program`         | `Pubkey`           |
| 1  | `event_authority` | `Pubkey`           |
| 2… | `remaining`       | `Vec<AccountMeta>` |

## Accounts

Variants of `KaminoLendingAccount`. Each wraps a boxed struct from `carbon_kamino_lending_decoder::accounts::<module>`. `decode_account` only considers accounts owned by `PROGRAM_ID` and returns the first variant that matches.

### `GlobalConfig`

Discriminator `95089ccaa0fcb0d9` · `accounts::global_config::GlobalConfig`.

| Field           | Type        | Description                                                                       |
| --------------- | ----------- | --------------------------------------------------------------------------------- |
| `global_admin`  | `Pubkey`    | Global admin of the program                                                       |
| `pending_admin` | `Pubkey`    | Pending admin must sign a specific transaction to become the global admin         |
| `fee_collector` | `Pubkey`    | Fee collector is the only allowed owner of token accounts receiving protocol fees |
| `padding`       | `[u8; 928]` | Padding to make the struct size 1024 bytes                                        |

### `LendingMarket`

Discriminator `f6723262489d1c78` · `accounts::lending_market::LendingMarket`.

| Field                                                    | Type                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| -------------------------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `version`                                                | `u64`                                     | Version of lending market                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `bump_seed`                                              | `u64`                                     | Bump seed for derived authority address                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `lending_market_owner`                                   | `Pubkey`                                  | Owner authority which can add new reserves                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `lending_market_owner_cached`                            | `Pubkey`                                  | Temporary cache of the lending market owner, used in update_lending_market_owner                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `quote_currency`                                         | `[u8; 32]`                                | Currency market prices are quoted in e.g. "USD" null padded (`*b"USD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"`) or a SPL token mint pubkey                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `referral_fee_bps`                                       | `u16`                                     | Referral fee for the lending market, as bps out of the total protocol fee                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `emergency_mode`                                         | `u8`                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `autodeleverage_enabled`                                 | `u8`                                      | Whether the obligations on this market should be subject to auto-deleveraging after deposit or borrow limit is crossed. Besides this flag, the particular reserve's flag also needs to be enabled (logical `AND`). **NOTE:** this also affects the individual "target LTV" deleveraging.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `borrow_disabled`                                        | `u8`                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `price_refresh_trigger_to_max_age_pct`                   | `u8`                                      | Refresh price from oracle only if it's older than this percentage of the price max age. e.g. if the max age is set to 100s and this is set to 80%, the price will be refreshed if it's older than 80s. Price is always refreshed if this set to 0.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `liquidation_max_debt_close_factor_pct`                  | `u8`                                      | Percentage of the total borrowed value in an obligation available for liquidation                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `insolvency_risk_unhealthy_ltv_pct`                      | `u8`                                      | Minimum acceptable unhealthy LTV before max_debt_close_factor_pct becomes 100%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `min_full_liquidation_value_threshold`                   | `u64`                                     | Minimum liquidation value threshold triggering full liquidation for an obligation, in full units of the quote currency (e.g. `2` means "$2", not "2 lamports of USDC").                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `max_liquidatable_debt_market_value_at_once`             | `u64`                                     | Max allowed liquidation value in one ix call                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `reserved0`                                              | `[u8; 8]`                                 | \[DEPRECATED] Global maximum unhealthy borrow value allowed for any obligation                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `global_allowed_borrow_value`                            | `u64`                                     | Global maximum allowed borrow value allowed for any obligation                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `emergency_council`                                      | `Pubkey`                                  | The address of the emergency council, in charge of taking emergency actions on the market (e.g., enabling emergency mode)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `reserved1`                                              | `[u8; 8]`                                 | \[DEPRECATED] Reward points multiplier per obligation type                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `elevation_groups`                                       | [`[ElevationGroup; 32]`](#elevationgroup) | Elevation groups are used to group together reserves that have the same risk parameters and can bump the ltv and liquidation threshold                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `elevation_group_padding`                                | `[u64; 90]`                               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `min_net_value_in_obligation_sf`                         | `u128`                                    | Min net value accepted to be found in a position after any lending action in an obligation (scaled by quote currency decimals)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `min_value_skip_liquidation_ltv_checks`                  | `u64`                                     | Minimum value to enforce smallest ltv priority checks on the collateral reserves on liquidation                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `name`                                                   | `[u8; 32]`                                | Market name, zero-padded.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `min_value_skip_liquidation_bf_checks`                   | `u64`                                     | Minimum value to enforce highest borrow factor priority checks on the debt reserves on liquidation                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `individual_autodeleverage_margin_call_period_secs`      | `u64`                                     | Time (in seconds) that must pass before liquidation is allowed on an obligation that has been individually marked for auto-deleveraging.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `min_initial_deposit_amount`                             | `u64`                                     | Minimum amount of deposit at creation of a reserve to prevent artificial inflation Note: this amount cannot be recovered, the ctoken associated are never minted                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `obligation_order_execution_enabled`                     | `u8`                                      | Whether the obligation orders should be evaluated during liquidations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `immutable`                                              | `u8`                                      | Whether the lending market is set as immutable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `obligation_order_creation_enabled`                      | `u8`                                      | Whether new obligation orders can be created. Note: updating or cancelling existing orders is _not_ affected by this flag.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `price_triggered_liquidation_disabled`                   | `u8`                                      | Whether the liquidation operations that are triggered by price changes should be disabled. This includes regular liquidation (i.e. LTV exceeding the unhealthy threshold) and some obligation orders' execution. _Caution:_ this flag is _disabling_ the liquidations when `1` - contrary to all the other liquidation-driving flags (see e.g. \[Self::autodeleverage_enabled]).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `mature_reserve_debt_liquidation_enabled`                | `u8`                                      | Whether the debts that reached their reserve's \[ReserveConfig::debt_maturity_timestamp] can be liquidated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `obligation_borrow_debt_term_liquidation_enabled`        | `u8`                                      | Whether the \[Obligation::borrows] that reached their \[ReserveConfig::debt_term_seconds] can be liquidated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `borrow_order_creation_enabled`                          | `u8`                                      | Whether new borrow orders can be created. Note: updating or cancelling existing orders is _not_ affected by this flag.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `borrow_order_execution_enabled`                         | `u8`                                      | Whether the existing borrow orders can be filled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `proposer_authority`                                     | `Pubkey`                                  | Authority that can propose creating of new reserves but cannot enable them.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `min_borrow_order_fill_value`                            | `u64`                                     | Minimum value that can be filled in a single `fill_borrow_order()` call, in full units of the quote currency (e.g. `2` means "$2", not "2 lamports of USDC").                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `withdraw_ticket_issuance_enabled`                       | `u8`                                      | Whether any new withdraw tickets can be issued (i.e. whether new requests can enter the withdraw queue).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `withdraw_ticket_redemption_enabled`                     | `u8`                                      | Whether the existing withdraw tickets can be redeemed (i.e. whether the tickets can be used to transfer accumulated pending liquidity to destination accounts).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `obligation_borrow_rollover_configuration_enabled`       | `u8`                                      | Whether the owners can enable the borrow rollover/migration on their obligations. _Note 1:_ the actual execution of (different kinds of) rollovers are enabled/disabled by: - \[Self::fixed_term_rollover_window_duration_seconds], - \[Self::open_term_rollover_window_duration_seconds], - \[Self::obligation_borrow_migration_to_fixed_execution_enabled]. _Note 2:_ when this configuration is disabled, the obligation owners can still disable their rollover (i.e. set the obligation's flags to zeroes).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `obligation_borrow_migration_to_fixed_execution_enabled` | `u8`                                      | Whether the actual execution of a "migration to fixed" rollover flavor is allowed. See \[FixedTermBorrowRolloverConfig::migration_to_fixed_enabled].                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `withdraw_ticket_cancellation_enabled`                   | `u8`                                      | Whether the ticket owners can cancel their withdraw tickets (i.e. recover ctokens from the queued collateral vault back to their wallet).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `padding2`                                               | `[u8; 1]`                                 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `reserve_rewards_max_apr_bps`                            | `u16`                                     | Maximum APR (in basis points; `FULL_BPS = 10_000` = 100%) at which reserves on this market may distribute their `rewards_amount_per_slot`. `0` disables rewards on this market entirely (`topup_reserve_rewards` is rejected). Bounded by `FULL_BPS` (100% APR) when set. See \[ReserveConfig::rewards_amount_per_slot] for the depositor-cap interaction.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `min_withdraw_queued_liquidity_value`                    | `u64`                                     | Minimum value that can be withdrawn in a single `withdraw_queued_liquidity()` call, in full units of the quote currency (e.g. `2` means "$2", not "2 lamports of USDC").                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `fixed_term_rollover_window_duration_seconds`            | `u64`                                     | A configurable time window (right before the end of a fixed debt term) during which an auto-rollover into another _fixed_ rate/term can happen. When zeroed, this rollover mode is effectively disabled. Can only be enabled when \[Self::min_partial_rollover_value] is configured. See \[FixedTermBorrowRolloverConfig].                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `open_term_rollover_window_duration_seconds`             | `u64`                                     | A configurable time window (right before the end of a fixed debt term) during which an auto-rollover into a _variable_ (indefinite) rate/term can happen. When zeroed, this rollover mode is effectively disabled. Can only be enabled when \[Self::min_partial_rollover_value] is configured. This will typically be shorter than \[Self::fixed_term_rollover_window_duration_seconds], acting as a fallback if a fixed reserve liquidity remains unavailable for considerable time.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `min_partial_rollover_value`                             | `u64`                                     | Minimum dollar value for a partial rollover into a different reserve. When the achievable rollover amount is below this threshold (and it's not a full rollover), the rollover is rejected. In full units of the quote currency (e.g. `2` means "$2").                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `term_based_full_liquidation_duration_secs`              | `u64`                                     | The time that must pass before an entire expired debt becomes liquidatable. For example: Let's assume this duration is configured as 100 seconds; then: - right after fixed-term debt expiration, effectively no debt can be liquidated. - 30 seconds after expiration, we allow to 30% of the expired debt to be liquidated - to be specific: at this point in time, we "protect" from liquidation 70% of the \[ObligationLiquidity::borrowed_amount_at_expiration] (regardless of how much interest was accrued or how much debt was repaid while expired). - 100 seconds after expiration we allow the entire debt to be liquidated. Only effective when \[Self::obligation_borrow_debt_term_liquidation_enabled]. Motivation note: this throttling feature gives an opportunity to execute a configured auto-rollover (after a partial liquidation brings the debt size down so that there is enough available liquidity in some compatible reserve). When zeroed, an entire expired debt can be liquidated right after expiration (i.e. no throttling). |
| `permissioning_authority`                                | `Pubkey`                                  | If not NULL, operations encoded in permissioned_ops require a signature from this authority                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `permissioned_ops`                                       | `u64`                                     | Bitmap of operations that require permissioning authority signature                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `padding1`                                               | `[u64; 153]`                              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

### `Obligation`

> _From the program's IDL:_
>
> Lending market obligation state

Discriminator `a8ce8d6a584caca7` · `accounts::obligation::Obligation`.

| Field                                          | Type                                                 | Description                                                                                                                                                    |
| ---------------------------------------------- | ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tag`                                          | `u64`                                                | Version of the struct                                                                                                                                          |
| `last_update`                                  | [`LastUpdate`](#lastupdate)                          | Last update to collateral, liquidity, or their market values                                                                                                   |
| `lending_market`                               | `Pubkey`                                             | Lending market address                                                                                                                                         |
| `owner`                                        | `Pubkey`                                             | Owner authority which can borrow liquidity                                                                                                                     |
| `deposits`                                     | [`[ObligationCollateral; 8]`](#obligationcollateral) | Deposited collateral for the obligation, unique by deposit reserve address                                                                                     |
| `lowest_reserve_deposit_liquidation_ltv`       | `u64`                                                | Worst LTV for the collaterals backing the loan, represented as a percentage                                                                                    |
| `deposited_value_sf`                           | `u128`                                               | Market value of deposits (scaled fraction)                                                                                                                     |
| `borrows`                                      | [`[ObligationLiquidity; 5]`](#obligationliquidity)   | Borrowed liquidity for the obligation, unique by borrow reserve address                                                                                        |
| `borrow_factor_adjusted_debt_value_sf`         | `u128`                                               | Risk adjusted market value of borrows/debt (sum of price \* borrowed_amount \* borrow_factor) (scaled fraction)                                                |
| `borrowed_assets_market_value_sf`              | `u128`                                               | Market value of borrows - used for max_liquidatable_borrowed_amount (scaled fraction)                                                                          |
| `allowed_borrow_value_sf`                      | `u128`                                               | The maximum borrow value at the weighted average loan to value ratio (scaled fraction)                                                                         |
| `unhealthy_borrow_value_sf`                    | `u128`                                               | The dangerous borrow value at the weighted average liquidation threshold (scaled fraction)                                                                     |
| `padding_deprecated_asset_tiers`               | `[u8; 13]`                                           | The asset tier of the deposits                                                                                                                                 |
| `elevation_group`                              | `u8`                                                 | The elevation group id the obligation opted into.                                                                                                              |
| `num_of_obsolete_deposit_reserves`             | `u8`                                                 | The number of obsolete reserves the obligation has a deposit in                                                                                                |
| `has_debt`                                     | `u8`                                                 | Marked = 1 if borrows array is not empty, 0 = borrows empty                                                                                                    |
| `referrer`                                     | `Pubkey`                                             | Wallet address of the referrer                                                                                                                                 |
| `borrowing_disabled`                           | `u8`                                                 | Marked = 1 if borrowing disabled, 0 = borrowing enabled                                                                                                        |
| `autodeleverage_target_ltv_pct`                | `u8`                                                 | A target LTV set by the market owner when marking this obligation for deleveraging. Only effective when `deleveraging_margin_call_started_slot != 0`.          |
| `lowest_reserve_deposit_max_ltv_pct`           | `u8`                                                 | The lowest max LTV found amongst the collateral deposits                                                                                                       |
| `num_of_obsolete_borrow_reserves`              | `u8`                                                 | The number of obsolete reserves the obligation has a borrow in                                                                                                 |
| `ownership_transfer_state`                     | `u8`                                                 | State of ownership transfer, see \[OwnershipTransferState]                                                                                                     |
| `reserved`                                     | `[u8; 3]`                                            |                                                                                                                                                                |
| `highest_borrow_factor_pct`                    | `u64`                                                |                                                                                                                                                                |
| `autodeleverage_margin_call_started_timestamp` | `u64`                                                | A timestamp at which the market owner most-recently marked this obligation for deleveraging. Zero if not currently subject to deleveraging.                    |
| `obligation_orders`                            | [`[ObligationOrder; 2]`](#obligationorder)           | Owner-defined, permissionlessly-executed repay orders. Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).                        |
| `borrow_order`                                 | [`BorrowOrder`](#borroworder)                        | Owner-defined, permissionlessly-executed borrow order applicable to this obligation. Non-zeroed only on a newly-initialized fixed-rate, fixed-term obligation. |
| `pending_owner`                                | `Pubkey`                                             | Pending owner during ownership transfer process. Pubkey::default() means no pending owner (similar to Option::None)                                            |
| `padding3`                                     | `[u64; 69]`                                          |                                                                                                                                                                |

### `ReferrerState`

Discriminator `c251d9670c130c42` · `accounts::referrer_state::ReferrerState`.

| Field       | Type     |
| ----------- | -------- |
| `short_url` | `Pubkey` |
| `owner`     | `Pubkey` |

### `ReferrerTokenState`

> _From the program's IDL:_
>
> Referrer account -> each owner can have multiple accounts for specific reserves

Discriminator `270fd04d20c36938` · `accounts::referrer_token_state::ReferrerTokenState`.

| Field                  | Type        | Description                                                                                       |
| ---------------------- | ----------- | ------------------------------------------------------------------------------------------------- |
| `referrer`             | `Pubkey`    | Pubkey of the referrer/owner                                                                      |
| `mint`                 | `Pubkey`    | Token mint for the account                                                                        |
| `amount_unclaimed_sf`  | `u128`      | Amount that has been accumulated and not claimed yet -> available to claim (scaled fraction)      |
| `amount_cumulative_sf` | `u128`      | Amount that has been accumulated in total -> both already claimed and unclaimed (scaled fraction) |
| `bump`                 | `u64`       | Referrer token state bump, used for address validation                                            |
| `padding`              | `[u64; 31]` |                                                                                                   |

### `Reserve`

Discriminator `2bf2ccca1af73b7f` · `accounts::reserve::Reserve`.

| Field                                                       | Type                                      | Description                                                                                                                  |
| ----------------------------------------------------------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `version`                                                   | `u64`                                     | Version of the reserve                                                                                                       |
| `last_update`                                               | [`LastUpdate`](#lastupdate)               | Last slot when supply and rates updated                                                                                      |
| `lending_market`                                            | `Pubkey`                                  | Lending market address                                                                                                       |
| `farm_collateral`                                           | `Pubkey`                                  |                                                                                                                              |
| `farm_debt`                                                 | `Pubkey`                                  |                                                                                                                              |
| `liquidity`                                                 | [`ReserveLiquidity`](#reserveliquidity)   | Reserve liquidity                                                                                                            |
| `reserve_liquidity_padding`                                 | `[u64; 150]`                              |                                                                                                                              |
| `collateral`                                                | [`ReserveCollateral`](#reservecollateral) | Reserve collateral                                                                                                           |
| `reserve_collateral_padding`                                | `[u64; 150]`                              |                                                                                                                              |
| `config`                                                    | [`ReserveConfig`](#reserveconfig)         | Reserve configuration values                                                                                                 |
| `config_padding`                                            | `[u64; 113]`                              |                                                                                                                              |
| `borrowed_amount_outside_elevation_group`                   | `u64`                                     |                                                                                                                              |
| `borrowed_amounts_against_this_reserve_in_elevation_groups` | `[u64; 32]`                               | Amount of token borrowed in lamport of debt asset in the given elevation group when this reserve is part of the collaterals. |
| `withdraw_queue`                                            | [`WithdrawQueue`](#withdrawqueue)         | The tracker of ticket-based withdrawals.                                                                                     |
| `padding`                                                   | `[u64; 204]`                              |                                                                                                                              |

### `ShortUrl`

Discriminator `1c59ae19e27c7ed4` · `accounts::short_url::ShortUrl`.

| Field       | Type     |
| ----------- | -------- |
| `referrer`  | `Pubkey` |
| `short_url` | `String` |

### `UserMetadata`

> _From the program's IDL:_
>
> Referrer account -> each owner can have multiple accounts for specific reserves

Discriminator `9dd6dceb6287ab1c` · `accounts::user_metadata::UserMetadata`.

| Field               | Type        | Description                                                                                                                                                                     |
| ------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `referrer`          | `Pubkey`    | Pubkey of the referrer/owner - pubkey::default if no referrer                                                                                                                   |
| `bump`              | `u64`       | Bump used for validation of account address                                                                                                                                     |
| `user_lookup_table` | `Pubkey`    | User lookup table - used to store all user accounts - atas for each reserve mint, each obligation PDA, UserMetadata itself and all referrer_token_states if there is a referrer |
| `owner`             | `Pubkey`    | User metadata account owner                                                                                                                                                     |
| `padding1`          | `[u64; 51]` |                                                                                                                                                                                 |
| `padding2`          | `[u64; 64]` |                                                                                                                                                                                 |

### `UserState`

Discriminator `48b155f94ca7ba7e` · `accounts::user_state::UserState`.

| Field                               | Type         |
| ----------------------------------- | ------------ |
| `user_id`                           | `u64`        |
| `farm_state`                        | `Pubkey`     |
| `owner`                             | `Pubkey`     |
| `is_farm_delegated`                 | `u8`         |
| `padding0`                          | `[u8; 7]`    |
| `rewards_tally_scaled`              | `[u128; 10]` |
| `rewards_issued_unclaimed`          | `[u64; 10]`  |
| `last_claim_ts`                     | `[u64; 10]`  |
| `active_stake_scaled`               | `u128`       |
| `pending_deposit_stake_scaled`      | `u128`       |
| `pending_deposit_stake_ts`          | `u64`        |
| `pending_withdrawal_unstake_scaled` | `u128`       |
| `pending_withdrawal_unstake_ts`     | `u64`        |
| `bump`                              | `u64`        |
| `delegatee`                         | `Pubkey`     |
| `last_stake_ts`                     | `u64`        |
| `padding1`                          | `[u64; 50]`  |

### `WithdrawTicket`

> _From the program's IDL:_
>
> A finite-lifecycle account representing a specific depositor's place in the withdraw queue of a specific reserve.\
> The lifecycle:
>
> 1. The depositor holding ctokens wants to withdraw funds from the reserve, and finds out that
>
> the required amount is not available (due to high utilization).
> 2\. The depositor calls the `enqueue_to_withdraw` handler.
> 3\. The handler transfers the depositor's ctokens to the reserve's internal "pending" vault.
> 4\. The handler initializes a new \[WithdrawTicket] account, with the next available sequence
>
> number.
> 5\. The depositor waits until his ticket is the next expected one for actual withdraw, and until
>
> the reserve has enough liquidity.
> 6\. Anyone (the depositor or a bot) calls the permissionless `withdraw_queued_liquidity`
>
> handler. If the ticket became invalid (e.g. destination account no longer exists), then the depositor can call the `recover_invalid_ticket_collateral` handler instead.
> 7\. The handler transfers the liquidity amount according to the current exchange rate.
> 8\. The handler closes the ticket account.

Discriminator `ed17a43a35f8f05e` · `accounts::withdraw_ticket::WithdrawTicket`.

| Field                               | Type          | Description                                                                                                                                                                                                                                                                                                                         |
| ----------------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sequence_number`                   | `u64`         | This ticket's place in the queue; the same as used for PDA derivation.                                                                                                                                                                                                                                                              |
| `owner`                             | `Pubkey`      | The funds' owner (the user who called the `enqueue_to_withdraw` handler).                                                                                                                                                                                                                                                           |
| `reserve`                           | `Pubkey`      | The reserve to withdraw from.                                                                                                                                                                                                                                                                                                       |
| `user_destination_liquidity_ta`     | `Pubkey`      | The token account to which the finally-available liquidity should be transferred (by the `withdraw_queued_liquidity` handler).                                                                                                                                                                                                      |
| `queued_collateral_amount`          | `u64`         | The amount of collateral still waiting to be withdrawn using this ticket.                                                                                                                                                                                                                                                           |
| `created_at_timestamp`              | `u64`         | The timestamp at which the queue was entered. This is currently only a piece of metadata, not used by the logic.                                                                                                                                                                                                                    |
| `invalid`                           | `u8`          | Whether the ticket has been found to be invalid (e.g. the \[Self::user_destination_liquidity] has been repurposed) by the `withdraw_queued_liquidity` handler. To be specific: valid = `0`, invalid = `1`. An invalid ticket cannot be made valid again, and can only be passed to the `recover_invalid_ticket_collateral` handler. |
| `progress_callback_type`            | `u8`          | One of the valid \[ProgressCallbackType] representations.                                                                                                                                                                                                                                                                           |
| `alignment_padding`                 | `[u8; 6]`     | Inner padding, for alignment.                                                                                                                                                                                                                                                                                                       |
| `progress_callback_custom_accounts` | `[Pubkey; 2]` | The (optional) accounts to be used by \[Self::progress_callback_type]s.                                                                                                                                                                                                                                                             |
| `end_padding`                       | `[u64; 40]`   | Trailing padding, for future developments.                                                                                                                                                                                                                                                                                          |

## Events

Variants of `instructions::CpiEvent`, decoded from the `CpiEvent` instruction. Each wraps a struct from `carbon_kamino_lending_decoder::events::<module>`. The discriminator is the 8-byte event discriminator that follows the `e445a52e51cb9a1d` CPI-event tag.

### `BorrowOrderCancelEvent`

Discriminator `58e4e7e6eaf84590` · `events::borrow_order_cancel_event::BorrowOrderCancelEventEvent`.

| Field    | Type                          |
| -------- | ----------------------------- |
| `before` | [`BorrowOrder`](#borroworder) |

### `BorrowOrderFullFillEvent`

Discriminator `b1f1edfa8f140eb7` · `events::borrow_order_full_fill_event::BorrowOrderFullFillEventEvent`.

| Field    | Type                          |
| -------- | ----------------------------- |
| `before` | [`BorrowOrder`](#borroworder) |

### `BorrowOrderPartialFillEvent`

Discriminator `7151fcc198186354` · `events::borrow_order_partial_fill_event::BorrowOrderPartialFillEventEvent`.

| Field    | Type                          |
| -------- | ----------------------------- |
| `before` | [`BorrowOrder`](#borroworder) |
| `after`  | [`BorrowOrder`](#borroworder) |

### `BorrowOrderPlaceEvent`

Discriminator `2bd3d0ba5ee3dac6` · `events::borrow_order_place_event::BorrowOrderPlaceEventEvent`.

| Field   | Type                          |
| ------- | ----------------------------- |
| `after` | [`BorrowOrder`](#borroworder) |

### `BorrowOrderUpdateEvent`

Discriminator `1521438330b85a40` · `events::borrow_order_update_event::BorrowOrderUpdateEventEvent`.

| Field    | Type                          |
| -------- | ----------------------------- |
| `before` | [`BorrowOrder`](#borroworder) |
| `after`  | [`BorrowOrder`](#borroworder) |

## Types

Types used by the instructions, accounts and events above, exported from `carbon_kamino_lending_decoder::types`.

### `BigFractionBytes`

Struct `types::BigFractionBytes`.

| Field     | Type       |
| --------- | ---------- |
| `value`   | `[u64; 4]` |
| `padding` | `[u64; 2]` |

### `BorrowOrder`

> _From the program's IDL:_
>
> A borrow order.\
> When the \[Obligation::borrow_order] is populated (i.e. non-zeroed) on an\
> Obligation, then the permissionless "fill" operations may borrow liquidity to the owner according to this specification.

Struct `types::BorrowOrder`.

| Field                                    | Type       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ---------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `debt_liquidity_mint`                    | `Pubkey`   | The asset to be borrowed. The reserves used for \[Obligation::borrows] _must_ all provide exactly this asset.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `remaining_debt_amount`                  | `u64`      | The amount of debt that still needs to be filled, in lamports.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `filled_debt_destination`                | `Pubkey`   | The token account owned by the \[Obligation::owner] and holding \[Self::debt_liquidity_mint], where the filled funds should be transferred to.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `min_debt_term_seconds`                  | `u64`      | The minimum allowed debt term that the obligation owner agrees to. The reserves used to fill this order _cannot_ define their debt term _lower_ than this. If zeroed, then only open-term reserves may be used.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `fillable_until_timestamp`               | `u64`      | The time until which the borrow order can still be filled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `placed_at_timestamp`                    | `u64`      | The time at which this order was placed. Currently, this is only a piece of metadata.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `last_updated_at_timestamp`              | `u64`      | The time at which this order was most-recently updated (including: created). Currently, this is only a piece of metadata.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `requested_debt_amount`                  | `u64`      | The amount of debt that was originally requested when this order was most-recently updated. In other words: this field holds a value of \[Self::remaining_debt_amount] captured at \[Self::last_updated_at_timestamp]. Currently, this is only a piece of metadata.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `max_borrow_rate_bps`                    | `u32`      | The maximum borrow rate that the obligation owner agrees to. The reserves used for \[Obligation::borrows] _cannot_ define their maximum borrow rate _higher_ than this.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `active`                                 | `u8`       | Whether the \[Self::remaining_debt_amount] is non-zero. This field is _not_ used by smart contract logic (which prefers to treat the above \[Self::remaining_debt_amount]-based definition as the single source of truth). However, it is useful for off-chain bots (order-searchers) to efficiently list (i.e. `memcmp` filter) just the obligations that have active borrow orders.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `enable_auto_rollover_on_filled_borrows` | `u8`       | When `1`, all \[Obligation::borrows] that get filled by this order will have their \[FixedTermBorrowRolloverConfig::auto_rollover_enabled] flag set. Additionally, their rollover customizations: - will exactly match this order's constraints regarding \[Self::min_debt_term_seconds] and \[Self::max_borrow_rate_bps]; - will use the \[FixedTermBorrowRolloverConfig::open_term_allowed] fallback. See \[BorrowOrder::get_rollover_config_for_filled_borrow()]. Clarification note: when `0`, this setting has no effect on any borrow (i.e. if an existing borrow was independently marked for auto-rollover, it will _not_ be unmarked when filled by this order). Feature flag note: when \[LendingMarket::obligation_borrow_rollover_configuration_enabled] is disabled, this setting has no effect on any borrow (i.e. the fill will be successful, but the borrow will not be marked for auto-rollover. |
| `padding1`                               | `[u8; 2]`  | Alignment padding.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `end_padding`                            | `[u64; 5]` | End padding.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

### `BorrowOrderCancelEvent`

Struct `types::BorrowOrderCancelEvent`. Same fields as the [`BorrowOrderCancelEvent`](#borrowordercancelevent) event.

### `BorrowOrderConfigArgs`

> _From the program's IDL:_
>
> A subset of \[BorrowOrderConfig] excluding the accounts passed via\
> \[SetBorrowOrder].

Struct `types::BorrowOrderConfigArgs`.

| Field                                    | Type   |
| ---------------------------------------- | ------ |
| `remaining_debt_amount`                  | `u64`  |
| `max_borrow_rate_bps`                    | `u32`  |
| `min_debt_term_seconds`                  | `u64`  |
| `fillable_until_timestamp`               | `u64`  |
| `enable_auto_rollover_on_filled_borrows` | `bool` |

### `BorrowOrderFullFillEvent`

Struct `types::BorrowOrderFullFillEvent`. Same fields as the [`BorrowOrderFullFillEvent`](#borroworderfullfillevent) event.

### `BorrowOrderPartialFillEvent`

Struct `types::BorrowOrderPartialFillEvent`. Same fields as the [`BorrowOrderPartialFillEvent`](#borroworderpartialfillevent) event.

### `BorrowOrderPlaceEvent`

Struct `types::BorrowOrderPlaceEvent`. Same fields as the [`BorrowOrderPlaceEvent`](#borroworderplaceevent) event.

### `BorrowOrderUpdateEvent`

Struct `types::BorrowOrderUpdateEvent`. Same fields as the [`BorrowOrderUpdateEvent`](#borroworderupdateevent) event.

### `BorrowRateCurve`

Struct `types::BorrowRateCurve`.

| Field    | Type                              |
| -------- | --------------------------------- |
| `points` | [`[CurvePoint; 11]`](#curvepoint) |

### `CurvePoint`

Struct `types::CurvePoint`.

| Field                  | Type  |
| ---------------------- | ----- |
| `utilization_rate_bps` | `u32` |
| `borrow_rate_bps`      | `u32` |

### `ElevationGroup`

Struct `types::ElevationGroup`.

| Field                        | Type       | Description                                     |
| ---------------------------- | ---------- | ----------------------------------------------- |
| `max_liquidation_bonus_bps`  | `u16`      |                                                 |
| `id`                         | `u8`       |                                                 |
| `ltv_pct`                    | `u8`       |                                                 |
| `liquidation_threshold_pct`  | `u8`       |                                                 |
| `allow_new_loans`            | `u8`       |                                                 |
| `max_reserves_as_collateral` | `u8`       |                                                 |
| `padding0`                   | `u8`       |                                                 |
| `debt_reserve`               | `Pubkey`   | Mandatory debt reserve for this elevation group |
| `padding1`                   | `[u64; 4]` |                                                 |

### `FeeCalculation`

> _From the program's IDL:_
>
> Calculate fees exlusive or inclusive of an amount

Enum `types::FeeCalculation`.

| Variant     |
| ----------- |
| `Exclusive` |
| `Inclusive` |

### `FixedTermBorrowRolloverConfig`

> _From the program's IDL:_
>
> Settings driving the auto-rollover (or migration) of an\
> \[ObligationLiquidity]'s borrow. This covers three flavors:
>
> - _fixed-to-fixed_: a fixed-term borrow rolling into another fixed-term reserve,
> - _fixed-to-open_: a fixed-term borrow rolling into an open-term reserve,
> - _open-to-fixed_: an open-term borrow migrating into a fixed-term reserve.
>
> By its nature (not a special case), the zeroed struct means "no auto-rollover/migration".

Struct `types::FixedTermBorrowRolloverConfig`.

| Field                        | Type      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ---------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `auto_rollover_enabled`      | `u8`      | Whether this _fixed-term_ borrow can be permissionlessly prolonged. The funds used to roll over can come: - either from a _fixed-term_ reserve (same or a different one): - This can only happen within \[LendingMarket::fixed_term_rollover_window_duration_seconds]. - The target reserve must meet all the criteria defined in this config (see \[Self::max_borrow_rate_bps] and \[Self::min_debt_term_seconds]). - Note: not possible when \[Self::min_debt_term_seconds] is `0` (open-term only). - or from an _open-term_ reserve: - This can only happen within \[LendingMarket::open_term_rollover_window_duration_seconds]. - The user must explicitly set \[Self::open_term_allowed] here. This setting is not effective when the borrow is currently using an _open-term_ reserve. |
| `open_term_allowed`          | `u8`      | When `1`, then \[Self::auto_rollover_enabled] is allowed to roll this borrow over into any open-term reserve. Please note that if such rollover actually happens, then \[Self::max_borrow_rate_bps] condition does not apply - technically, it could be evaluated, but open-term reserves typically use float-rate (utilization-driven borrow rate curve) which has very high maximum (when at 100% utilization) that would not meet any practical criteria here.                                                                                                                                                                                                                                                                                                                             |
| `migration_to_fixed_enabled` | `u8`      | Whether this _open-term_ borrow can be permissionlessly migrated into a fixed-term reserve: - This can happen at any moment (as soon as liquidity becomes available). - The target fixed-term reserve must meet all the criteria defined in this config (see \[Self::max_borrow_rate_bps] and \[Self::min_debt_term_seconds]). This setting is not effective when the borrow is currently using a _fixed-term_ reserve. Cannot be enabled when \[Self::min_debt_term_seconds] is `0` (open-term only), because migrating into a fixed-term reserve contradicts the open-term-only intent.                                                                                                                                                                                                     |
| `alignment_padding`          | `[u8; 1]` | Internal alignment padding (free to reuse).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `max_borrow_rate_bps`        | `u32`     | A maximum allowed borrow rate of a reserve that can be used for a rollover/migration. Note: this must be set (i.e. non-zero) when enabling any rollover/migration flavor, but is of course not effective when rollover/migration is not enabled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `min_debt_term_seconds`      | `u64`     | A minimum debt term (in seconds) of a fixed-term reserve that can be used for a rollover/migration. When `0`, the owner only accepts open-term reserves as rollover targets — i.e. rolling over (or migrating) into a fixed-term reserve is not allowed. This is consistent with the semantics of \[BorrowOrder::min_debt_term_seconds]. This means that `0` is incompatible with \[Self::migration_to_fixed_enabled] (which requires a fixed-term target) — this combination is rejected at configuration time.                                                                                                                                                                                                                                                                              |

### `InitObligationArgs`

Struct `types::InitObligationArgs`.

| Field | Type |
| ----- | ---- |
| `tag` | `u8` |
| `id`  | `u8` |

### `LastUpdate`

> _From the program's IDL:_
>
> Last update state

Struct `types::LastUpdate`.

| Field          | Type      | Description                                            |
| -------------- | --------- | ------------------------------------------------------ |
| `slot`         | `u64`     | Last slot when updated                                 |
| `stale`        | `u8`      | True when marked stale, false when slot updated        |
| `price_status` | `u8`      | Status of the prices used to calculate the last update |
| `placeholder`  | `[u8; 6]` |                                                        |

### `ObligationCollateral`

> _From the program's IDL:_
>
> Obligation collateral state

Struct `types::ObligationCollateral`.

| Field                                                        | Type       | Description                                                                                                                                                                                                                                                                                          |
| ------------------------------------------------------------ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `deposit_reserve`                                            | `Pubkey`   | Reserve collateral is deposited to                                                                                                                                                                                                                                                                   |
| `deposited_amount`                                           | `u64`      | Amount of collateral deposited                                                                                                                                                                                                                                                                       |
| `market_value_sf`                                            | `u128`     | Collateral market value in quote currency (scaled fraction)                                                                                                                                                                                                                                          |
| `borrowed_amount_against_this_collateral_in_elevation_group` | `u64`      | Debt amount (lamport) taken against this collateral. (only meaningful if this obligation is part of an elevation group, otherwise 0) This is only indicative of the debt computed on the last refresh obligation. If the obligation have multiple collateral this value is the same for all of them. |
| `padding`                                                    | `[u64; 9]` |                                                                                                                                                                                                                                                                                                      |

### `ObligationLiquidity`

> _From the program's IDL:_
>
> Obligation liquidity state

Struct `types::ObligationLiquidity`.

| Field                                      | Type                                                              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------------------------------ | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `borrow_reserve`                           | `Pubkey`                                                          | Reserve liquidity is borrowed from                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `cumulative_borrow_rate_bsf`               | [`BigFractionBytes`](#bigfractionbytes)                           | Borrow rate used for calculating interest (big scaled fraction)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `last_borrowed_at_timestamp`               | `u64`                                                             | The timestamp at which this debt was taken. Conceptually, every borrow can be interpreted as "closing the previous loan and starting a new one" (which would make a plain `borrowed_at` an even better name). But in terms of implementation, this fields records when the _last_ borrow operation from this reserve happened (i.e. adding debt of the same reserve _does_ move this timestamp). Note: this field is _not_ only metadata: it is used in the logic, e.g. for enforcing the fixed-term borrows (i.e. those induced by \[ReserveConfig::debt_term_seconds]).         |
| `borrowed_amount_sf`                       | `u128`                                                            | Amount of liquidity borrowed plus interest (scaled fraction)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `market_value_sf`                          | `u128`                                                            | Liquidity market value in quote currency (scaled fraction)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `borrow_factor_adjusted_market_value_sf`   | `u128`                                                            | Risk adjusted liquidity market value in quote currency - DEBUG ONLY - use market_value instead                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `borrowed_amount_outside_elevation_groups` | `u64`                                                             | Amount of liquidity borrowed outside of an elevation group                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `fixed_term_borrow_rollover_config`        | [`FixedTermBorrowRolloverConfig`](#fixedtermborrowrolloverconfig) | The user's auto-rollover/migration opt-ins. Some settings are effective only for fixed-term borrows, while others only for open-term borrows - see individual field docs.                                                                                                                                                                                                                                                                                                                                                                                                         |
| `borrowed_amount_at_expiration`            | `u64`                                                             | An amount of liquidity that was borrowed when this fixed-term borrow expired (i.e. zeroed if this borrow is not fixed-term, or if it did not yet expire). Needed to honor the \[LendingMarket::term_based_full_liquidation_duration_secs]. This value is captured by \[Self::capture_borrowed_amount_at_expiration] during obligation's refresh - please see the method's docs for gotchas. Note on precision: we use a `u64` field, since the remaining space within this struct is rather scarce, and we do not need sub-lamport precision for the liquidation throttling rate. |
| `padding2`                                 | `[u64; 4]`                                                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

### `ObligationOrder`

> _From the program's IDL:_
>
> A single obligation order.\
> See \[Obligation::obligation_orders].

Struct `types::ObligationOrder`.

| Field                      | Type        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| -------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `condition_threshold_sf`   | `u128`      | A threshold value used by the condition (scaled \[Fraction]). The exact meaning depends on the specific \[Self::condition_type]. Examples: - when `condition_type == 2 (UserLtvBelow)`: then a value of `0.455` here means that the order is active only when the obligation's user LTV is less than `0.455` (i.e. < 45.5%). - when `condition_type == 3 (DebtCollPriceRatioAbove)`: assuming the obligation uses BTC collateral for SOL debt, then a value of `491.3` here means that the order is active only when the BTC-SOL price is greater than `491.3` (i.e. > 491.3 SOL per BTC).                                                                                                                                                 |
| `opportunity_parameter_sf` | `u128`      | A configuration parameter used by the opportunity (scaled \[Fraction]). The exact meaning depends on the specific \[Self::opportunity_type]. Examples: - when `opportunity_type == 0 (DeleverageSingleDebtAmount)`: Assuming the obligation uses BTC collateral for SOL debt, then a value of `1_234_000_000` here means that a liquidator may repay up to 1234000000 lamports (i.e. 1.234 SOL) on this obligation. Note: the special value of \[Fraction::MAX] is _not_ allowed in this case. - when `opportunity_type == 1 (DeleverageAllDebtAmount)`: The only allowed value in this case is \[Fraction::MAX] (to emphasize that _all_ debt should be repaid).                                                                          |
| `min_execution_bonus_bps`  | `u16`       | A _minimum_ additional fraction of collateral transferred to the liquidator, in bps. The minimum bonus is applied exactly when the \[Self::condition_threshold_sf] is met, and grows linearly towards the \[Self::max_execution_bonus_bps]. Example: a value of `50` here means 50bps == 0.5% bonus for an "LTV > 65%" order, when executed precisely at the moment LTV exceeds 65%.                                                                                                                                                                                                                                                                                                                                                       |
| `max_execution_bonus_bps`  | `u16`       | A _maximum_ additional fraction of collateral transferred to the liquidator, in bps. The maximum bonus is applied at the relevant "extreme" state of the obligation, i.e.: - for a stop-loss condition, it is a point at which the obligation becomes liquidatable; - for a take-profit condition, it is a point at which obligation has 0% LTV. In non-extreme states, the actual bonus value is interpolated linearly, starting from \[Self::min_execution_bonus_bps] (at the point specified by the order's condition). Example: a value of `300` here means 300bps == 3.0% bonus for a "debt/coll price > 140" order, when executed at a higher price = 200, at which the obligation's LTV happens to be equal to its liquidation LTV. |
| `condition_type`           | `u8`        | Serialized \[ConditionType]. The entire order is void when this is zeroed (i.e. representing \[ConditionType::Never]). Example: a value of `2` here denotes `UserLtvBelow` condition type. Of course, to interpret this condition, we also need to take the \[Self::condition_threshold_sf] into account.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `opportunity_type`         | `u8`        | Serialized \[OpportunityType]. Example: a value of `0` here denotes `DeleverageSingleDebtAmount` opportunity. Of course, to interpret this opportunity, we also need to take the \[Self::opportunity_parameter_sf] into account.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `padding1`                 | `[u8; 10]`  | Alignment padding. The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to align with `u128`s.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `padding2`                 | `[u128; 5]` | End padding. The total size of a single instance is 8\*u128 = 128 bytes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

### `PriceHeuristic`

Struct `types::PriceHeuristic`.

| Field   | Type  | Description                                         |
| ------- | ----- | --------------------------------------------------- |
| `lower` | `u64` | Lower value of acceptable price                     |
| `upper` | `u64` | Upper value of acceptable price                     |
| `exp`   | `u64` | Number of decimals of the previously defined values |

### `ProgressCallbackType`

> _From the program's IDL:_
>
> A callback to be notified when the ticket is being processed.
>
> **Why an enum?**
>
> Only reliable programs may be used for callbacks (since any error or panic returned from a CPI aborts an entire transaction, which would stall the queue progress). Hence, we need a whitelist, and the simplest initial implementation is a hardcoded enum. If we want to be able to add new whitelist items without SC updates, we can implement such support using a special enum value (e.g. `SPECIFIED_BY_PDA = 255`).

Enum `types::ProgressCallbackType`.

| Variant                               |
| ------------------------------------- |
| `None`                                |
| `KlendQueueAccountingHandlerOnKvault` |

### `PythConfiguration`

Struct `types::PythConfiguration`.

| Field   | Type     | Description                                                     |
| ------- | -------- | --------------------------------------------------------------- |
| `price` | `Pubkey` | Pubkey of the base price feed (disabled if `null` or `default`) |

### `ReserveCollateral`

> _From the program's IDL:_
>
> Reserve collateral

Struct `types::ReserveCollateral`.

| Field               | Type         | Description                                            |
| ------------------- | ------------ | ------------------------------------------------------ |
| `mint_pubkey`       | `Pubkey`     | Reserve collateral mint address                        |
| `mint_total_supply` | `u64`        | Reserve collateral mint supply, used for exchange rate |
| `supply_vault`      | `Pubkey`     | Reserve collateral supply address                      |
| `padding1`          | `[u128; 32]` |                                                        |
| `padding2`          | `[u128; 32]` |                                                        |

### `ReserveConfig`

> _From the program's IDL:_
>
> Reserve configuration values

Struct `types::ReserveConfig`.

| Field                                                     | Type                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------------------------------------------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status`                                                  | `u8`                                  | Status of the reserve Active/Obsolete/Hidden                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `padding_deprecated_asset_tier`                           | `u8`                                  | Asset tier -> 0 - regular (collateral & debt), 1 - isolated collateral, 2 - isolated debt                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `host_fixed_interest_rate_bps`                            | `u16`                                 | Flat rate that goes to the host                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `min_deleveraging_bonus_bps`                              | `u16`                                 | Starting bonus for deleveraging-related liquidations, in bps.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `block_ctoken_usage`                                      | `u8`                                  | Boolean flag to block minting/redeeming of ctokens Blocks usage of ctokens (minting or withdrawing from obligation) Effectively blocks deposit_reserve_liquidity and withdraw_obligation_collateral                                                                                                                                                                                                                                                                                                                                          |
| `early_repay_remaining_interest_pct`                      | `u8`                                  | The percentage of remaining interest over the debt term that is charged as early repay penalty. Only meaningful when `debt_term_seconds > 0`.                                                                                                                                                                                                                                                                                                                                                                                                |
| `emergency_mode`                                          | `u8`                                  | Whether the reserve is in emergency mode. Blocks most user operations involving this reserve, similar to \[LendingMarket::emergency_mode] but scoped to a single reserve. Also cascades to obligations using this reserve as collateral or debt, blocking borrows and withdrawals on other reserves but still allowing repays and deposits.                                                                                                                                                                                                  |
| `reserved1`                                               | `[u8; 4]`                             | Past reserved space - feel free to reuse.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `protocol_order_execution_fee_pct`                        | `u8`                                  | Cut of the order execution bonus that the protocol receives, as a percentage                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `protocol_take_rate_pct`                                  | `u8`                                  | Protocol take rate is the amount borrowed interest protocol receives, as a percentage                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `protocol_liquidation_fee_pct`                            | `u8`                                  | Cut of the liquidation bonus that the protocol receives, as a percentage                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `loan_to_value_pct`                                       | `u8`                                  | Target ratio of the value of borrows to deposits, as a percentage 0 if use as collateral is disabled                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `liquidation_threshold_pct`                               | `u8`                                  | Loan to value ratio at which an obligation can be liquidated, as percentage                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `min_liquidation_bonus_bps`                               | `u16`                                 | Minimum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `max_liquidation_bonus_bps`                               | `u16`                                 | Maximum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `bad_debt_liquidation_bonus_bps`                          | `u16`                                 | Bad debt liquidation bonus for an undercollateralized obligation, as bps                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `deleveraging_margin_call_period_secs`                    | `u64`                                 | Time in seconds that must pass before redemptions are enabled after the deposit limit is crossed. Only relevant when `autodeleverage_enabled == 1`, and must not be 0 in such case.                                                                                                                                                                                                                                                                                                                                                          |
| `deleveraging_threshold_decrease_bps_per_day`             | `u64`                                 | The rate at which the deleveraging threshold decreases, in bps per day. Only relevant when `autodeleverage_enabled == 1`, and must not be 0 in such case.                                                                                                                                                                                                                                                                                                                                                                                    |
| `fees`                                                    | [`ReserveFees`](#reservefees)         | Program owner fees assessed, separate from gains due to interest accrual                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `borrow_rate_curve`                                       | [`BorrowRateCurve`](#borrowratecurve) | Borrow rate curve based on utilization                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `borrow_factor_pct`                                       | `u64`                                 | Borrow factor in percentage - used for risk adjustment                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `deposit_limit`                                           | `u64`                                 | Maximum deposit limit of liquidity in native units, u64::MAX for inf                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `borrow_limit`                                            | `u64`                                 | Maximum amount borrowed, u64::MAX for inf, 0 to disable borrows (protected deposits)                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `token_info`                                              | [`TokenInfo`](#tokeninfo)             | Token id from TokenInfos struct                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `deposit_withdrawal_cap`                                  | [`WithdrawalCaps`](#withdrawalcaps)   | Deposit withdrawal caps - deposit & redeem                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `debt_withdrawal_cap`                                     | [`WithdrawalCaps`](#withdrawalcaps)   | Debt withdrawal caps - borrow & repay                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `elevation_groups`                                        | `[u8; 20]`                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `disable_usage_as_coll_outside_emode`                     | `u8`                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `utilization_limit_block_borrowing_above_pct`             | `u8`                                  | Utilization (in percentage) above which borrowing is blocked. 0 to disable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `autodeleverage_enabled`                                  | `u8`                                  | Whether this reserve should be subject to auto-deleveraging after deposit or borrow limit is crossed. Besides this flag, the lending market's flag also needs to be enabled (logical `AND`). **NOTE:** the manual "target LTV" deleveraging is NOT affected by this flag.                                                                                                                                                                                                                                                                    |
| `proposer_authority_locked`                               | `u8`                                  | Boolean flag indicating whether the reserve is locked for the proposer authority. Once the proposer have finished preparing the reserve, it must be locked to prevent further changes to the reserve configuration allowing review and voting on the proposal without alteration during the voting period.                                                                                                                                                                                                                                   |
| `borrow_limit_outside_elevation_group`                    | `u64`                                 | Maximum amount liquidity of this reserve borrowed outside all elevation groups - u64::MAX for inf - 0 to disable borrows outside elevation groups                                                                                                                                                                                                                                                                                                                                                                                            |
| `borrow_limit_against_this_collateral_in_elevation_group` | `[u64; 32]`                           | Defines the maximum amount (in lamports of elevation group debt asset) that can be borrowed when this reserve is used as collateral. - u64::MAX for inf - 0 to disable borrows in this elevation group (expected value for the debt asset)                                                                                                                                                                                                                                                                                                   |
| `deleveraging_bonus_increase_bps_per_day`                 | `u64`                                 | The rate at which the deleveraging-related liquidation bonus increases, in bps per day. Only relevant when `autodeleverage_enabled == 1`, and must not be 0 in such case.                                                                                                                                                                                                                                                                                                                                                                    |
| `debt_maturity_timestamp`                                 | `u64`                                 | The timestamp at which all \[Obligation::borrows] using this reserve become liquidatable (on the same terms as reserve-wide deleveraging). Inactive when zeroed (i.e. debt never matures). Note: this feature is independent of \[Self::debt_term_seconds] - the liquidation mechanism is based directly on the timestamp defined here, on Reserve's level.                                                                                                                                                                                  |
| `debt_term_seconds`                                       | `u64`                                 | The duration after which any debt coming from this Reserve must be repaid. Inactive when zeroed (i.e. funds can be borrowed indefinitely). Note: this feature is independent of \[Self::debt_maturity_timestamp] - the liquidation mechanism is based on the \[ObligationLiquidity::last_borrowed_at_timestamp].                                                                                                                                                                                                                             |
| `rewards_amount_per_slot`                                 | `u64`                                 | Rewards distributed per slot to depositors. Drained from \[ReserveLiquidity::rewards_amount_available] into \[ReserveLiquidity::total_available_amount] at each refresh, capped by the market-level \[LendingMarket::reserve_rewards_max_apr_bps]. `0` disables. **Note:** because rewards inflate `total_available_amount`, a non-zero RPS on a reserve with \[Self::autodeleverage_enabled] and a finite \[Self::deposit_limit] will eventually cross the cap and arm the autodeleverage countdown. Size `deposit_limit` and RPS together. |

### `ReserveConfigCustomizationArgs`

> _From the program's IDL:_
>
> A definition of optional customizations that should be applied after cloning the config.

Struct `types::ReserveConfigCustomizationArgs`.

| Field                        | Type  | Description                                                                                                                                                                                                                                                                                     |
| ---------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `override_fixed_rate_bps`    | `u8`  | A gate for \[Self::fixed_borrow_rate_bps].                                                                                                                                                                                                                                                      |
| `fixed_borrow_rate_bps`      | `u32` | If \[Self::override_fixed_rate_bps] is non-zero, this borrow rate will be used to override the \[ReserveConfig::borrow_rate_curve] with a fixed one.                                                                                                                                            |
| `override_debt_term_seconds` | `u8`  | A gate for \[Self::debt_term_seconds].                                                                                                                                                                                                                                                          |
| `debt_term_seconds`          | `u64` | If \[Self::override_debt_term_seconds] is non-zero, this value will be used to override the \[ReserveConfig::debt_term_seconds].                                                                                                                                                                |
| `clear_elevation_groups`     | `u8`  | Whether the target reserve should have zeroed \[ReserveConfig::elevation_groups] (i.e. not cloned from source). This customization is mandatory when cloning a reserve (with some elevation groups) into a different market (where those elevation group indices would have different meaning). |

### `ReserveFarmKind`

Enum `types::ReserveFarmKind`.

| Variant      |
| ------------ |
| `Collateral` |
| `Debt`       |

### `ReserveFees`

> _From the program's IDL:_
>
> Additional fee information on a reserve\
> These exist separately from interest accrual fees, and are specifically for the program owner and referral fee. The fees are paid out as a percentage of liquidity token amounts during repayments and liquidations.

Struct `types::ReserveFees`.

| Field                | Type      | Description                                                                                                                                                                                                                                                                                                  |
| -------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `origination_fee_sf` | `u64`     | Fee assessed on `BorrowObligationLiquidity`, as scaled fraction (60 bits fractional part) Must be between `0` and `2^60`, such that `2^60 = 1`.  A few examples for clarity: 1% = (1 << 60) / 100 = 11529215046068470 0.01% (1 basis point) = 115292150460685 0.00001% (Aave origination fee) = 115292150461 |
| `flash_loan_fee_sf`  | `u64`     | Fee for flash loan, expressed as scaled fraction. 0.3% (Aave flash loan fee) = 0.003 \* 2^60 = 3458764513820541                                                                                                                                                                                              |
| `padding`            | `[u8; 8]` | Used for allignment                                                                                                                                                                                                                                                                                          |

### `ReserveLiquidity`

> _From the program's IDL:_
>
> Reserve liquidity

Struct `types::ReserveLiquidity`.

| Field                             | Type                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                              |
| --------------------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mint_pubkey`                     | `Pubkey`                                | Reserve liquidity mint address                                                                                                                                                                                                                                                                                                                                                                                                           |
| `supply_vault`                    | `Pubkey`                                | Reserve liquidity supply address                                                                                                                                                                                                                                                                                                                                                                                                         |
| `fee_vault`                       | `Pubkey`                                | Reserve liquidity fee collection address                                                                                                                                                                                                                                                                                                                                                                                                 |
| `total_available_amount`          | `u64`                                   | Total reserve liquidity available. Note: not all of this liquidity can be freely used for any purpose. Production code should use the specialized getters - see e.g. \[Reserve::total_available_liquidity_amount()], \[Reserve::freely_available_liquidity_amount()].                                                                                                                                                                    |
| `borrowed_amount_sf`              | `u128`                                  | Reserve liquidity borrowed (scaled fraction)                                                                                                                                                                                                                                                                                                                                                                                             |
| `market_price_sf`                 | `u128`                                  | Reserve liquidity market price in quote currency (scaled fraction)                                                                                                                                                                                                                                                                                                                                                                       |
| `market_price_last_updated_ts`    | `u64`                                   | Unix timestamp of the market price (from the oracle)                                                                                                                                                                                                                                                                                                                                                                                     |
| `mint_decimals`                   | `u64`                                   | Reserve liquidity mint decimals                                                                                                                                                                                                                                                                                                                                                                                                          |
| `deposit_limit_crossed_timestamp` | `u64`                                   | Timestamp when the last refresh reserve detected that the liquidity amount is above the deposit cap. When this threshold is crossed, then redemptions (auto-deleverage) are enabled. If the threshold is not crossed, then the timestamp is set to 0                                                                                                                                                                                     |
| `borrow_limit_crossed_timestamp`  | `u64`                                   | Timestamp when the last refresh reserve detected that the borrowed amount is above the borrow cap. When this threshold is crossed, then redemptions (auto-deleverage) are enabled. If the threshold is not crossed, then the timestamp is set to 0                                                                                                                                                                                       |
| `cumulative_borrow_rate_bsf`      | [`BigFractionBytes`](#bigfractionbytes) | Reserve liquidity cumulative borrow rate (scaled fraction)                                                                                                                                                                                                                                                                                                                                                                               |
| `accumulated_protocol_fees_sf`    | `u128`                                  | Reserve cumulative protocol fees (scaled fraction)                                                                                                                                                                                                                                                                                                                                                                                       |
| `accumulated_referrer_fees_sf`    | `u128`                                  | Reserve cumulative referrer fees (scaled fraction)                                                                                                                                                                                                                                                                                                                                                                                       |
| `pending_referrer_fees_sf`        | `u128`                                  | Reserve pending referrer fees, to be claimed in refresh_obligation by referrer or protocol (scaled fraction)                                                                                                                                                                                                                                                                                                                             |
| `absolute_referral_rate_sf`       | `u128`                                  | Reserve referrer fee absolute rate calculated at each refresh_reserve operation (scaled fraction)                                                                                                                                                                                                                                                                                                                                        |
| `token_program`                   | `Pubkey`                                | Token program of the liquidity mint                                                                                                                                                                                                                                                                                                                                                                                                      |
| `rewards_amount_available`        | `u64`                                   | Reserve rewards budget remaining for distribution. Tokens are deposited via `topup_reserve_rewards` and increase this counter (without touching \[Self::total_available_amount]). On every `refresh_reserve`, up to `rewards_amount_per_slot * slots_elapsed` tokens are moved from this counter into \[Self::total_available_amount], inflating the cToken exchange rate, capped by the market-level `reserve_rewards_max_apr_bps` cap. |
| `padding2`                        | `[u64; 50]`                             |                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `padding3`                        | `[u128; 32]`                            |                                                                                                                                                                                                                                                                                                                                                                                                                                          |

### `ReserveStatus`

Enum `types::ReserveStatus`.

| Variant    |
| ---------- |
| `Active`   |
| `Obsolete` |
| `Hidden`   |

### `ScopeConfiguration`

Struct `types::ScopeConfiguration`.

| Field         | Type       | Description                                                            |
| ------------- | ---------- | ---------------------------------------------------------------------- |
| `price_feed`  | `Pubkey`   | Pubkey of the scope price feed (disabled if `null` or `default`)       |
| `price_chain` | `[u16; 4]` | This is the scope_id price chain that results in a price for the token |
| `twap_chain`  | `[u16; 4]` | This is the scope_id price chain for the twap                          |

### `SwitchboardConfiguration`

Struct `types::SwitchboardConfiguration`.

| Field              | Type     | Description                                                     |
| ------------------ | -------- | --------------------------------------------------------------- |
| `price_aggregator` | `Pubkey` | Pubkey of the base price feed (disabled if `null` or `default`) |
| `twap_aggregator`  | `Pubkey` |                                                                 |

### `TokenInfo`

Struct `types::TokenInfo`.

| Field                       | Type                                                    | Description                                       |
| --------------------------- | ------------------------------------------------------- | ------------------------------------------------- |
| `name`                      | `[u8; 32]`                                              | UTF-8 encoded name of the token (null-terminated) |
| `heuristic`                 | [`PriceHeuristic`](#priceheuristic)                     | Heuristics limits of acceptable price             |
| `max_twap_divergence_bps`   | `u64`                                                   | Max divergence between twap and price in bps      |
| `max_age_price_seconds`     | `u64`                                                   |                                                   |
| `max_age_twap_seconds`      | `u64`                                                   |                                                   |
| `scope_configuration`       | [`ScopeConfiguration`](#scopeconfiguration)             | Scope price configuration                         |
| `switchboard_configuration` | [`SwitchboardConfiguration`](#switchboardconfiguration) | Switchboard configuration                         |
| `pyth_configuration`        | [`PythConfiguration`](#pythconfiguration)               | Pyth configuration                                |
| `block_price_usage`         | `u8`                                                    |                                                   |
| `reserved`                  | `[u8; 7]`                                               |                                                   |
| `padding`                   | `[u64; 19]`                                             |                                                   |

### `UpdateConfigMode`

Enum `types::UpdateConfigMode`.

| Variant                                                |
| ------------------------------------------------------ |
| `UpdateLoanToValuePct`                                 |
| `UpdateMaxLiquidationBonusBps`                         |
| `UpdateLiquidationThresholdPct`                        |
| `UpdateProtocolLiquidationFee`                         |
| `UpdateProtocolTakeRate`                               |
| `UpdateFeesOriginationFee`                             |
| `UpdateFeesFlashLoanFee`                               |
| `DeprecatedUpdateFeesReferralFeeBps`                   |
| `UpdateDepositLimit`                                   |
| `UpdateBorrowLimit`                                    |
| `UpdateTokenInfoLowerHeuristic`                        |
| `UpdateTokenInfoUpperHeuristic`                        |
| `UpdateTokenInfoExpHeuristic`                          |
| `UpdateTokenInfoTwapDivergence`                        |
| `UpdateTokenInfoScopeTwap`                             |
| `UpdateTokenInfoScopeChain`                            |
| `UpdateTokenInfoName`                                  |
| `UpdateTokenInfoPriceMaxAge`                           |
| `UpdateTokenInfoTwapMaxAge`                            |
| `UpdateScopePriceFeed`                                 |
| `UpdatePythPrice`                                      |
| `UpdateSwitchboardFeed`                                |
| `UpdateSwitchboardTwapFeed`                            |
| `UpdateBorrowRateCurve`                                |
| `DeprecatedUpdateEntireReserveConfig`                  |
| `UpdateDebtWithdrawalCap`                              |
| `UpdateDepositWithdrawalCap`                           |
| `DeprecatedUpdateDebtWithdrawalCapCurrentTotal`        |
| `DeprecatedUpdateDepositWithdrawalCapCurrentTotal`     |
| `UpdateBadDebtLiquidationBonusBps`                     |
| `UpdateMinLiquidationBonusBps`                         |
| `UpdateDeleveragingMarginCallPeriod`                   |
| `UpdateBorrowFactor`                                   |
| `DeprecatedUpdateAssetTier`                            |
| `UpdateElevationGroup`                                 |
| `UpdateDeleveragingThresholdDecreaseBpsPerDay`         |
| `DeprecatedUpdateMultiplierSideBoost`                  |
| `DeprecatedUpdateMultiplierTagBoost`                   |
| `UpdateReserveStatus`                                  |
| `UpdateFarmCollateral`                                 |
| `UpdateFarmDebt`                                       |
| `UpdateDisableUsageAsCollateralOutsideEmode`           |
| `UpdateBlockBorrowingAboveUtilizationPct`              |
| `UpdateBlockPriceUsage`                                |
| `UpdateBorrowLimitOutsideElevationGroup`               |
| `UpdateBorrowLimitsInElevationGroupAgainstThisReserve` |
| `UpdateHostFixedInterestRateBps`                       |
| `UpdateAutodeleverageEnabled`                          |
| `UpdateDeleveragingBonusIncreaseBpsPerDay`             |
| `UpdateProtocolOrderExecutionFee`                      |
| `UpdateProposerAuthorityLock`                          |
| `UpdateMinDeleveragingBonusBps`                        |
| `UpdateBlockCTokenUsage`                               |
| `UpdateDebtMaturityTimestamp`                          |
| `UpdateDebtTermSeconds`                                |
| `UpdateEarlyRepayRemainingInterestPct`                 |
| `UpdateReserveEmergencyMode`                           |
| `UpdateRewardsAmountPerSlot`                           |

### `UpdateGlobalConfigMode`

Enum `types::UpdateGlobalConfigMode`.

| Variant        |
| -------------- |
| `PendingAdmin` |
| `FeeCollector` |

### `UpdateLendingMarketConfigValue`

Enum `types::UpdateLendingMarketConfigValue`.

| Variant          | Fields                              |
| ---------------- | ----------------------------------- |
| `Bool`           | `bool`                              |
| `U8`             | `u8`                                |
| `U8Array`        | `[u8; 8]`                           |
| `U16`            | `u16`                               |
| `U64`            | `u64`                               |
| `U128`           | `u128`                              |
| `Pubkey`         | `Pubkey`                            |
| `ElevationGroup` | [`ElevationGroup`](#elevationgroup) |
| `Name`           | `[u8; 32]`                          |

### `UpdateLendingMarketMode`

Enum `types::UpdateLendingMarketMode`.

| Variant                                                  |
| -------------------------------------------------------- |
| `UpdateOwner`                                            |
| `UpdateEmergencyMode`                                    |
| `UpdateLiquidationCloseFactor`                           |
| `UpdateLiquidationMaxValue`                              |
| `DeprecatedUpdateGlobalUnhealthyBorrow`                  |
| `UpdateGlobalAllowedBorrow`                              |
| `UpdateEmergencyCouncil`                                 |
| `UpdateMinFullLiquidationThreshold`                      |
| `UpdateInsolvencyRiskLtv`                                |
| `UpdateElevationGroup`                                   |
| `UpdateReferralFeeBps`                                   |
| `DeprecatedUpdateMultiplierPoints`                       |
| `UpdatePriceRefreshTriggerToMaxAgePct`                   |
| `UpdateAutodeleverageEnabled`                            |
| `UpdateBorrowingDisabled`                                |
| `UpdateMinNetValueObligationPostAction`                  |
| `UpdateMinValueLtvSkipPriorityLiqCheck`                  |
| `UpdateMinValueBfSkipPriorityLiqCheck`                   |
| `UpdatePaddingFields`                                    |
| `UpdateName`                                             |
| `UpdateIndividualAutodeleverageMarginCallPeriodSecs`     |
| `UpdateInitialDepositAmount`                             |
| `UpdateObligationOrderExecutionEnabled`                  |
| `UpdateImmutableFlag`                                    |
| `UpdateObligationOrderCreationEnabled`                   |
| `UpdateProposerAuthority`                                |
| `UpdatePriceTriggeredLiquidationDisabled`                |
| `UpdateMatureReserveDebtLiquidationEnabled`              |
| `UpdateObligationBorrowDebtTermLiquidationEnabled`       |
| `UpdateBorrowOrderCreationEnabled`                       |
| `UpdateBorrowOrderExecutionEnabled`                      |
| `UpdateMinBorrowOrderFillValue`                          |
| `UpdateWithdrawTicketIssuanceEnabled`                    |
| `UpdateWithdrawTicketRedemptionEnabled`                  |
| `UpdateMinWithdrawQueuedLiquidityValue`                  |
| `UpdateFixedTermRolloverWindowDurationSeconds`           |
| `UpdateOpenTermRolloverWindowDurationSeconds`            |
| `UpdateObligationBorrowRolloverConfigurationEnabled`     |
| `UpdateTermBasedFullLiquidationDurationSecs`             |
| `UpdateObligationBorrowMigrationToFixedExecutionEnabled` |
| `UpdateMinPartialRolloverValue`                          |
| `UpdateWithdrawTicketCancellationEnabled`                |
| `UpdatePermissioningAuthority`                           |
| `UpdatePermissionedOps`                                  |
| `DeprecatedUpdateReserveRewardsMaxAprPct`                |
| `UpdateReserveRewardsMaxAprBps`                          |

### `UpdateObligationConfigMode`

> _From the program's IDL:_
>
> A discriminator of a user-configurable piece of \[Obligation].\
> Implementation note: due to TS-side codegen quirks (and a "convention" currently seen e.g. within reserve and market update operations), this is not a true Rust enum. The new value of a config item is provided in a separate handler argument (borsh-serialized), and its expected type is defined by each discriminator here. Additionally, each update mode acts on a specific \[ObligationConfigUpdateSubject] (e.g. the auto-rollover of fixed-term borrows is configured on a per-borrow basis), which is also specified by separate handler arguments.

Enum `types::UpdateObligationConfigMode`.

| Variant                               |
| ------------------------------------- |
| `FixedTermRolloverEnabled`            |
| `FixedTermRolloverMaxBorrowRateBps`   |
| `FixedTermRolloverMinDebtTermSeconds` |
| `FixedTermRolloverOpenTermAllowed`    |
| `MigrationToFixedEnabled`             |

### `WithdrawalCaps`

> _From the program's IDL:_
>
> Reserve Withdrawal Caps State

Struct `types::WithdrawalCaps`.

| Field                            | Type  |
| -------------------------------- | ----- |
| `config_capacity`                | `i64` |
| `current_total`                  | `i64` |
| `last_interval_start_timestamp`  | `u64` |
| `config_interval_length_seconds` | `u64` |

### `WithdrawQueue`

> _From the program's IDL:_
>
> A tracker of ticket-based withdrawals.

Struct `types::WithdrawQueue`.

| Field                                      | Type  | Description                                                                                                                                                                                                |
| ------------------------------------------ | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `queued_collateral_amount`                 | `u64` | The part of \[ReserveLiquidity::total_available_amount] locked for ticketed withdrawals.                                                                                                                   |
| `next_issued_ticket_sequence_number`       | `u64` | The sequence number of the next ticket to be issued when enqueueing to withdraw. Note: it is also a number of tickets issued so far.                                                                       |
| `next_withdrawable_ticket_sequence_number` | `u64` | The sequence number of the next ticket to be used for actually transferring the withdrawn liquidity (assuming it is available in the reserve). Note: it is also a number of fully-consumed tickets so far. |

---

Carbon 2.0.0 documentation · Web: https://carbon.sevenlabs.org/decoders/kamino-lending · Last updated 2026-11-09 · Index of all pages: https://carbon.sevenlabs.org/llms.txt
