# marginfi v2 decoder (Carbon 2.0)

> Decode marginfi v2 instructions, accounts and events in Rust with carbon-marginfi-v2-decoder 2.0.0. Program ID MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA.

`carbon-marginfi-v2-decoder` decodes the instructions, accounts and events of the marginfi v2 program (`MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA`): 91 instructions, 15 account types, 30 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-marginfi-v2-decoder`](https://crates.io/crates/carbon-marginfi-v2-decoder/2.0.0) 2.0.0                 |
| Install          | `cargo add carbon-marginfi-v2-decoder@2.0.0`                                                                    |
| Program ID       | `MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA` (`carbon_marginfi_v2_decoder::PROGRAM_ID`)                        |
| Category         | [Lending](https://carbon.sevenlabs.org/decoders/lending.md)                                                     |
| Decoder          | `carbon_marginfi_v2_decoder::MarginfiV2Decoder`                                                                 |
| Instruction enum | `instructions::MarginfiV2Instruction`                                                                           |
| Account enum     | `accounts::MarginfiV2Account`                                                                                   |
| Event enum       | `instructions::CpiEvent`                                                                                        |
| Features         | `serde`, `postgres`, `graphql` (none enabled by default)                                                        |
| API docs         | [docs.rs/carbon-marginfi-v2-decoder/2.0.0](https://docs.rs/carbon-marginfi-v2-decoder/2.0.0)                    |
| Source           | [decoders/marginfi-v2-decoder](https://github.com/sevenlabs-hq/carbon/tree/v2.0.0/decoders/marginfi-v2-decoder) |

Other lending decoders: [Jupiter Lend](https://carbon.sevenlabs.org/decoders/jupiter-lend.md), [Kamino Lending](https://carbon.sevenlabs.org/decoders/kamino-lending.md), [Kamino Vault](https://carbon.sevenlabs.org/decoders/kamino-vault.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 marginfi v2 transactions from the public RPC and prints every decoded `ConfigGroupFee` instruction. Add the dependencies:

```sh
cargo add carbon-core@2.0.0 carbon-marginfi-v2-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_marginfi_v2_decoder::{
        instructions::MarginfiV2Instruction, MarginfiV2Decoder, 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(MarginfiV2Decoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

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

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

Each `ConfigGroupFee` instruction prints one line with the transaction signature and the decoded `ConfigGroupFee` 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 `MarginfiV2Instruction::CpiEvent { data: CpiEvent::DeleverageEvent(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 `MarginfiAccount` 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_marginfi_v2_decoder::{accounts::MarginfiV2Account, MarginfiV2Decoder, 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(MarginfiV2Decoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

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

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

Each update to a `MarginfiAccount` 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 `MarginfiV2Instruction`. Each is `MarginfiV2Instruction::<Variant> { program_id, data, accounts }`, where `data` and `accounts` are the types listed under the variant, exported from `carbon_marginfi_v2_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 `MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA`.
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.

### `ConfigGroupFee`

> _From the program's IDL:_
>
> (global fee admin only) Enable or disable program fees for any group. Does not require the group admin to sign: the global fee state admin can turn program fees on or off for any group

Discriminator `e7cd42f2dc579126` · data `ConfigGroupFee` · accounts `ConfigGroupFeeInstructionAccounts`.

| Field                | Type   |
| -------------------- | ------ |
| `enable_program_fee` | `bool` |

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

Fields of `ConfigGroupFeeInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `marginfi_group`   | `Pubkey`           |
| 1  | `global_fee_admin` | `Pubkey`           |
| 2  | `fee_state`        | `Pubkey`           |
| 3… | `remaining`        | `Vec<AccountMeta>` |

### `ConfigureBankRateLimits`

> _From the program's IDL:_
>
> (admin or delegate_limit_admin) Configure bank-level rate limits for withdraw/borrow. Rate limits track net outflow in native tokens. Deposits offset withdraws. Set to 0 to disable. Hourly and daily windows are independent.

Discriminator `af5455ddcedc6eae` · data `ConfigureBankRateLimits` · accounts `ConfigureBankRateLimitsInstructionAccounts`.

| Field                | Type          |
| -------------------- | ------------- |
| `hourly_max_outflow` | `Option<u64>` |
| `daily_max_outflow`  | `Option<u64>` |

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

Fields of `ConfigureBankRateLimitsInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `group`     | `Pubkey`           |
| 1  | `admin`     | `Pubkey`           |
| 2  | `bank`      | `Pubkey`           |
| 3… | `remaining` | `Vec<AccountMeta>` |

### `ConfigureDeleverageWithdrawalLimit`

> _From the program's IDL:_
>
> (admin or delegate_limit_admin) Set the daily withdrawal limit for deleverages per group.

Discriminator `1c84cd9e434db13f` · data `ConfigureDeleverageWithdrawalLimit` · accounts `ConfigureDeleverageWithdrawalLimitInstructionAccounts`.

| Field   | Type  |
| ------- | ----- |
| `limit` | `u32` |

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

Fields of `ConfigureDeleverageWithdrawalLimitInstructionAccounts`, in account order:

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

### `ConfigureGroupRateLimits`

> _From the program's IDL:_
>
> (admin or delegate_limit_admin) Configure group-level rate limits for withdraw/borrow. Rate limits track aggregate net outflow in USD.\
> Example: $10M = 10_000_000. Set to 0 to disable.

Discriminator `6f2fd58e9e33e266` · data `ConfigureGroupRateLimits` · accounts `ConfigureGroupRateLimitsInstructionAccounts`.

| Field                    | Type          |
| ------------------------ | ------------- |
| `hourly_max_outflow_usd` | `Option<u64>` |
| `daily_max_outflow_usd`  | `Option<u64>` |

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

Fields of `ConfigureGroupRateLimitsInstructionAccounts`, in account order:

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

### `DriftDeposit`

> _From the program's IDL:_
>
> (user) Deposit into a Drift spot market through a marginfi account
>
> - amount - in the underlying token (e.g., USDC), in native decimals

Discriminator `fc3ffac96237820c` · data `DriftDeposit` · accounts `DriftDepositInstructionAccounts`.

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

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

Fields of `DriftDepositInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `group`                     | `Pubkey`           |
| 1   | `marginfi_account`          | `Pubkey`           |
| 2   | `authority`                 | `Pubkey`           |
| 3   | `bank`                      | `Pubkey`           |
| 4   | `drift_oracle`              | `Option<Pubkey>`   |
| 5   | `liquidity_vault_authority` | `Pubkey`           |
| 6   | `liquidity_vault`           | `Pubkey`           |
| 7   | `signer_token_account`      | `Pubkey`           |
| 8   | `drift_state`               | `Pubkey`           |
| 9   | `integration_acc2`          | `Pubkey`           |
| 10  | `integration_acc3`          | `Pubkey`           |
| 11  | `integration_acc1`          | `Pubkey`           |
| 12  | `drift_spot_market_vault`   | `Pubkey`           |
| 13  | `mint`                      | `Pubkey`           |
| 14  | `drift_program`             | `Pubkey`           |
| 15  | `token_program`             | `Pubkey`           |
| 16  | `system_program`            | `Pubkey`           |
| 17… | `remaining`                 | `Vec<AccountMeta>` |

### `DriftHarvestReward`

> _From the program's IDL:_
>
> (permissionless) Harvest rewards from admin deposits in Drift spot markets.\
> Rewards are always sent to the global fee wallet's canonical ATA.\
> The harvest spot market must be different from the bank's main drift spot market.

Discriminator `a7a1f0c28a3657bd` · data `DriftHarvestReward` · accounts `DriftHarvestRewardInstructionAccounts`.

No data fields.

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

Fields of `DriftHarvestRewardInstructionAccounts`, in account order:

| #   | Field                             | Type               |
| --- | --------------------------------- | ------------------ |
| 0   | `bank`                            | `Pubkey`           |
| 1   | `fee_state`                       | `Pubkey`           |
| 2   | `liquidity_vault_authority`       | `Pubkey`           |
| 3   | `intermediary_token_account`      | `Pubkey`           |
| 4   | `destination_token_account`       | `Pubkey`           |
| 5   | `drift_state`                     | `Pubkey`           |
| 6   | `integration_acc2`                | `Pubkey`           |
| 7   | `integration_acc3`                | `Pubkey`           |
| 8   | `harvest_drift_spot_market`       | `Pubkey`           |
| 9   | `harvest_drift_spot_market_vault` | `Pubkey`           |
| 10  | `drift_signer`                    | `Pubkey`           |
| 11  | `reward_mint`                     | `Pubkey`           |
| 12  | `drift_program`                   | `Pubkey`           |
| 13  | `token_program`                   | `Pubkey`           |
| 14… | `remaining`                       | `Vec<AccountMeta>` |

### `DriftInitUser`

> _From the program's IDL:_
>
> (permissionless) Initialize a Drift user and user stats for a marginfi bank\
> Creates user with sub_account_id = 0 and empty name\
> Requires a minimum deposit to ensure the account remains active
>
> - amount - minimum deposit amount (at least 10 units) in native decimals

Discriminator `1d12ecbe1dfe72a9` · data `DriftInitUser` · accounts `DriftInitUserInstructionAccounts`.

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

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

Fields of `DriftInitUserInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `fee_payer`                 | `Pubkey`           |
| 1   | `signer_token_account`      | `Pubkey`           |
| 2   | `bank`                      | `Pubkey`           |
| 3   | `liquidity_vault_authority` | `Pubkey`           |
| 4   | `liquidity_vault`           | `Pubkey`           |
| 5   | `mint`                      | `Pubkey`           |
| 6   | `integration_acc3`          | `Pubkey`           |
| 7   | `integration_acc2`          | `Pubkey`           |
| 8   | `drift_state`               | `Pubkey`           |
| 9   | `integration_acc1`          | `Pubkey`           |
| 10  | `drift_spot_market_vault`   | `Pubkey`           |
| 11  | `drift_oracle`              | `Option<Pubkey>`   |
| 12  | `drift_program`             | `Pubkey`           |
| 13  | `token_program`             | `Pubkey`           |
| 14  | `rent`                      | `Pubkey`           |
| 15  | `system_program`            | `Pubkey`           |
| 16… | `remaining`                 | `Vec<AccountMeta>` |

### `DriftWithdraw`

> _From the program's IDL:_
>
> (user) Withdraw from a Drift spot market through a marginfi account
>
> - amount - in the underlying token (e.g., USDC), in native decimals
> - withdraw_all - if true, withdraws entire position

Discriminator `563bba7bb7b5ea89` · data `DriftWithdraw` · accounts `DriftWithdrawInstructionAccounts`.

| Field          | Type           |
| -------------- | -------------- |
| `amount`       | `u64`          |
| `withdraw_all` | `Option<bool>` |

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

Fields of `DriftWithdrawInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `group`                     | `Pubkey`           |
| 1   | `marginfi_account`          | `Pubkey`           |
| 2   | `authority`                 | `Pubkey`           |
| 3   | `bank`                      | `Pubkey`           |
| 4   | `drift_oracle`              | `Option<Pubkey>`   |
| 5   | `liquidity_vault_authority` | `Pubkey`           |
| 6   | `liquidity_vault`           | `Pubkey`           |
| 7   | `destination_token_account` | `Pubkey`           |
| 8   | `drift_state`               | `Pubkey`           |
| 9   | `integration_acc2`          | `Pubkey`           |
| 10  | `integration_acc3`          | `Pubkey`           |
| 11  | `integration_acc1`          | `Pubkey`           |
| 12  | `drift_spot_market_vault`   | `Pubkey`           |
| 13  | `drift_reward_oracle`       | `Option<Pubkey>`   |
| 14  | `drift_reward_spot_market`  | `Option<Pubkey>`   |
| 15  | `drift_reward_mint`         | `Option<Pubkey>`   |
| 16  | `drift_reward_oracle2`      | `Option<Pubkey>`   |
| 17  | `drift_reward_spot_market2` | `Option<Pubkey>`   |
| 18  | `drift_reward_mint2`        | `Option<Pubkey>`   |
| 19  | `drift_signer`              | `Pubkey`           |
| 20  | `mint`                      | `Pubkey`           |
| 21  | `drift_program`             | `Pubkey`           |
| 22  | `token_program`             | `Pubkey`           |
| 23  | `system_program`            | `Pubkey`           |
| 24… | `remaining`                 | `Vec<AccountMeta>` |

### `EditGlobalFeeState`

> _From the program's IDL:_
>
> (global fee admin only) Adjust fees, admin, or the destination wallet

Discriminator `343e23815d45a5ca` · data `EditGlobalFeeState` · accounts `EditGlobalFeeStateInstructionAccounts`.

| Field                      | Type                              |
| -------------------------- | --------------------------------- |
| `admin`                    | `Pubkey`                          |
| `fee_wallet`               | `Pubkey`                          |
| `bank_init_flat_sol_fee`   | `u32`                             |
| `liquidation_flat_sol_fee` | `u32`                             |
| `order_init_flat_sol_fee`  | `u32`                             |
| `program_fee_fixed`        | [`WrappedI80F48`](#wrappedi80f48) |
| `program_fee_rate`         | [`WrappedI80F48`](#wrappedi80f48) |
| `liquidation_max_fee`      | [`WrappedI80F48`](#wrappedi80f48) |
| `order_execution_max_fee`  | [`WrappedI80F48`](#wrappedi80f48) |

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

Fields of `EditGlobalFeeStateInstructionAccounts`, in account order:

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

### `EditStakedSettings`

> _From the program's IDL:_
>
> (admin only) Edit the staked collateral settings for the group.

Discriminator `0b6cd757f00942f1` · data `EditStakedSettings` · accounts `EditStakedSettingsInstructionAccounts`.

| Field      | Type                                                    |
| ---------- | ------------------------------------------------------- |
| `settings` | [`StakedSettingsEditConfig`](#stakedsettingseditconfig) |

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

Fields of `EditStakedSettingsInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `marginfi_group`  | `Pubkey`           |
| 1  | `admin`           | `Pubkey`           |
| 2  | `staked_settings` | `Pubkey`           |
| 3… | `remaining`       | `Vec<AccountMeta>` |

### `EndDeleverage`

> _From the program's IDL:_
>
> (risk_admin only) End forced deleverage. Validates health did not worsen.

Discriminator `720efa8ffc68d6d1` · data `EndDeleverage` · accounts `EndDeleverageInstructionAccounts`.

No data fields.

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

Fields of `EndDeleverageInstructionAccounts`, in account order:

| #  | Field                | Type               |
| -- | -------------------- | ------------------ |
| 0  | `marginfi_account`   | `Pubkey`           |
| 1  | `liquidation_record` | `Pubkey`           |
| 2  | `group`              | `Pubkey`           |
| 3  | `risk_admin`         | `Pubkey`           |
| 4… | `remaining`          | `Vec<AccountMeta>` |

### `EndLiquidation`

> _From the program's IDL:_
>
> (liquidation_receiver, set in start_liquidation) End receivership liquidation. Validates health improved and seized assets are within fee limits. Charges a flat SOL fee.

Discriminator `6e0bf436e5b516b8` · data `EndLiquidation` · accounts `EndLiquidationInstructionAccounts`.

No data fields.

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

Fields of `EndLiquidationInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `marginfi_account`     | `Pubkey`           |
| 1  | `liquidation_record`   | `Pubkey`           |
| 2  | `liquidation_receiver` | `Pubkey`           |
| 3  | `fee_state`            | `Pubkey`           |
| 4  | `global_fee_wallet`    | `Pubkey`           |
| 5  | `system_program`       | `Pubkey`           |
| 6… | `remaining`            | `Vec<AccountMeta>` |

### `InitBankMetadata`

> _From the program's IDL:_
>
> (permissionless) pay the rent to open a bank's metadata.

Discriminator `5eef328889ccfed5` · data `InitBankMetadata` · accounts `InitBankMetadataInstructionAccounts`.

No data fields.

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

Fields of `InitBankMetadataInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `bank`           | `Pubkey`           |
| 1  | `fee_payer`      | `Pubkey`           |
| 2  | `metadata`       | `Pubkey`           |
| 3  | `system_program` | `Pubkey`           |
| 4… | `remaining`      | `Vec<AccountMeta>` |

### `InitGlobalFeeState`

> _From the program's IDL:_
>
> (Runs once per program) Configures the fee state account, where the global admin sets fees that are assessed to the protocol

Discriminator `5230f73bdc6de72c` · data `InitGlobalFeeState` · accounts `InitGlobalFeeStateInstructionAccounts`.

| Field                      | Type                              |
| -------------------------- | --------------------------------- |
| `admin`                    | `Pubkey`                          |
| `fee_wallet`               | `Pubkey`                          |
| `bank_init_flat_sol_fee`   | `u32`                             |
| `liquidation_flat_sol_fee` | `u32`                             |
| `order_init_flat_sol_fee`  | `u32`                             |
| `program_fee_fixed`        | [`WrappedI80F48`](#wrappedi80f48) |
| `program_fee_rate`         | [`WrappedI80F48`](#wrappedi80f48) |
| `liquidation_max_fee`      | [`WrappedI80F48`](#wrappedi80f48) |
| `order_execution_max_fee`  | [`WrappedI80F48`](#wrappedi80f48) |

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

Fields of `InitGlobalFeeStateInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `payer`          | `Pubkey`           |
| 1  | `fee_state`      | `Pubkey`           |
| 2  | `system_program` | `Pubkey`           |
| 3… | `remaining`      | `Vec<AccountMeta>` |

### `InitStakedSettings`

> _From the program's IDL:_
>
> (group admin only) Init the Staked Settings account, which is used to create staked collateral banks, and must run before any staked collateral bank can be created with `add_pool_permissionless`. Running this ix effectively opts the group into the staked collateral feature.

Discriminator `3423952c45564550` · data `InitStakedSettings` · accounts `InitStakedSettingsInstructionAccounts`.

| Field      | Type                                            |
| ---------- | ----------------------------------------------- |
| `settings` | [`StakedSettingsConfig`](#stakedsettingsconfig) |

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

Fields of `InitStakedSettingsInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `marginfi_group`  | `Pubkey`           |
| 1  | `admin`           | `Pubkey`           |
| 2  | `fee_payer`       | `Pubkey`           |
| 3  | `staked_settings` | `Pubkey`           |
| 4  | `system_program`  | `Pubkey`           |
| 5… | `remaining`       | `Vec<AccountMeta>` |

### `JuplendDeposit`

> _From the program's IDL:_
>
> (user) Deposit into a JupLend lending pool through a marginfi account.
>
> - amount - in the underlying token (e.g., USDC), in native decimals

Discriminator `720bda51b7a58fff` · data `JuplendDeposit` · accounts `JuplendDepositInstructionAccounts`.

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

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

Fields of `JuplendDepositInstructionAccounts`, in account order:

| #   | Field                                  | Type               |
| --- | -------------------------------------- | ------------------ |
| 0   | `group`                                | `Pubkey`           |
| 1   | `marginfi_account`                     | `Pubkey`           |
| 2   | `authority`                            | `Pubkey`           |
| 3   | `bank`                                 | `Pubkey`           |
| 4   | `signer_token_account`                 | `Pubkey`           |
| 5   | `liquidity_vault_authority`            | `Pubkey`           |
| 6   | `liquidity_vault`                      | `Pubkey`           |
| 7   | `mint`                                 | `Pubkey`           |
| 8   | `integration_acc1`                     | `Pubkey`           |
| 9   | `f_token_mint`                         | `Pubkey`           |
| 10  | `integration_acc2`                     | `Pubkey`           |
| 11  | `lending_admin`                        | `Pubkey`           |
| 12  | `supply_token_reserves_liquidity`      | `Pubkey`           |
| 13  | `lending_supply_position_on_liquidity` | `Pubkey`           |
| 14  | `rate_model`                           | `Pubkey`           |
| 15  | `vault`                                | `Pubkey`           |
| 16  | `liquidity`                            | `Pubkey`           |
| 17  | `liquidity_program`                    | `Pubkey`           |
| 18  | `rewards_rate_model`                   | `Pubkey`           |
| 19  | `juplend_program`                      | `Pubkey`           |
| 20  | `token_program`                        | `Pubkey`           |
| 21  | `associated_token_program`             | `Pubkey`           |
| 22  | `system_program`                       | `Pubkey`           |
| 23… | `remaining`                            | `Vec<AccountMeta>` |

### `JuplendInitPosition`

> _From the program's IDL:_
>
> (permissionless) Initialize the bank-level JupLend position.\
> This creates the bank's fToken ATA (owned by the bank liquidity vault authority) and performs a nominal seed deposit into JupLend, then flips the bank from `Paused` to `Operational`.

Discriminator `b0ff976a05cf4ad7` · data `JuplendInitPosition` · accounts `JuplendInitPositionInstructionAccounts`.

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

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

Fields of `JuplendInitPositionInstructionAccounts`, in account order:

| #   | Field                                  | Type               |
| --- | -------------------------------------- | ------------------ |
| 0   | `fee_payer`                            | `Pubkey`           |
| 1   | `signer_token_account`                 | `Pubkey`           |
| 2   | `bank`                                 | `Pubkey`           |
| 3   | `liquidity_vault_authority`            | `Pubkey`           |
| 4   | `liquidity_vault`                      | `Pubkey`           |
| 5   | `mint`                                 | `Pubkey`           |
| 6   | `integration_acc1`                     | `Pubkey`           |
| 7   | `f_token_mint`                         | `Pubkey`           |
| 8   | `integration_acc2`                     | `Pubkey`           |
| 9   | `lending_admin`                        | `Pubkey`           |
| 10  | `supply_token_reserves_liquidity`      | `Pubkey`           |
| 11  | `lending_supply_position_on_liquidity` | `Pubkey`           |
| 12  | `rate_model`                           | `Pubkey`           |
| 13  | `vault`                                | `Pubkey`           |
| 14  | `liquidity`                            | `Pubkey`           |
| 15  | `liquidity_program`                    | `Pubkey`           |
| 16  | `rewards_rate_model`                   | `Pubkey`           |
| 17  | `juplend_program`                      | `Pubkey`           |
| 18  | `token_program`                        | `Pubkey`           |
| 19  | `associated_token_program`             | `Pubkey`           |
| 20  | `system_program`                       | `Pubkey`           |
| 21… | `remaining`                            | `Vec<AccountMeta>` |

### `JuplendWithdraw`

> _From the program's IDL:_
>
> (user) Withdraw from a JupLend lending pool through a marginfi account.
>
> - amount - in the underlying token (e.g., USDC), in native decimals

Discriminator `f5a4fdca354dfbdd` · data `JuplendWithdraw` · accounts `JuplendWithdrawInstructionAccounts`.

| Field          | Type           |
| -------------- | -------------- |
| `amount`       | `u64`          |
| `withdraw_all` | `Option<bool>` |

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

Fields of `JuplendWithdrawInstructionAccounts`, in account order:

| #   | Field                                  | Type               |
| --- | -------------------------------------- | ------------------ |
| 0   | `group`                                | `Pubkey`           |
| 1   | `marginfi_account`                     | `Pubkey`           |
| 2   | `authority`                            | `Pubkey`           |
| 3   | `bank`                                 | `Pubkey`           |
| 4   | `destination_token_account`            | `Pubkey`           |
| 5   | `liquidity_vault_authority`            | `Pubkey`           |
| 6   | `mint`                                 | `Pubkey`           |
| 7   | `integration_acc1`                     | `Pubkey`           |
| 8   | `f_token_mint`                         | `Pubkey`           |
| 9   | `integration_acc2`                     | `Pubkey`           |
| 10  | `integration_acc3`                     | `Pubkey`           |
| 11  | `lending_admin`                        | `Pubkey`           |
| 12  | `supply_token_reserves_liquidity`      | `Pubkey`           |
| 13  | `lending_supply_position_on_liquidity` | `Pubkey`           |
| 14  | `rate_model`                           | `Pubkey`           |
| 15  | `vault`                                | `Pubkey`           |
| 16  | `claim_account`                        | `Pubkey`           |
| 17  | `liquidity`                            | `Pubkey`           |
| 18  | `liquidity_program`                    | `Pubkey`           |
| 19  | `rewards_rate_model`                   | `Pubkey`           |
| 20  | `juplend_program`                      | `Pubkey`           |
| 21  | `token_program`                        | `Pubkey`           |
| 22  | `associated_token_program`             | `Pubkey`           |
| 23  | `system_program`                       | `Pubkey`           |
| 24… | `remaining`                            | `Vec<AccountMeta>` |

### `KaminoDeposit`

> _From the program's IDL:_
>
> (user) Deposit into a Kamino pool through a marginfi account
>
> - amount - in the liquidity token (e.g. if there is a Kamino USDC bank, pass the amount of
>
> USDC desired), in native decimals.

Discriminator `ed08bcbb73633155` · data `KaminoDeposit` · accounts `KaminoDepositInstructionAccounts`.

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

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

Fields of `KaminoDepositInstructionAccounts`, in account order:

| #   | Field                                    | Type               |
| --- | ---------------------------------------- | ------------------ |
| 0   | `group`                                  | `Pubkey`           |
| 1   | `marginfi_account`                       | `Pubkey`           |
| 2   | `authority`                              | `Pubkey`           |
| 3   | `bank`                                   | `Pubkey`           |
| 4   | `signer_token_account`                   | `Pubkey`           |
| 5   | `liquidity_vault_authority`              | `Pubkey`           |
| 6   | `liquidity_vault`                        | `Pubkey`           |
| 7   | `integration_acc2`                       | `Pubkey`           |
| 8   | `lending_market`                         | `Pubkey`           |
| 9   | `lending_market_authority`               | `Pubkey`           |
| 10  | `integration_acc1`                       | `Pubkey`           |
| 11  | `mint`                                   | `Pubkey`           |
| 12  | `reserve_liquidity_supply`               | `Pubkey`           |
| 13  | `reserve_collateral_mint`                | `Pubkey`           |
| 14  | `reserve_destination_deposit_collateral` | `Pubkey`           |
| 15  | `obligation_farm_user_state`             | `Option<Pubkey>`   |
| 16  | `reserve_farm_state`                     | `Option<Pubkey>`   |
| 17  | `kamino_program`                         | `Pubkey`           |
| 18  | `farms_program`                          | `Pubkey`           |
| 19  | `collateral_token_program`               | `Pubkey`           |
| 20  | `liquidity_token_program`                | `Pubkey`           |
| 21  | `instruction_sysvar_account`             | `Pubkey`           |
| 22… | `remaining`                              | `Vec<AccountMeta>` |

### `KaminoHarvestReward`

> _From the program's IDL:_
>
> (permissionless) Harvest the specified reward index from the Kamino Farm attached to this bank. Rewards are always sent to the global fee wallet's canonical ATA.
>
> - `reward_index` — index of the reward token in the Kamino Farm's reward list

Discriminator `a3caf88d6a147405` · data `KaminoHarvestReward` · accounts `KaminoHarvestRewardInstructionAccounts`.

| Field          | Type  |
| -------------- | ----- |
| `reward_index` | `u64` |

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

Fields of `KaminoHarvestRewardInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `bank`                      | `Pubkey`           |
| 1   | `fee_state`                 | `Pubkey`           |
| 2   | `destination_token_account` | `Pubkey`           |
| 3   | `liquidity_vault_authority` | `Pubkey`           |
| 4   | `user_state`                | `Pubkey`           |
| 5   | `farm_state`                | `Pubkey`           |
| 6   | `global_config`             | `Pubkey`           |
| 7   | `reward_mint`               | `Pubkey`           |
| 8   | `user_reward_ata`           | `Pubkey`           |
| 9   | `rewards_vault`             | `Pubkey`           |
| 10  | `rewards_treasury_vault`    | `Pubkey`           |
| 11  | `farm_vaults_authority`     | `Pubkey`           |
| 12  | `scope_prices`              | `Option<Pubkey>`   |
| 13  | `farms_program`             | `Pubkey`           |
| 14  | `token_program`             | `Pubkey`           |
| 15… | `remaining`                 | `Vec<AccountMeta>` |

### `KaminoInitObligation`

> _From the program's IDL:_
>
> (permissionless) Initialize a Kamino obligation for a marginfi bank
>
> - amount - In token, in native decimals. Must be >10 (i.e. 10 lamports, not 10 tokens). Lost
>
> forever. Generally, try to make this the equivalent of around $1, in case\
> Kamino ever rounds small balances down to zero.

Discriminator `fdb1a0e1469cd96d` · data `KaminoInitObligation` · accounts `KaminoInitObligationInstructionAccounts`.

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

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

Fields of `KaminoInitObligationInstructionAccounts`, in account order:

| #   | Field                                    | Type               |
| --- | ---------------------------------------- | ------------------ |
| 0   | `fee_payer`                              | `Pubkey`           |
| 1   | `bank`                                   | `Pubkey`           |
| 2   | `signer_token_account`                   | `Pubkey`           |
| 3   | `liquidity_vault_authority`              | `Pubkey`           |
| 4   | `liquidity_vault`                        | `Pubkey`           |
| 5   | `integration_acc2`                       | `Pubkey`           |
| 6   | `user_metadata`                          | `Pubkey`           |
| 7   | `lending_market`                         | `Pubkey`           |
| 8   | `lending_market_authority`               | `Pubkey`           |
| 9   | `integration_acc1`                       | `Pubkey`           |
| 10  | `mint`                                   | `Pubkey`           |
| 11  | `reserve_liquidity_supply`               | `Pubkey`           |
| 12  | `reserve_collateral_mint`                | `Pubkey`           |
| 13  | `reserve_destination_deposit_collateral` | `Pubkey`           |
| 14  | `pyth_oracle`                            | `Option<Pubkey>`   |
| 15  | `switchboard_price_oracle`               | `Option<Pubkey>`   |
| 16  | `switchboard_twap_oracle`                | `Option<Pubkey>`   |
| 17  | `scope_prices`                           | `Option<Pubkey>`   |
| 18  | `obligation_farm_user_state`             | `Option<Pubkey>`   |
| 19  | `reserve_farm_state`                     | `Option<Pubkey>`   |
| 20  | `kamino_program`                         | `Pubkey`           |
| 21  | `farms_program`                          | `Pubkey`           |
| 22  | `collateral_token_program`               | `Pubkey`           |
| 23  | `liquidity_token_program`                | `Pubkey`           |
| 24  | `instruction_sysvar_account`             | `Pubkey`           |
| 25  | `rent`                                   | `Pubkey`           |
| 26  | `system_program`                         | `Pubkey`           |
| 27… | `remaining`                              | `Vec<AccountMeta>` |

### `KaminoWithdraw`

> _From the program's IDL:_
>
> (user) Withdraw from a Kamino pool through a marginfi account
>
> - amount - in the collateral token (NOT liquidity token), in native decimals. Must convert
>
> from collateral to liquidity token amounts using the current exchange rate.
>
> - withdraw_all - if true, withdraw the entire mrgn balance (Note: due to rounding down, a
>
> deposit and withdraw back to back may result in several lamports less)

Discriminator `c765292dd562e0c8` · data `KaminoWithdraw` · accounts `KaminoWithdrawInstructionAccounts`.

| Field          | Type           |
| -------------- | -------------- |
| `amount`       | `u64`          |
| `withdraw_all` | `Option<bool>` |

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

Fields of `KaminoWithdrawInstructionAccounts`, in account order:

| #   | Field                        | Type               |
| --- | ---------------------------- | ------------------ |
| 0   | `group`                      | `Pubkey`           |
| 1   | `marginfi_account`           | `Pubkey`           |
| 2   | `authority`                  | `Pubkey`           |
| 3   | `bank`                       | `Pubkey`           |
| 4   | `destination_token_account`  | `Pubkey`           |
| 5   | `liquidity_vault_authority`  | `Pubkey`           |
| 6   | `liquidity_vault`            | `Pubkey`           |
| 7   | `integration_acc2`           | `Pubkey`           |
| 8   | `lending_market`             | `Pubkey`           |
| 9   | `lending_market_authority`   | `Pubkey`           |
| 10  | `integration_acc1`           | `Pubkey`           |
| 11  | `mint`                       | `Pubkey`           |
| 12  | `reserve_liquidity_supply`   | `Pubkey`           |
| 13  | `reserve_collateral_mint`    | `Pubkey`           |
| 14  | `reserve_source_collateral`  | `Pubkey`           |
| 15  | `obligation_farm_user_state` | `Option<Pubkey>`   |
| 16  | `reserve_farm_state`         | `Option<Pubkey>`   |
| 17  | `kamino_program`             | `Pubkey`           |
| 18  | `farms_program`              | `Pubkey`           |
| 19  | `collateral_token_program`   | `Pubkey`           |
| 20  | `liquidity_token_program`    | `Pubkey`           |
| 21  | `instruction_sysvar_account` | `Pubkey`           |
| 22… | `remaining`                  | `Vec<AccountMeta>` |

### `LendingAccountBorrow`

> _From the program's IDL:_
>
> (account authority) Borrow assets from a bank. Accrues interest, records liability, applies origination fee, transfers tokens, and runs a health check.

Discriminator `047e74353005d41f` · data `LendingAccountBorrow` · accounts `LendingAccountBorrowInstructionAccounts`.

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

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

Fields of `LendingAccountBorrowInstructionAccounts`, in account order:

| #  | Field                            | Type               |
| -- | -------------------------------- | ------------------ |
| 0  | `group`                          | `Pubkey`           |
| 1  | `marginfi_account`               | `Pubkey`           |
| 2  | `authority`                      | `Pubkey`           |
| 3  | `bank`                           | `Pubkey`           |
| 4  | `destination_token_account`      | `Pubkey`           |
| 5  | `bank_liquidity_vault_authority` | `Pubkey`           |
| 6  | `liquidity_vault`                | `Pubkey`           |
| 7  | `token_program`                  | `Pubkey`           |
| 8… | `remaining`                      | `Vec<AccountMeta>` |

### `LendingAccountClearEmissions`

> _From the program's IDL:_
>
> (permissionless) Zero out `emissions_outstanding` on a balance after emissions are disabled on the bank.

Discriminator `ef04dd622da7c9f4` · data `LendingAccountClearEmissions` · accounts `LendingAccountClearEmissionsInstructionAccounts`.

No data fields.

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

Fields of `LendingAccountClearEmissionsInstructionAccounts`, in account order:

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

### `LendingAccountCloseBalance`

> _From the program's IDL:_
>
> (account authority) Close a balance position with dust-level amounts.

Discriminator `f5362904f3ca1f11` · data `LendingAccountCloseBalance` · accounts `LendingAccountCloseBalanceInstructionAccounts`.

No data fields.

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

Fields of `LendingAccountCloseBalanceInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `group`            | `Pubkey`           |
| 1  | `marginfi_account` | `Pubkey`           |
| 2  | `authority`        | `Pubkey`           |
| 3  | `bank`             | `Pubkey`           |
| 4… | `remaining`        | `Vec<AccountMeta>` |

### `LendingAccountDeposit`

> _From the program's IDL:_
>
> (account authority) Deposit assets into a bank. Accrues interest, records deposit, and transfers tokens from the signer's token account to the bank's liquidity vault.

Discriminator `ab5eeb675240d48c` · data `LendingAccountDeposit` · accounts `LendingAccountDepositInstructionAccounts`.

| Field                 | Type           |
| --------------------- | -------------- |
| `amount`              | `u64`          |
| `deposit_up_to_limit` | `Option<bool>` |

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

Fields of `LendingAccountDepositInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `group`                | `Pubkey`           |
| 1  | `marginfi_account`     | `Pubkey`           |
| 2  | `authority`            | `Pubkey`           |
| 3  | `bank`                 | `Pubkey`           |
| 4  | `signer_token_account` | `Pubkey`           |
| 5  | `liquidity_vault`      | `Pubkey`           |
| 6  | `token_program`        | `Pubkey`           |
| 7… | `remaining`            | `Vec<AccountMeta>` |

### `LendingAccountEndFlashloan`

> _From the program's IDL:_
>
> (account authority) End a flash loan and run the health check.

Discriminator `697cc96a9902089c` · data `LendingAccountEndFlashloan` · accounts `LendingAccountEndFlashloanInstructionAccounts`.

No data fields.

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

Fields of `LendingAccountEndFlashloanInstructionAccounts`, in account order:

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

### `LendingAccountLiquidate`

> _From the program's IDL:_
>
> (permissionless) Liquidate a lending account balance of an unhealthy marginfi account. The liquidator takes on the liability and receives discounted collateral (2.5% liquidator fee + 2.5% insurance fee).
>
> - `asset_amount` - amount of collateral to liquidate
> - `liquidatee_accounts` - number of remaining accounts for the liquidatee
> - `liquidator_accounts` - number of remaining accounts for the liquidator

Discriminator `d6a997d5fba756db` · data `LendingAccountLiquidate` · accounts `LendingAccountLiquidateInstructionAccounts`.

| Field                 | Type  |
| --------------------- | ----- |
| `asset_amount`        | `u64` |
| `liquidatee_accounts` | `u8`  |
| `liquidator_accounts` | `u8`  |

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

Fields of `LendingAccountLiquidateInstructionAccounts`, in account order:

| #   | Field                            | Type               |
| --- | -------------------------------- | ------------------ |
| 0   | `group`                          | `Pubkey`           |
| 1   | `asset_bank`                     | `Pubkey`           |
| 2   | `liab_bank`                      | `Pubkey`           |
| 3   | `liquidator_marginfi_account`    | `Pubkey`           |
| 4   | `authority`                      | `Pubkey`           |
| 5   | `liquidatee_marginfi_account`    | `Pubkey`           |
| 6   | `bank_liquidity_vault_authority` | `Pubkey`           |
| 7   | `bank_liquidity_vault`           | `Pubkey`           |
| 8   | `bank_insurance_vault`           | `Pubkey`           |
| 9   | `token_program`                  | `Pubkey`           |
| 10… | `remaining`                      | `Vec<AccountMeta>` |

### `LendingAccountPulseHealth`

> _From the program's IDL:_
>
> (Permissionless) Refresh the internal risk engine health cache. Useful for liquidators and other consumers that want to see the internal risk state of a user account. This cache is read-only and serves no purpose except being populated by this ix.
>
> - remaining accounts expected in the same order as borrow, etc. I.e., for each balance the
>
> user has, pass bank and oracle: \<bank1, oracle1, bank2, oracle2>

Discriminator `ba347561224a27fd` · data `LendingAccountPulseHealth` · accounts `LendingAccountPulseHealthInstructionAccounts`.

No data fields.

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

Fields of `LendingAccountPulseHealthInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `marginfi_account` | `Pubkey`           |
| 1… | `remaining`        | `Vec<AccountMeta>` |

### `LendingAccountRepay`

> _From the program's IDL:_
>
> (account authority, or any signer during receivership) Repay borrowed assets. Accrues interest, records repayment, and transfers tokens to the bank's liquidity vault.

Discriminator `4fd1acb1de33ad97` · data `LendingAccountRepay` · accounts `LendingAccountRepayInstructionAccounts`.

| Field       | Type           |
| ----------- | -------------- |
| `amount`    | `u64`          |
| `repay_all` | `Option<bool>` |

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

Fields of `LendingAccountRepayInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `group`                | `Pubkey`           |
| 1  | `marginfi_account`     | `Pubkey`           |
| 2  | `authority`            | `Pubkey`           |
| 3  | `bank`                 | `Pubkey`           |
| 4  | `signer_token_account` | `Pubkey`           |
| 5  | `liquidity_vault`      | `Pubkey`           |
| 6  | `token_program`        | `Pubkey`           |
| 7… | `remaining`            | `Vec<AccountMeta>` |

### `LendingAccountStartFlashloan`

> _From the program's IDL:_
>
> (account authority) Start a flash loan. Must have a corresponding `end_flashloan` ix in the same tx. Health checks are skipped until the flash loan ends.

Discriminator `0e8321dc51bab46b` · data `LendingAccountStartFlashloan` · accounts `LendingAccountStartFlashloanInstructionAccounts`.

| Field       | Type  |
| ----------- | ----- |
| `end_index` | `u64` |

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

Fields of `LendingAccountStartFlashloanInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `marginfi_account` | `Pubkey`           |
| 1  | `authority`        | `Pubkey`           |
| 2  | `ixs_sysvar`       | `Pubkey`           |
| 3… | `remaining`        | `Vec<AccountMeta>` |

### `LendingAccountWithdraw`

> _From the program's IDL:_
>
> (account authority, or any signer during receivership) Withdraw assets from a bank. Accrues interest, records withdrawal, transfers tokens, and runs a health check (skipped during receivership).

Discriminator `24484a13d2d2c0c0` · data `LendingAccountWithdraw` · accounts `LendingAccountWithdrawInstructionAccounts`.

| Field          | Type           |
| -------------- | -------------- |
| `amount`       | `u64`          |
| `withdraw_all` | `Option<bool>` |

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

Fields of `LendingAccountWithdrawInstructionAccounts`, in account order:

| #  | Field                            | Type               |
| -- | -------------------------------- | ------------------ |
| 0  | `group`                          | `Pubkey`           |
| 1  | `marginfi_account`               | `Pubkey`           |
| 2  | `authority`                      | `Pubkey`           |
| 3  | `bank`                           | `Pubkey`           |
| 4  | `destination_token_account`      | `Pubkey`           |
| 5  | `bank_liquidity_vault_authority` | `Pubkey`           |
| 6  | `liquidity_vault`                | `Pubkey`           |
| 7  | `token_program`                  | `Pubkey`           |
| 8… | `remaining`                      | `Vec<AccountMeta>` |

### `LendingPoolAccrueBankInterest`

> _From the program's IDL:_
>
> (permissionless) Accrue interest on a bank, updating share values and collecting fees.

Discriminator `6cc91e572f4161bc` · data `LendingPoolAccrueBankInterest` · accounts `LendingPoolAccrueBankInterestInstructionAccounts`.

No data fields.

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

Fields of `LendingPoolAccrueBankInterestInstructionAccounts`, in account order:

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

### `LendingPoolAddBank`

> _From the program's IDL:_
>
> (admin only) Add a new bank to the lending pool

Discriminator `d744484ed0da67b6` · data `LendingPoolAddBank` · accounts `LendingPoolAddBankInstructionAccounts`.

| Field         | Type                                      |
| ------------- | ----------------------------------------- |
| `bank_config` | [`BankConfigCompact`](#bankconfigcompact) |

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

Fields of `LendingPoolAddBankInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `marginfi_group`            | `Pubkey`           |
| 1   | `admin`                     | `Pubkey`           |
| 2   | `fee_payer`                 | `Pubkey`           |
| 3   | `fee_state`                 | `Pubkey`           |
| 4   | `global_fee_wallet`         | `Pubkey`           |
| 5   | `bank_mint`                 | `Pubkey`           |
| 6   | `bank`                      | `Pubkey`           |
| 7   | `liquidity_vault_authority` | `Pubkey`           |
| 8   | `liquidity_vault`           | `Pubkey`           |
| 9   | `insurance_vault_authority` | `Pubkey`           |
| 10  | `insurance_vault`           | `Pubkey`           |
| 11  | `fee_vault_authority`       | `Pubkey`           |
| 12  | `fee_vault`                 | `Pubkey`           |
| 13  | `token_program`             | `Pubkey`           |
| 14  | `system_program`            | `Pubkey`           |
| 15… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolAddBankDrift`

> _From the program's IDL:_
>
> (group admin only) Add a Drift bank to the group.

Discriminator `3e3f31304c376c9b` · data `LendingPoolAddBankDrift` · accounts `LendingPoolAddBankDriftInstructionAccounts`.

| Field         | Type                                        |
| ------------- | ------------------------------------------- |
| `bank_config` | [`DriftConfigCompact`](#driftconfigcompact) |
| `bank_seed`   | `u64`                                       |

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

Fields of `LendingPoolAddBankDriftInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `group`                     | `Pubkey`           |
| 1   | `admin`                     | `Pubkey`           |
| 2   | `fee_payer`                 | `Pubkey`           |
| 3   | `bank_mint`                 | `Pubkey`           |
| 4   | `bank`                      | `Pubkey`           |
| 5   | `integration_acc1`          | `Pubkey`           |
| 6   | `integration_acc2`          | `Pubkey`           |
| 7   | `integration_acc3`          | `Pubkey`           |
| 8   | `liquidity_vault_authority` | `Pubkey`           |
| 9   | `liquidity_vault`           | `Pubkey`           |
| 10  | `insurance_vault_authority` | `Pubkey`           |
| 11  | `insurance_vault`           | `Pubkey`           |
| 12  | `fee_vault_authority`       | `Pubkey`           |
| 13  | `fee_vault`                 | `Pubkey`           |
| 14  | `token_program`             | `Pubkey`           |
| 15  | `system_program`            | `Pubkey`           |
| 16… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolAddBankJuplend`

> _From the program's IDL:_
>
> (admin) Add a JupLend bank to the marginfi group.\
> Remaining accounts (for oracle validation):
> 0\. underlying oracle feed (pyth push or switchboard pull)
>
> 1. JupLend `Lending` state

Discriminator `12d0755a356fc329` · data `LendingPoolAddBankJuplend` · accounts `LendingPoolAddBankJuplendInstructionAccounts`.

| Field         | Type                                            |
| ------------- | ----------------------------------------------- |
| `bank_config` | [`JuplendConfigCompact`](#juplendconfigcompact) |
| `bank_seed`   | `u64`                                           |

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

Fields of `LendingPoolAddBankJuplendInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `group`                     | `Pubkey`           |
| 1   | `admin`                     | `Pubkey`           |
| 2   | `fee_payer`                 | `Pubkey`           |
| 3   | `bank_mint`                 | `Pubkey`           |
| 4   | `bank`                      | `Pubkey`           |
| 5   | `integration_acc1`          | `Pubkey`           |
| 6   | `liquidity_vault_authority` | `Pubkey`           |
| 7   | `liquidity_vault`           | `Pubkey`           |
| 8   | `insurance_vault_authority` | `Pubkey`           |
| 9   | `insurance_vault`           | `Pubkey`           |
| 10  | `fee_vault_authority`       | `Pubkey`           |
| 11  | `fee_vault`                 | `Pubkey`           |
| 12  | `f_token_mint`              | `Pubkey`           |
| 13  | `integration_acc2`          | `Pubkey`           |
| 14  | `token_program`             | `Pubkey`           |
| 15  | `system_program`            | `Pubkey`           |
| 16… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolAddBankKamino`

> _From the program's IDL:_
>
> (group admin only) Add a Kamino bank to the group. Pass the oracle and reserve in remaining accounts 0 and 1 respectively.

Discriminator `763510f3fff595f1` · data `LendingPoolAddBankKamino` · accounts `LendingPoolAddBankKaminoInstructionAccounts`.

| Field         | Type                                          |
| ------------- | --------------------------------------------- |
| `bank_config` | [`KaminoConfigCompact`](#kaminoconfigcompact) |
| `bank_seed`   | `u64`                                         |

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

Fields of `LendingPoolAddBankKaminoInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `group`                     | `Pubkey`           |
| 1   | `admin`                     | `Pubkey`           |
| 2   | `fee_payer`                 | `Pubkey`           |
| 3   | `bank_mint`                 | `Pubkey`           |
| 4   | `bank`                      | `Pubkey`           |
| 5   | `integration_acc1`          | `Pubkey`           |
| 6   | `integration_acc2`          | `Pubkey`           |
| 7   | `liquidity_vault_authority` | `Pubkey`           |
| 8   | `liquidity_vault`           | `Pubkey`           |
| 9   | `insurance_vault_authority` | `Pubkey`           |
| 10  | `insurance_vault`           | `Pubkey`           |
| 11  | `fee_vault_authority`       | `Pubkey`           |
| 12  | `fee_vault`                 | `Pubkey`           |
| 13  | `token_program`             | `Pubkey`           |
| 14  | `system_program`            | `Pubkey`           |
| 15… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolAddBankPermissionless`

> _From the program's IDL:_
>
> (permissionless) Add a staked collateral bank. Requires a valid SPL single-pool LST mint.

Discriminator `7fbb7922bba7ee66` · data `LendingPoolAddBankPermissionless` · accounts `LendingPoolAddBankPermissionlessInstructionAccounts`.

| Field       | Type  |
| ----------- | ----- |
| `bank_seed` | `u64` |

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

Fields of `LendingPoolAddBankPermissionlessInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `marginfi_group`            | `Pubkey`           |
| 1   | `staked_settings`           | `Pubkey`           |
| 2   | `fee_payer`                 | `Pubkey`           |
| 3   | `bank_mint`                 | `Pubkey`           |
| 4   | `sol_pool`                  | `Pubkey`           |
| 5   | `stake_pool`                | `Pubkey`           |
| 6   | `bank`                      | `Pubkey`           |
| 7   | `liquidity_vault_authority` | `Pubkey`           |
| 8   | `liquidity_vault`           | `Pubkey`           |
| 9   | `insurance_vault_authority` | `Pubkey`           |
| 10  | `insurance_vault`           | `Pubkey`           |
| 11  | `fee_vault_authority`       | `Pubkey`           |
| 12  | `fee_vault`                 | `Pubkey`           |
| 13  | `token_program`             | `Pubkey`           |
| 14  | `system_program`            | `Pubkey`           |
| 15… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolAddBankSolend`

> _From the program's IDL:_
>
> (admin) Add a Solend bank to the marginfi group

Discriminator `51e9cbc72fe20044` · data `LendingPoolAddBankSolend` · accounts `LendingPoolAddBankSolendInstructionAccounts`.

| Field         | Type                                          |
| ------------- | --------------------------------------------- |
| `bank_config` | [`SolendConfigCompact`](#solendconfigcompact) |
| `bank_seed`   | `u64`                                         |

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

Fields of `LendingPoolAddBankSolendInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `group`                     | `Pubkey`           |
| 1   | `admin`                     | `Pubkey`           |
| 2   | `fee_payer`                 | `Pubkey`           |
| 3   | `bank_mint`                 | `Pubkey`           |
| 4   | `bank`                      | `Pubkey`           |
| 5   | `integration_acc1`          | `Pubkey`           |
| 6   | `integration_acc2`          | `Pubkey`           |
| 7   | `liquidity_vault_authority` | `Pubkey`           |
| 8   | `liquidity_vault`           | `Pubkey`           |
| 9   | `insurance_vault_authority` | `Pubkey`           |
| 10  | `insurance_vault`           | `Pubkey`           |
| 11  | `fee_vault_authority`       | `Pubkey`           |
| 12  | `fee_vault`                 | `Pubkey`           |
| 13  | `token_program`             | `Pubkey`           |
| 14  | `system_program`            | `Pubkey`           |
| 15… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolAddBankWithSeed`

> _From the program's IDL:_
>
> (admin only) A copy of lending_pool_add_bank with an additional bank seed.\
> This seed is used to create a PDA for the bank's signature.\
> lending_pool_add_bank is preserved for backwards compatibility.

Discriminator `4cd3d5ab754e9e4c` · data `LendingPoolAddBankWithSeed` · accounts `LendingPoolAddBankWithSeedInstructionAccounts`.

| Field         | Type                                      |
| ------------- | ----------------------------------------- |
| `bank_config` | [`BankConfigCompact`](#bankconfigcompact) |
| `bank_seed`   | `u64`                                     |

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

Fields of `LendingPoolAddBankWithSeedInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `marginfi_group`            | `Pubkey`           |
| 1   | `admin`                     | `Pubkey`           |
| 2   | `fee_payer`                 | `Pubkey`           |
| 3   | `fee_state`                 | `Pubkey`           |
| 4   | `global_fee_wallet`         | `Pubkey`           |
| 5   | `bank_mint`                 | `Pubkey`           |
| 6   | `bank`                      | `Pubkey`           |
| 7   | `liquidity_vault_authority` | `Pubkey`           |
| 8   | `liquidity_vault`           | `Pubkey`           |
| 9   | `insurance_vault_authority` | `Pubkey`           |
| 10  | `insurance_vault`           | `Pubkey`           |
| 11  | `fee_vault_authority`       | `Pubkey`           |
| 12  | `fee_vault`                 | `Pubkey`           |
| 13  | `token_program`             | `Pubkey`           |
| 14  | `system_program`            | `Pubkey`           |
| 15… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolCloneBank`

> _From the program's IDL:_
>
> (admin only) Staging or localnet only, panics on mainnet\
> This instruction is used to clone a bank to a new PDA.

Discriminator `d65d11ecb1e44e11` · data `LendingPoolCloneBank` · accounts `LendingPoolCloneBankInstructionAccounts`.

| Field       | Type  |
| ----------- | ----- |
| `bank_seed` | `u64` |

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

Fields of `LendingPoolCloneBankInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `marginfi_group`            | `Pubkey`           |
| 1   | `admin`                     | `Pubkey`           |
| 2   | `fee_payer`                 | `Pubkey`           |
| 3   | `bank_mint`                 | `Pubkey`           |
| 4   | `source_bank`               | `Pubkey`           |
| 5   | `bank`                      | `Pubkey`           |
| 6   | `liquidity_vault_authority` | `Pubkey`           |
| 7   | `liquidity_vault`           | `Pubkey`           |
| 8   | `insurance_vault_authority` | `Pubkey`           |
| 9   | `insurance_vault`           | `Pubkey`           |
| 10  | `fee_vault_authority`       | `Pubkey`           |
| 11  | `fee_vault`                 | `Pubkey`           |
| 12  | `token_program`             | `Pubkey`           |
| 13  | `system_program`            | `Pubkey`           |
| 14… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolCloneEmode`

> _From the program's IDL:_
>
> (admin or emode_admin) Copies emode settings from one bank to another.\
> Useful when applying emode settings from e.g. one LST to another.

Discriminator `92a75e6ab8ca0f0a` · data `LendingPoolCloneEmode` · accounts `LendingPoolCloneEmodeInstructionAccounts`.

No data fields.

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

Fields of `LendingPoolCloneEmodeInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `group`          | `Pubkey`           |
| 1  | `signer`         | `Pubkey`           |
| 2  | `copy_from_bank` | `Pubkey`           |
| 3  | `copy_to_bank`   | `Pubkey`           |
| 4… | `remaining`      | `Vec<AccountMeta>` |

### `LendingPoolCloseBank`

> _From the program's IDL:_
>
> (admin only) Close a bank. Requires CLOSE_ENABLED_FLAG and zero positions/shares.

Discriminator `16730782e355002f` · data `LendingPoolCloseBank` · accounts `LendingPoolCloseBankInstructionAccounts`.

No data fields.

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

Fields of `LendingPoolCloseBankInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `group`     | `Pubkey`           |
| 1  | `bank`      | `Pubkey`           |
| 2  | `admin`     | `Pubkey`           |
| 3… | `remaining` | `Vec<AccountMeta>` |

### `LendingPoolCollectBankFees`

> _From the program's IDL:_
>
> (permissionless) Transfer accrued fees from the liquidity vault to insurance/fee/program vaults.

Discriminator `c905d774e65c4b96` · data `LendingPoolCollectBankFees` · accounts `LendingPoolCollectBankFeesInstructionAccounts`.

No data fields.

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

Fields of `LendingPoolCollectBankFeesInstructionAccounts`, in account order:

| #  | Field                       | Type               |
| -- | --------------------------- | ------------------ |
| 0  | `group`                     | `Pubkey`           |
| 1  | `bank`                      | `Pubkey`           |
| 2  | `liquidity_vault_authority` | `Pubkey`           |
| 3  | `liquidity_vault`           | `Pubkey`           |
| 4  | `insurance_vault`           | `Pubkey`           |
| 5  | `fee_vault`                 | `Pubkey`           |
| 6  | `fee_state`                 | `Pubkey`           |
| 7  | `fee_ata`                   | `Pubkey`           |
| 8  | `token_program`             | `Pubkey`           |
| 9… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolConfigureBank`

> _From the program's IDL:_
>
> (admin only) Configure bank parameters. If the bank has `FREEZE_SETTINGS`, only deposit/borrow limits are updated and all other config changes are silently ignored.

Discriminator `79ad9c285d9438ed` · data `LendingPoolConfigureBank` · accounts `LendingPoolConfigureBankInstructionAccounts`.

| Field             | Type                              |
| ----------------- | --------------------------------- |
| `bank_config_opt` | [`BankConfigOpt`](#bankconfigopt) |

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

Fields of `LendingPoolConfigureBankInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `group`     | `Pubkey`           |
| 1  | `admin`     | `Pubkey`           |
| 2  | `bank`      | `Pubkey`           |
| 3… | `remaining` | `Vec<AccountMeta>` |

### `LendingPoolConfigureBankEmode`

> _From the program's IDL:_
>
> (emode_admin only)

Discriminator `11af5b39ef563147` · data `LendingPoolConfigureBankEmode` · accounts `LendingPoolConfigureBankEmodeInstructionAccounts`.

| Field       | Type                              |
| ----------- | --------------------------------- |
| `emode_tag` | `u16`                             |
| `entries`   | [`[EmodeEntry; 10]`](#emodeentry) |

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

Fields of `LendingPoolConfigureBankEmodeInstructionAccounts`, in account order:

| #  | Field         | Type               |
| -- | ------------- | ------------------ |
| 0  | `group`       | `Pubkey`           |
| 1  | `emode_admin` | `Pubkey`           |
| 2  | `bank`        | `Pubkey`           |
| 3… | `remaining`   | `Vec<AccountMeta>` |

### `LendingPoolConfigureBankInterestOnly`

> _From the program's IDL:_
>
> (delegate_curve_admin only) Update interest rate config. Does nothing if bank has `FREEZE_SETTINGS`.

Discriminator `f56b532667dba3f1` · data `LendingPoolConfigureBankInterestOnly` · accounts `LendingPoolConfigureBankInterestOnlyInstructionAccounts`.

| Field                  | Type                                              |
| ---------------------- | ------------------------------------------------- |
| `interest_rate_config` | [`InterestRateConfigOpt`](#interestrateconfigopt) |

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

Fields of `LendingPoolConfigureBankInterestOnlyInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `group`                | `Pubkey`           |
| 1  | `delegate_curve_admin` | `Pubkey`           |
| 2  | `bank`                 | `Pubkey`           |
| 3… | `remaining`            | `Vec<AccountMeta>` |

### `LendingPoolConfigureBankLimitsOnly`

> _From the program's IDL:_
>
> (delegate_limit_admin only) Update deposit/borrow/init limits only.

Discriminator `9dc4ddc8ca3e5415` · data `LendingPoolConfigureBankLimitsOnly` · accounts `LendingPoolConfigureBankLimitsOnlyInstructionAccounts`.

| Field                          | Type          |
| ------------------------------ | ------------- |
| `deposit_limit`                | `Option<u64>` |
| `borrow_limit`                 | `Option<u64>` |
| `total_asset_value_init_limit` | `Option<u64>` |

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

Fields of `LendingPoolConfigureBankLimitsOnlyInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `group`                | `Pubkey`           |
| 1  | `delegate_limit_admin` | `Pubkey`           |
| 2  | `bank`                 | `Pubkey`           |
| 3… | `remaining`            | `Vec<AccountMeta>` |

### `LendingPoolConfigureBankOracle`

> _From the program's IDL:_
>
> (admin only)

Discriminator `d152ffab7c154751` · data `LendingPoolConfigureBankOracle` · accounts `LendingPoolConfigureBankOracleInstructionAccounts`.

| Field    | Type     |
| -------- | -------- |
| `setup`  | `u8`     |
| `oracle` | `Pubkey` |

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

Fields of `LendingPoolConfigureBankOracleInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `group`     | `Pubkey`           |
| 1  | `admin`     | `Pubkey`           |
| 2  | `bank`      | `Pubkey`           |
| 3… | `remaining` | `Vec<AccountMeta>` |

### `LendingPoolForceTokenlessRepayComplete`

> _From the program's IDL:_
>
> (risk_admin only) - Signals all of a bank's liability have been deleveraged.\
> Used if a bank still has liability dust after the risk admin has completed deleveraging all debts. The risk admin is trusted not to execute this until all non-dust debts have been deleveraged.

Discriminator `0fcb93e8c70ee725` · data `LendingPoolForceTokenlessRepayComplete` · accounts `LendingPoolForceTokenlessRepayCompleteInstructionAccounts`.

No data fields.

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

Fields of `LendingPoolForceTokenlessRepayCompleteInstructionAccounts`, in account order:

| #  | Field        | Type               |
| -- | ------------ | ------------------ |
| 0  | `group`      | `Pubkey`           |
| 1  | `risk_admin` | `Pubkey`           |
| 2  | `bank`       | `Pubkey`           |
| 3… | `remaining`  | `Vec<AccountMeta>` |

### `LendingPoolHandleBankruptcy`

> _From the program's IDL:_
>
> (risk_admin or admin, unless `PERMISSIONLESS_BAD_DEBT_SETTLEMENT_FLAG` is set on the bank) Handle bad debt of a bankrupt marginfi account for a given bank. Covers bad debt from the insurance fund and socializes any remainder among depositors.

Discriminator `a20b388b5a8046ad` · data `LendingPoolHandleBankruptcy` · accounts `LendingPoolHandleBankruptcyInstructionAccounts`.

No data fields.

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

Fields of `LendingPoolHandleBankruptcyInstructionAccounts`, in account order:

| #  | Field                       | Type               |
| -- | --------------------------- | ------------------ |
| 0  | `group`                     | `Pubkey`           |
| 1  | `signer`                    | `Pubkey`           |
| 2  | `bank`                      | `Pubkey`           |
| 3  | `marginfi_account`          | `Pubkey`           |
| 4  | `liquidity_vault`           | `Pubkey`           |
| 5  | `insurance_vault`           | `Pubkey`           |
| 6  | `insurance_vault_authority` | `Pubkey`           |
| 7  | `token_program`             | `Pubkey`           |
| 8… | `remaining`                 | `Vec<AccountMeta>` |

### `LendingPoolPulseBankPriceCache`

> _From the program's IDL:_
>
> (Permissionless) Refresh the cached oracle price for a bank.

Discriminator `c013c98769cb20de` · data `LendingPoolPulseBankPriceCache` · accounts `LendingPoolPulseBankPriceCacheInstructionAccounts`.

No data fields.

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

Fields of `LendingPoolPulseBankPriceCacheInstructionAccounts`, in account order:

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

### `LendingPoolReclaimEmissionsVault`

> _From the program's IDL:_
>
> (permissionless) Reclaim all remaining tokens from the emissions vault to the global fee wallet ATA, and disable emissions on the bank.

Discriminator `ce43bae1291e5fd8` · data `LendingPoolReclaimEmissionsVault` · accounts `LendingPoolReclaimEmissionsVaultInstructionAccounts`.

No data fields.

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

Fields of `LendingPoolReclaimEmissionsVaultInstructionAccounts`, in account order:

| #  | Field                 | Type               |
| -- | --------------------- | ------------------ |
| 0  | `group`               | `Pubkey`           |
| 1  | `bank`                | `Pubkey`           |
| 2  | `emissions_mint`      | `Pubkey`           |
| 3  | `emissions_auth`      | `Pubkey`           |
| 4  | `emissions_vault`     | `Pubkey`           |
| 5  | `fee_state`           | `Pubkey`           |
| 6  | `destination_account` | `Pubkey`           |
| 7  | `token_program`       | `Pubkey`           |
| 8… | `remaining`           | `Vec<AccountMeta>` |

### `LendingPoolSetFixedOraclePrice`

> _From the program's IDL:_
>
> (admin only)

Discriminator `1c7e7f7f3c25d37d` · data `LendingPoolSetFixedOraclePrice` · accounts `LendingPoolSetFixedOraclePriceInstructionAccounts`.

| Field   | Type                              |
| ------- | --------------------------------- |
| `price` | [`WrappedI80F48`](#wrappedi80f48) |

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

Fields of `LendingPoolSetFixedOraclePriceInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `group`     | `Pubkey`           |
| 1  | `admin`     | `Pubkey`           |
| 2  | `bank`      | `Pubkey`           |
| 3… | `remaining` | `Vec<AccountMeta>` |

### `LendingPoolUpdateFeesDestinationAccount`

> _From the program's IDL:_
>
> (admin only) Set the destination wallet for permissionless fee withdrawals.

Discriminator `660479f3ed6e5f0d` · data `LendingPoolUpdateFeesDestinationAccount` · accounts `LendingPoolUpdateFeesDestinationAccountInstructionAccounts`.

No data fields.

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

Fields of `LendingPoolUpdateFeesDestinationAccountInstructionAccounts`, in account order:

| #  | Field                 | Type               |
| -- | --------------------- | ------------------ |
| 0  | `group`               | `Pubkey`           |
| 1  | `bank`                | `Pubkey`           |
| 2  | `admin`               | `Pubkey`           |
| 3  | `destination_account` | `Pubkey`           |
| 4… | `remaining`           | `Vec<AccountMeta>` |

### `LendingPoolWithdrawFees`

> _From the program's IDL:_
>
> (admin only) Withdraw collected group fees from the fee vault.

Discriminator `5c8cd7feaa0053ae` · data `LendingPoolWithdrawFees` · accounts `LendingPoolWithdrawFeesInstructionAccounts`.

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

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

Fields of `LendingPoolWithdrawFeesInstructionAccounts`, in account order:

| #  | Field                 | Type               |
| -- | --------------------- | ------------------ |
| 0  | `group`               | `Pubkey`           |
| 1  | `bank`                | `Pubkey`           |
| 2  | `admin`               | `Pubkey`           |
| 3  | `fee_vault`           | `Pubkey`           |
| 4  | `fee_vault_authority` | `Pubkey`           |
| 5  | `dst_token_account`   | `Pubkey`           |
| 6  | `token_program`       | `Pubkey`           |
| 7… | `remaining`           | `Vec<AccountMeta>` |

### `LendingPoolWithdrawFeesPermissionless`

> _From the program's IDL:_
>
> (permissionless) Withdraw group fees to the pre-configured `fees_destination_account`.

Discriminator `39f501d082129171` · data `LendingPoolWithdrawFeesPermissionless` · accounts `LendingPoolWithdrawFeesPermissionlessInstructionAccounts`.

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

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

Fields of `LendingPoolWithdrawFeesPermissionlessInstructionAccounts`, in account order:

| #  | Field                      | Type               |
| -- | -------------------------- | ------------------ |
| 0  | `group`                    | `Pubkey`           |
| 1  | `bank`                     | `Pubkey`           |
| 2  | `fee_vault`                | `Pubkey`           |
| 3  | `fee_vault_authority`      | `Pubkey`           |
| 4  | `fees_destination_account` | `Pubkey`           |
| 5  | `token_program`            | `Pubkey`           |
| 6… | `remaining`                | `Vec<AccountMeta>` |

### `LendingPoolWithdrawInsurance`

> _From the program's IDL:_
>
> (admin only) Withdraw from the insurance vault.

Discriminator `6c3c3cf6684f9ff3` · data `LendingPoolWithdrawInsurance` · accounts `LendingPoolWithdrawInsuranceInstructionAccounts`.

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

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

Fields of `LendingPoolWithdrawInsuranceInstructionAccounts`, in account order:

| #  | Field                       | Type               |
| -- | --------------------------- | ------------------ |
| 0  | `group`                     | `Pubkey`           |
| 1  | `bank`                      | `Pubkey`           |
| 2  | `admin`                     | `Pubkey`           |
| 3  | `insurance_vault`           | `Pubkey`           |
| 4  | `insurance_vault_authority` | `Pubkey`           |
| 5  | `dst_token_account`         | `Pubkey`           |
| 6  | `token_program`             | `Pubkey`           |
| 7… | `remaining`                 | `Vec<AccountMeta>` |

### `MarginfiAccountClose`

> _From the program's IDL:_
>
> (account authority) Close a marginfi account. Requires all balances to be empty and no active flags (disabled, flashloan, receivership).

Discriminator `badd5d223261c2f1` · data `MarginfiAccountClose` · accounts `MarginfiAccountCloseInstructionAccounts`.

No data fields.

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

Fields of `MarginfiAccountCloseInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `marginfi_account` | `Pubkey`           |
| 1  | `authority`        | `Pubkey`           |
| 2  | `fee_payer`        | `Pubkey`           |
| 3… | `remaining`        | `Vec<AccountMeta>` |

### `MarginfiAccountCloseOrder`

> _From the program's IDL:_
>
> (user) Close an existing Order, returning rent to the user

Discriminator `d4df4fb6acb7cded` · data `MarginfiAccountCloseOrder` · accounts `MarginfiAccountCloseOrderInstructionAccounts`.

No data fields.

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

Fields of `MarginfiAccountCloseOrderInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `marginfi_account` | `Pubkey`           |
| 1  | `authority`        | `Pubkey`           |
| 2  | `order`            | `Pubkey`           |
| 3  | `fee_recipient`    | `Pubkey`           |
| 4  | `system_program`   | `Pubkey`           |
| 5… | `remaining`        | `Vec<AccountMeta>` |

### `MarginfiAccountEndExecuteOrder`

> _From the program's IDL:_
>
> (permissionless keeper) End Order execution
>
> - Closes the Order (keeper keeps the rent)
> - Closes the borrow position involved in the Order, the lending position remains open
> - User health must be "unchanged" (within Order requirements i.e. minus slippage). Keeper
>
> may keep any slippage in excess of what was needed to complete the Order as profit.
>
> - `StartExecuteOrder` must appear earlier in the tx
> - Must appear last in the tx
> - CPI is forbidden
> - Returns rent for ephemeral accounts created during `StartExecuteOrder`

Discriminator `732a145d7954b253` · data `MarginfiAccountEndExecuteOrder` · accounts `MarginfiAccountEndExecuteOrderInstructionAccounts`.

No data fields.

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

Fields of `MarginfiAccountEndExecuteOrderInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `group`            | `Pubkey`           |
| 1  | `marginfi_account` | `Pubkey`           |
| 2  | `executor`         | `Pubkey`           |
| 3  | `fee_recipient`    | `Pubkey`           |
| 4  | `order`            | `Pubkey`           |
| 5  | `execute_record`   | `Pubkey`           |
| 6  | `fee_state`        | `Pubkey`           |
| 7… | `remaining`        | `Vec<AccountMeta>` |

### `MarginfiAccountInitialize`

> _From the program's IDL:_
>
> Initialize a marginfi account for a given group. The account is a fresh keypair, and must sign. If you are a CPI caller, consider using `marginfi_account_initialize_pda` instead, or create the account manually and use `transfer_to_new_account` to gift it to the owner you wish.

Discriminator `2b4e3dff9434f99a` · data `MarginfiAccountInitialize` · accounts `MarginfiAccountInitializeInstructionAccounts`.

No data fields.

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

Fields of `MarginfiAccountInitializeInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `marginfi_group`   | `Pubkey`           |
| 1  | `marginfi_account` | `Pubkey`           |
| 2  | `authority`        | `Pubkey`           |
| 3  | `fee_payer`        | `Pubkey`           |
| 4  | `system_program`   | `Pubkey`           |
| 5… | `remaining`        | `Vec<AccountMeta>` |

### `MarginfiAccountInitializePda`

> _From the program's IDL:_
>
> The same as `marginfi_account_initialize`, except the created marginfi account uses a PDA (Program Derived Address) seeds:
>
> - marginfi_group
> - authority: The account authority (owner)
> - account_index: A u16 value to allow multiple accounts per authority
> - third_party_id: Optional u16 for third-party tagging. Seeds <\
>   PDA_FREE_THRESHOLD can be
>
> used freely. For a dedicated seed used by just your program (via CPI), contact us.

Discriminator `57b15b50da77f51f` · data `MarginfiAccountInitializePda` · accounts `MarginfiAccountInitializePdaInstructionAccounts`.

| Field            | Type          |
| ---------------- | ------------- |
| `account_index`  | `u16`         |
| `third_party_id` | `Option<u16>` |

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

Fields of `MarginfiAccountInitializePdaInstructionAccounts`, in account order:

| #  | Field                 | Type               |
| -- | --------------------- | ------------------ |
| 0  | `marginfi_group`      | `Pubkey`           |
| 1  | `marginfi_account`    | `Pubkey`           |
| 2  | `authority`           | `Pubkey`           |
| 3  | `fee_payer`           | `Pubkey`           |
| 4  | `instructions_sysvar` | `Pubkey`           |
| 5  | `system_program`      | `Pubkey`           |
| 6… | `remaining`           | `Vec<AccountMeta>` |

### `MarginfiAccountInitLiqRecord`

> _From the program's IDL:_
>
> (permissionless) Initialize a liquidation record PDA for a marginfi account.\
> The fee_payer pays rent; the record is required for receivership liquidation.

Discriminator `ecd5ee7e93fba408` · data `MarginfiAccountInitLiqRecord` · accounts `MarginfiAccountInitLiqRecordInstructionAccounts`.

No data fields.

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

Fields of `MarginfiAccountInitLiqRecordInstructionAccounts`, in account order:

| #  | Field                | Type               |
| -- | -------------------- | ------------------ |
| 0  | `marginfi_account`   | `Pubkey`           |
| 1  | `fee_payer`          | `Pubkey`           |
| 2  | `liquidation_record` | `Pubkey`           |
| 3  | `system_program`     | `Pubkey`           |
| 4… | `remaining`          | `Vec<AccountMeta>` |

### `MarginfiAccountKeeperCloseOrder`

> _From the program's IDL:_
>
> (permissionless keeper) Close an existing Order after the user account was closed, or it no longer has the associated positions, or the user has executed `marginfi_account_set_keeper_close_flags`. Keeper keeps the rent.

Discriminator `8072472ec247ba6a` · data `MarginfiAccountKeeperCloseOrder` · accounts `MarginfiAccountKeeperCloseOrderInstructionAccounts`.

No data fields.

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

Fields of `MarginfiAccountKeeperCloseOrderInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `marginfi_account` | `Pubkey`           |
| 1  | `fee_recipient`    | `Pubkey`           |
| 2  | `order`            | `Pubkey`           |
| 3… | `remaining`        | `Vec<AccountMeta>` |

### `MarginfiAccountPlaceOrder`

> _From the program's IDL:_
>
> (user) Create a new Order.
>
> - bank_keys - Currently only two keys: the lending position and borrowing position in the
>
> users's Balances for which the order is being placed
>
> - trigger - the type of order (stop loss, take profit, or both), and the threshold at which
>
> to trigger the order, in dollars

Discriminator `f4704b8a8f6c07ba` · data `MarginfiAccountPlaceOrder` · accounts `MarginfiAccountPlaceOrderInstructionAccounts`.

| Field       | Type                            |
| ----------- | ------------------------------- |
| `bank_keys` | `Vec<Pubkey>`                   |
| `trigger`   | [`OrderTrigger`](#ordertrigger) |

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

Fields of `MarginfiAccountPlaceOrderInstructionAccounts`, in account order:

| #  | Field               | Type               |
| -- | ------------------- | ------------------ |
| 0  | `group`             | `Pubkey`           |
| 1  | `marginfi_account`  | `Pubkey`           |
| 2  | `fee_payer`         | `Pubkey`           |
| 3  | `authority`         | `Pubkey`           |
| 4  | `order`             | `Pubkey`           |
| 5  | `fee_state`         | `Pubkey`           |
| 6  | `global_fee_wallet` | `Pubkey`           |
| 7  | `system_program`    | `Pubkey`           |
| 8… | `remaining`         | `Vec<AccountMeta>` |

### `MarginfiAccountSetFreeze`

> _From the program's IDL:_
>
> (admin only) Freeze or unfreeze a marginfi account. Frozen accounts can only be operated on by the group admin.

Discriminator `c7b3e71e8af76ee3` · data `MarginfiAccountSetFreeze` · accounts `MarginfiAccountSetFreezeInstructionAccounts`.

| Field    | Type   |
| -------- | ------ |
| `frozen` | `bool` |

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

Fields of `MarginfiAccountSetFreezeInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `group`            | `Pubkey`           |
| 1  | `marginfi_account` | `Pubkey`           |
| 2  | `admin`            | `Pubkey`           |
| 3… | `remaining`        | `Vec<AccountMeta>` |

### `MarginfiAccountSetKeeperCloseFlags`

> _From the program's IDL:_
>
> (user) Purge flags from some balances, enabling a Keeper to call `marginfi_account_keeper_close_order` on associated Orders. Typically, use `marginfi_account_close_order` instead if trying to close an Order.

Discriminator `52a3a5ded4ff21d2` · data `MarginfiAccountSetKeeperCloseFlags` · accounts `MarginfiAccountSetKeeperCloseFlagsInstructionAccounts`.

| Field           | Type                  |
| --------------- | --------------------- |
| `bank_keys_opt` | `Option<Vec<Pubkey>>` |

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

Fields of `MarginfiAccountSetKeeperCloseFlagsInstructionAccounts`, in account order:

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

### `MarginfiAccountStartExecuteOrder`

> _From the program's IDL:_
>
> (permissionless keeper) Begin Order execution
>
> - Enables the Keeper to withdraw/repay associated positions until the end of the tx
> - Only one `StartExecuteOrder` is allowed per tx
> - Must appear before `EndExecuteOrder` in the tx, and before any instructions except certain
>
> allowed ones (compute budget, kamino refresh, etc)
>
> - `EndExecuteOrder` must also appear in the tx
> - CPI is forbidden
> - Costs a small amount of rent, which is returned at the end of the tx, make sure you have
>
> enough SOL to start the tx.

Discriminator `01468c86b71dd0e0` · data `MarginfiAccountStartExecuteOrder` · accounts `MarginfiAccountStartExecuteOrderInstructionAccounts`.

No data fields.

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

Fields of `MarginfiAccountStartExecuteOrderInstructionAccounts`, in account order:

| #  | Field                | Type               |
| -- | -------------------- | ------------------ |
| 0  | `group`              | `Pubkey`           |
| 1  | `marginfi_account`   | `Pubkey`           |
| 2  | `fee_payer`          | `Pubkey`           |
| 3  | `executor`           | `Pubkey`           |
| 4  | `order`              | `Pubkey`           |
| 5  | `execute_record`     | `Pubkey`           |
| 6  | `instruction_sysvar` | `Pubkey`           |
| 7  | `system_program`     | `Pubkey`           |
| 8… | `remaining`          | `Vec<AccountMeta>` |

### `MarginfiAccountUpdateEmissionsDestinationAccount`

> _From the program's IDL:_
>
> (account authority) Set the wallet whose canonical ATA will receive off-chain emissions.

Discriminator `49b9a2c96f1874b9` · data `MarginfiAccountUpdateEmissionsDestinationAccount` · accounts `MarginfiAccountUpdateEmissionsDestinationAccountInstructionAccounts`.

No data fields.

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

Fields of `MarginfiAccountUpdateEmissionsDestinationAccountInstructionAccounts`, in account order:

| #  | Field                 | Type               |
| -- | --------------------- | ------------------ |
| 0  | `marginfi_account`    | `Pubkey`           |
| 1  | `authority`           | `Pubkey`           |
| 2  | `destination_account` | `Pubkey`           |
| 3… | `remaining`           | `Vec<AccountMeta>` |

### `MarginfiGroupConfigure`

> _From the program's IDL:_
>
> (admin only) Configure group admin keys and emode leverage caps. All admin keys must be provided on every call. Emode leverage caps are set if provided, otherwise the existing (non-zero) values are kept. Pass `Some(value)` to update, `None` to leave unchanged.

Discriminator `3ec7514e210dec3d` · data `MarginfiGroupConfigure` · accounts `MarginfiGroupConfigureInstructionAccounts`.

| Field                      | Type                                      |
| -------------------------- | ----------------------------------------- |
| `new_admin`                | `Option<Pubkey>`                          |
| `new_emode_admin`          | `Option<Pubkey>`                          |
| `new_curve_admin`          | `Option<Pubkey>`                          |
| `new_limit_admin`          | `Option<Pubkey>`                          |
| `new_flow_admin`           | `Option<Pubkey>`                          |
| `new_emissions_admin`      | `Option<Pubkey>`                          |
| `new_metadata_admin`       | `Option<Pubkey>`                          |
| `new_risk_admin`           | `Option<Pubkey>`                          |
| `emode_max_init_leverage`  | [`Option<WrappedI80F48>`](#wrappedi80f48) |
| `emode_max_maint_leverage` | [`Option<WrappedI80F48>`](#wrappedi80f48) |

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

Fields of `MarginfiGroupConfigureInstructionAccounts`, in account order:

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

### `MarginfiGroupInitialize`

> _From the program's IDL:_
>
> (admin only) Initialize a new marginfi group. The signer becomes the group admin.

Discriminator `ff43431a5e1f2214` · data `MarginfiGroupInitialize` · accounts `MarginfiGroupInitializeInstructionAccounts`.

No data fields.

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

Fields of `MarginfiGroupInitializeInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `marginfi_group` | `Pubkey`           |
| 1  | `admin`          | `Pubkey`           |
| 2  | `fee_state`      | `Pubkey`           |
| 3  | `system_program` | `Pubkey`           |
| 4… | `remaining`      | `Vec<AccountMeta>` |

### `MigrateCurve`

> _From the program's IDL:_
>
> (Permissionless) Convert a bank from the legacy curve setup to the new setup, with no effect on how interest accrues.

Discriminator `97fe320d70eb9848` · data `MigrateCurve` · accounts `MigrateCurveInstructionAccounts`.

No data fields.

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

Fields of `MigrateCurveInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `bank`      | `Pubkey`           |
| 1… | `remaining` | `Vec<AccountMeta>` |

### `PanicPause`

> _From the program's IDL:_
>
> (global_fee_admin only) Pause the protocol. Auto-expires after 30 minutes.\
> Limited to 3 pauses per day and 2 consecutive pauses.

Discriminator `4ca47b19042b4fa5` · data `PanicPause` · accounts `PanicPauseInstructionAccounts`.

No data fields.

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

Fields of `PanicPauseInstructionAccounts`, in account order:

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

### `PanicUnpause`

> _From the program's IDL:_
>
> (global_fee_admin only) Unpause the protocol before the auto-expiry.

Discriminator `ec6bc2f263337980` · data `PanicUnpause` · accounts `PanicUnpauseInstructionAccounts`.

No data fields.

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

Fields of `PanicUnpauseInstructionAccounts`, in account order:

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

### `PanicUnpausePermissionless`

> _From the program's IDL:_
>
> (permissionless) Unpause the protocol when pause time has expired

Discriminator `f58b329fd53e5bf8` · data `PanicUnpausePermissionless` · accounts `PanicUnpausePermissionlessInstructionAccounts`.

No data fields.

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

Fields of `PanicUnpausePermissionlessInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `fee_state` | `Pubkey`           |
| 1… | `remaining` | `Vec<AccountMeta>` |

### `PropagateFeeState`

> _From the program's IDL:_
>
> (Permissionless) Force any group to adopt the current FeeState settings

Discriminator `4003a6c28115659b` · data `PropagateFeeState` · accounts `PropagateFeeStateInstructionAccounts`.

No data fields.

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

Fields of `PropagateFeeStateInstructionAccounts`, in account order:

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

### `PropagateStakedSettings`

> _From the program's IDL:_
>
> (permissionless) Propagate updated staked settings to a staked collateral bank.

Discriminator `d21e98458263deaa` · data `PropagateStakedSettings` · accounts `PropagateStakedSettingsInstructionAccounts`.

No data fields.

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

Fields of `PropagateStakedSettingsInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `marginfi_group`  | `Pubkey`           |
| 1  | `staked_settings` | `Pubkey`           |
| 2  | `bank`            | `Pubkey`           |
| 3… | `remaining`       | `Vec<AccountMeta>` |

### `PurgeDeleverageBalance`

> _From the program's IDL:_
>
> (risk admin only) Purge a user's lending balance without withdrawing anything. Only usable after all the debt has been settled on a bank in deleveraging mode, e.g. when `TOKENLESS_REPAYMENTS_ALLOWED` and `TOKENLESS_REPAYMENTS_COMPLETE`. used to purge remaining lending assets in a now-worthless bank before it is fully sunset.

Discriminator `84bb1995b53bfd88` · data `PurgeDeleverageBalance` · accounts `PurgeDeleverageBalanceInstructionAccounts`.

No data fields.

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

Fields of `PurgeDeleverageBalanceInstructionAccounts`, in account order:

| #  | Field              | Type               |
| -- | ------------------ | ------------------ |
| 0  | `group`            | `Pubkey`           |
| 1  | `marginfi_account` | `Pubkey`           |
| 2  | `risk_admin`       | `Pubkey`           |
| 3  | `bank`             | `Pubkey`           |
| 4… | `remaining`        | `Vec<AccountMeta>` |

### `SolendDeposit`

> _From the program's IDL:_
>
> (user) Deposit into a Solend reserve through a marginfi account
>
> - amount - in the underlying token (e.g., USDC), in native decimals

Discriminator `387fb0940c190318` · data `SolendDeposit` · accounts `SolendDepositInstructionAccounts`.

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

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

Fields of `SolendDepositInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `group`                     | `Pubkey`           |
| 1   | `marginfi_account`          | `Pubkey`           |
| 2   | `authority`                 | `Pubkey`           |
| 3   | `bank`                      | `Pubkey`           |
| 4   | `signer_token_account`      | `Pubkey`           |
| 5   | `liquidity_vault_authority` | `Pubkey`           |
| 6   | `liquidity_vault`           | `Pubkey`           |
| 7   | `integration_acc2`          | `Pubkey`           |
| 8   | `lending_market`            | `Pubkey`           |
| 9   | `lending_market_authority`  | `Pubkey`           |
| 10  | `integration_acc1`          | `Pubkey`           |
| 11  | `mint`                      | `Pubkey`           |
| 12  | `reserve_liquidity_supply`  | `Pubkey`           |
| 13  | `reserve_collateral_mint`   | `Pubkey`           |
| 14  | `reserve_collateral_supply` | `Pubkey`           |
| 15  | `user_collateral`           | `Pubkey`           |
| 16  | `pyth_price`                | `Pubkey`           |
| 17  | `switchboard_feed`          | `Pubkey`           |
| 18  | `solend_program`            | `Pubkey`           |
| 19  | `token_program`             | `Pubkey`           |
| 20… | `remaining`                 | `Vec<AccountMeta>` |

### `SolendInitObligation`

> _From the program's IDL:_
>
> (permissionless) Initialize a Solend obligation for a marginfi bank\
> Requires a minimum deposit to ensure the obligation remains active
>
> - amount - minimum deposit amount (at least 10 units) in native decimals

Discriminator `51607b95da74ebc4` · data `SolendInitObligation` · accounts `SolendInitObligationInstructionAccounts`.

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

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

Fields of `SolendInitObligationInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `fee_payer`                 | `Pubkey`           |
| 1   | `bank`                      | `Pubkey`           |
| 2   | `signer_token_account`      | `Pubkey`           |
| 3   | `liquidity_vault_authority` | `Pubkey`           |
| 4   | `liquidity_vault`           | `Pubkey`           |
| 5   | `integration_acc2`          | `Pubkey`           |
| 6   | `lending_market`            | `Pubkey`           |
| 7   | `lending_market_authority`  | `Pubkey`           |
| 8   | `integration_acc1`          | `Pubkey`           |
| 9   | `mint`                      | `Pubkey`           |
| 10  | `reserve_liquidity_supply`  | `Pubkey`           |
| 11  | `reserve_collateral_mint`   | `Pubkey`           |
| 12  | `reserve_collateral_supply` | `Pubkey`           |
| 13  | `user_collateral`           | `Pubkey`           |
| 14  | `pyth_price`                | `Pubkey`           |
| 15  | `switchboard_feed`          | `Pubkey`           |
| 16  | `solend_program`            | `Pubkey`           |
| 17  | `token_program`             | `Pubkey`           |
| 18  | `rent`                      | `Pubkey`           |
| 19  | `system_program`            | `Pubkey`           |
| 20… | `remaining`                 | `Vec<AccountMeta>` |

### `SolendWithdraw`

> _From the program's IDL:_
>
> (user) Withdraw from a Solend reserve through a marginfi account
>
> - amount - in collateral tokens (cTokens), in native decimals
> - withdraw_all - withdraw entire position if true

Discriminator `ee90aac715489b24` · data `SolendWithdraw` · accounts `SolendWithdrawInstructionAccounts`.

| Field          | Type           |
| -------------- | -------------- |
| `amount`       | `u64`          |
| `withdraw_all` | `Option<bool>` |

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

Fields of `SolendWithdrawInstructionAccounts`, in account order:

| #   | Field                       | Type               |
| --- | --------------------------- | ------------------ |
| 0   | `group`                     | `Pubkey`           |
| 1   | `marginfi_account`          | `Pubkey`           |
| 2   | `authority`                 | `Pubkey`           |
| 3   | `bank`                      | `Pubkey`           |
| 4   | `destination_token_account` | `Pubkey`           |
| 5   | `liquidity_vault_authority` | `Pubkey`           |
| 6   | `liquidity_vault`           | `Pubkey`           |
| 7   | `integration_acc2`          | `Pubkey`           |
| 8   | `lending_market`            | `Pubkey`           |
| 9   | `lending_market_authority`  | `Pubkey`           |
| 10  | `integration_acc1`          | `Pubkey`           |
| 11  | `mint`                      | `Pubkey`           |
| 12  | `reserve_liquidity_supply`  | `Pubkey`           |
| 13  | `reserve_collateral_mint`   | `Pubkey`           |
| 14  | `reserve_collateral_supply` | `Pubkey`           |
| 15  | `user_collateral`           | `Pubkey`           |
| 16  | `solend_program`            | `Pubkey`           |
| 17  | `token_program`             | `Pubkey`           |
| 18… | `remaining`                 | `Vec<AccountMeta>` |

### `StartDeleverage`

> _From the program's IDL:_
>
> (risk_admin only) Begin forced deleverage on an account. Similar to start_liquidation but does not require the account to be unhealthy.

Discriminator `0a8a0a3928e8b6c1` · data `StartDeleverage` · accounts `StartDeleverageInstructionAccounts`.

No data fields.

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

Fields of `StartDeleverageInstructionAccounts`, in account order:

| #  | Field                | Type               |
| -- | -------------------- | ------------------ |
| 0  | `marginfi_account`   | `Pubkey`           |
| 1  | `liquidation_record` | `Pubkey`           |
| 2  | `group`              | `Pubkey`           |
| 3  | `risk_admin`         | `Pubkey`           |
| 4  | `instruction_sysvar` | `Pubkey`           |
| 5… | `remaining`          | `Vec<AccountMeta>` |

### `StartLiquidation`

> _From the program's IDL:_
>
> (permissionless) Begin receivership liquidation on an unhealthy account.\
> Snapshots health and marks the account in receivership. Must have `end_liquidation` as the last ix in the tx.

Discriminator `f45d5ad6c0a6bf15` · data `StartLiquidation` · accounts `StartLiquidationInstructionAccounts`.

No data fields.

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

Fields of `StartLiquidationInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `marginfi_account`     | `Pubkey`           |
| 1  | `liquidation_record`   | `Pubkey`           |
| 2  | `liquidation_receiver` | `Pubkey`           |
| 3  | `instruction_sysvar`   | `Pubkey`           |
| 4… | `remaining`            | `Vec<AccountMeta>` |

### `SuperAdminDeposit`

> _From the program's IDL:_
>
> (primary admin only) Deposit directly into a bank liquidity vault and raise `asset_share_value` proportionally. No marginfi account is involved.

Discriminator `f1bdc711cfe1404b` · data `SuperAdminDeposit` · accounts `SuperAdminDepositInstructionAccounts`.

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

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

Fields of `SuperAdminDepositInstructionAccounts`, in account order:

| #  | Field                 | Type               |
| -- | --------------------- | ------------------ |
| 0  | `group`               | `Pubkey`           |
| 1  | `admin`               | `Pubkey`           |
| 2  | `bank`                | `Pubkey`           |
| 3  | `admin_token_account` | `Pubkey`           |
| 4  | `liquidity_vault`     | `Pubkey`           |
| 5  | `token_program`       | `Pubkey`           |
| 6… | `remaining`           | `Vec<AccountMeta>` |

### `SuperAdminWithdraw`

> _From the program's IDL:_
>
> (primary admin only) Withdraw directly from a bank liquidity vault and lower `asset_share_value` proportionally. No marginfi account is involved.

Discriminator `ca43557e688a4fc5` · data `SuperAdminWithdraw` · accounts `SuperAdminWithdrawInstructionAccounts`.

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

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

Fields of `SuperAdminWithdrawInstructionAccounts`, in account order:

| #  | Field                       | Type               |
| -- | --------------------------- | ------------------ |
| 0  | `group`                     | `Pubkey`           |
| 1  | `admin`                     | `Pubkey`           |
| 2  | `bank`                      | `Pubkey`           |
| 3  | `destination_token_account` | `Pubkey`           |
| 4  | `liquidity_vault_authority` | `Pubkey`           |
| 5  | `liquidity_vault`           | `Pubkey`           |
| 6  | `token_program`             | `Pubkey`           |
| 7… | `remaining`                 | `Vec<AccountMeta>` |

### `TransferToNewAccount`

> _From the program's IDL:_
>
> (account authority) Transfer all positions to a new account under a new authority. The old account is disabled. Pays a flat SOL fee to the protocol.

Discriminator `1c4f81e7a9454541` · data `TransferToNewAccount` · accounts `TransferToNewAccountInstructionAccounts`.

No data fields.

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

Fields of `TransferToNewAccountInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `group`                | `Pubkey`           |
| 1  | `old_marginfi_account` | `Pubkey`           |
| 2  | `new_marginfi_account` | `Pubkey`           |
| 3  | `authority`            | `Pubkey`           |
| 4  | `fee_payer`            | `Pubkey`           |
| 5  | `new_authority`        | `Pubkey`           |
| 6  | `global_fee_wallet`    | `Pubkey`           |
| 7  | `system_program`       | `Pubkey`           |
| 8… | `remaining`            | `Vec<AccountMeta>` |

### `TransferToNewAccountPda`

> _From the program's IDL:_
>
> (account authority) Same as `transfer_to_new_account` except the resulting account is a PDA seeds:
>
> - marginfi_group
> - authority: The account authority (owner)
> - account_index: A u16 value to allow multiple accounts per authority
> - third_party_id: Optional u16 for third-party tagging. Seeds <\
>   PDA_FREE_THRESHOLD can be
>
> used freely. For a dedicated seed used by just your program (via CPI), contact us.

Discriminator `acd2e0dc92d4fd31` · data `TransferToNewAccountPda` · accounts `TransferToNewAccountPdaInstructionAccounts`.

| Field            | Type          |
| ---------------- | ------------- |
| `account_index`  | `u16`         |
| `third_party_id` | `Option<u16>` |

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

Fields of `TransferToNewAccountPdaInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `group`                | `Pubkey`           |
| 1  | `old_marginfi_account` | `Pubkey`           |
| 2  | `new_marginfi_account` | `Pubkey`           |
| 3  | `authority`            | `Pubkey`           |
| 4  | `fee_payer`            | `Pubkey`           |
| 5  | `new_authority`        | `Pubkey`           |
| 6  | `global_fee_wallet`    | `Pubkey`           |
| 7  | `instructions_sysvar`  | `Pubkey`           |
| 8  | `system_program`       | `Pubkey`           |
| 9… | `remaining`            | `Vec<AccountMeta>` |

### `UpdateDeleverageWithdrawals`

> _From the program's IDL:_
>
> (delegate_flow_admin only) Update the deleverage daily withdraw outflow with aggregated data. The delegate flow admin aggregates `DeleverageWithdrawFlowEvent` events off-chain and calls this instruction at intervals.

Discriminator `3803b5761bf7cfe3` · data `UpdateDeleverageWithdrawals` · accounts `UpdateDeleverageWithdrawalsInstructionAccounts`.

| Field              | Type  |
| ------------------ | ----- |
| `outflow_usd`      | `u32` |
| `update_seq`       | `u64` |
| `event_start_slot` | `u64` |
| `event_end_slot`   | `u64` |

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

Fields of `UpdateDeleverageWithdrawalsInstructionAccounts`, in account order:

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

### `UpdateGroupRateLimiter`

> _From the program's IDL:_
>
> (delegate_flow_admin only) Update the group rate limiter with aggregated inflow/outflow. The delegate flow admin aggregates `RateLimitFlowEvent` events off-chain, converts to USD, and calls this instruction at intervals to update group rate limiter state.

Discriminator `174e3c8bbb2c8125` · data `UpdateGroupRateLimiter` · accounts `UpdateGroupRateLimiterInstructionAccounts`.

| Field              | Type          |
| ------------------ | ------------- |
| `outflow_usd`      | `Option<u64>` |
| `inflow_usd`       | `Option<u64>` |
| `update_seq`       | `u64`         |
| `event_start_slot` | `u64`         |
| `event_end_slot`   | `u64`         |

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

Fields of `UpdateGroupRateLimiterInstructionAccounts`, in account order:

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

### `WriteBankMetadata`

> _From the program's IDL:_
>
> (metadata admin only) Write ticker/description information for a bank on-chain. Optional, not all Banks are guaranteed to have metadata.

Discriminator `934e5185818ae93b` · data `WriteBankMetadata` · accounts `WriteBankMetadataInstructionAccounts`.

| Field         | Type              |
| ------------- | ----------------- |
| `ticker`      | `Option<Vec<u8>>` |
| `description` | `Option<Vec<u8>>` |

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

Fields of `WriteBankMetadataInstructionAccounts`, in account order:

| #  | Field            | Type               |
| -- | ---------------- | ------------------ |
| 0  | `group`          | `Pubkey`           |
| 1  | `bank`           | `Pubkey`           |
| 2  | `metadata_admin` | `Pubkey`           |
| 3  | `metadata`       | `Pubkey`           |
| 4… | `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 `MarginfiV2Account`. Each wraps a boxed struct from `carbon_marginfi_v2_decoder::accounts::<module>`. `decode_account` only considers accounts owned by `PROGRAM_ID` and returns the first variant that matches.

### `Bank`

Discriminator `8e31a6f2324261bc` · `accounts::bank::Bank`.

| Field                                  | Type                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------------------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mint`                                 | `Pubkey`                              | The SPL token mint this bank manages                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `mint_decimals`                        | `u8`                                  | Number of decimals of the `mint`. Must be < 24.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `group`                                | `Pubkey`                              | The `MarginfiGroup` this bank belongs to                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `_pad0`                                | `[u8; 7]`                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `asset_share_value`                    | [`WrappedI80F48`](#wrappedi80f48)     | Monotonically increases as interest rate accumulates. For typical banks, a user's asset value in token = (number of shares the user has \* asset_share_value). \* A float (arbitrary decimals) \* Initially 1                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `liability_share_value`                | [`WrappedI80F48`](#wrappedi80f48)     | Monotonically increases as interest rate accumulates. For typical banks, a user's liabilty value in token = (number of shares the user has \* liability_share_value) \* A float (arbitrary decimals) \* Initially 1                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `liquidity_vault`                      | `Pubkey`                              | The SPL token account holding deposited liquidity                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `liquidity_vault_bump`                 | `u8`                                  | PDA bump for the liquidity vault                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `liquidity_vault_authority_bump`       | `u8`                                  | PDA bump for the liquidity vault authority                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `insurance_vault`                      | `Pubkey`                              | The SPL token account holding insurance fund tokens                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `insurance_vault_bump`                 | `u8`                                  | PDA bump for the insurance vault                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `insurance_vault_authority_bump`       | `u8`                                  | PDA bump for the insurance vault authority                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `pad1`                                 | `[u8; 4]`                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `collected_insurance_fees_outstanding` | [`WrappedI80F48`](#wrappedi80f48)     | Fees collected and pending withdraw for the `insurance_vault`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `fee_vault`                            | `Pubkey`                              | The SPL token account holding collected group fees                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `fee_vault_bump`                       | `u8`                                  | PDA bump for the fee vault                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `fee_vault_authority_bump`             | `u8`                                  | PDA bump for the fee vault authority                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `pad2`                                 | `[u8; 6]`                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `collected_group_fees_outstanding`     | [`WrappedI80F48`](#wrappedi80f48)     | Fees collected and pending withdraw for the `fee_vault`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `total_liability_shares`               | [`WrappedI80F48`](#wrappedi80f48)     | Sum of all liability shares held by all borrowers in this bank. Multiply by `liability_share_value` to get the total liability amount in native token units.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `total_asset_shares`                   | [`WrappedI80F48`](#wrappedi80f48)     | Sum of all asset shares held by all depositors in this bank. Multiply by `asset_share_value` to get the total asset amount in native token units. \* For Kamino banks, this is the quantity of collateral tokens (NOT liquidity tokens) in the bank, and also uses `mint_decimals`, though the mint itself will always show (6) decimals exactly (i.e Kamino ignores this and treats it as if it was using `mint_decimals`)                                                                                                                                                                                                                       |
| `last_update`                          | `i64`                                 | Unix timestamp (i64) of the last interest accrual                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `config`                               | [`BankConfig`](#bankconfig)           | The bank's configuration parameters (weights, limits, oracle setup, interest rate config)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `flags`                                | `u64`                                 | Bank flags bitfield (u64). - Bit 0 (1): `EMISSIONS_FLAG_BORROW_ACTIVE` — borrow-side emissions are active - Bit 1 (2): `EMISSIONS_FLAG_LENDING_ACTIVE` — lending-side emissions are active - Bit 2 (4): `PERMISSIONLESS_BAD_DEBT_SETTLEMENT_FLAG` — anyone can settle bad debt - Bit 3 (8): `FREEZE_SETTINGS` — bank configuration is frozen (only limits can change) - Bit 4 (16): `CLOSE_ENABLED_FLAG` — bank can be closed (set at creation for banks >= 0.1.4) - Bit 5 (32): `TOKENLESS_REPAYMENTS_ALLOWED` — risk admin can repay debt without tokens - Bit 6 (64): `TOKENLESS_REPAYMENTS_COMPLETE` — all debt cleared, lender purge enabled |
| `emissions_rate`                       | `u64`                                 | Emissions APR. Number of emitted tokens (emissions_mint) per 1e(bank.mint_decimal) tokens (bank mint) (native amount) per 1 YEAR.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `emissions_remaining`                  | [`WrappedI80F48`](#wrappedi80f48)     | Remaining emissions tokens available for distribution                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `emissions_mint`                       | `Pubkey`                              | The SPL token mint used for emissions rewards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `collected_program_fees_outstanding`   | [`WrappedI80F48`](#wrappedi80f48)     | Fees collected and pending withdraw for the `FeeState.global_fee_wallet`'s canonical ATA for `mint`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `emode`                                | [`EmodeSettings`](#emodesettings)     | Controls this bank's emode configuration, which enables some banks to treat the assets of certain other banks more preferentially as collateral.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `fees_destination_account`             | `Pubkey`                              | Set with `update_fees_destination_account`. Fees can be withdrawn to the canonical ATA of this wallet without the admin's input (withdraw_fees_permissionless). If pubkey default, the bank doesn't support this feature, and the fees must be collected manually (withdraw_fees).                                                                                                                                                                                                                                                                                                                                                                |
| `cache`                                | [`BankCache`](#bankcache)             | Cached bank metrics (interest rates, oracle price, etc.)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `lending_position_count`               | `i32`                                 | Number of user lending positions currently open in this bank \* For banks created prior to 0.1.4, this is the number of positions opened/closed after 0.1.4 goes live, and may be negative. \* For banks created in 0.1.4 or later, this is the number of positions open in total, and the bank may safely be closed if this is zero. Will never go negative.                                                                                                                                                                                                                                                                                     |
| `borrowing_position_count`             | `i32`                                 | Number of user borrowing positions currently open in this bank \* For banks created prior to 0.1.4, this is the number of positions opened/closed after 0.1.4 goes live, and may be negative. \* For banks created in 0.1.4 or later, this is the number of positions open in total, and the bank may safely be closed if this is zero. Will never go negative.                                                                                                                                                                                                                                                                                   |
| `padding0`                             | `[u8; 16]`                            | Reserved for future use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `integration_acc1`                     | `Pubkey`                              | Integration account slot 1 (default Pubkey for non-integrations). - Kamino: reserve - Drift: spot market - Solend: reserve - JupLend: lending state                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `integration_acc2`                     | `Pubkey`                              | Integration account slot 2 (default Pubkey for non-integrations). - Kamino: obligation - Drift: user - Solend: obligation - JupLend: fToken vault                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `integration_acc3`                     | `Pubkey`                              | Integration account slot 3 (default Pubkey for non-integrations). - Drift: user stats - JupLend: withdraw intermediary ATA (ATA of liquidity_vault_authority for bank mint)                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `rate_limiter`                         | [`BankRateLimiter`](#bankratelimiter) | Rate limiter for controlling withdraw/borrow outflow. Tracks net outflow (outflows - inflows) in native tokens.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `pad0`                                 | `[u8; 16]`                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `padding1`                             | `[[u64; 2]; 7]`                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

### `BankMetadata`

Discriminator `31cf1f2243e1a9ba` · `accounts::bank_metadata::BankMetadata`.

| Field                  | Type        | Description                                                                |
| ---------------------- | ----------- | -------------------------------------------------------------------------- |
| `bank`                 | `Pubkey`    | Bank this metadata corresponds to                                          |
| `placeholder`          | `u64`       |                                                                            |
| `ticker`               | `[u8; 64]`  | The token's ticker name, e.g. USDC \* utf-8                                |
| `description`          | `[u8; 128]` | The token's plain english description, e.g US Dollar Coin \* utf-8         |
| `data_blob`            | `[u8; 256]` | Reserved for future use. Room for a very small icon or something else cool |
| `end_description_byte` | `u16`       | The last data byte in description (padding follows)                        |
| `end_data_blob`        | `u16`       | The last data byte in data_blob (padding follows)                          |
| `end_ticker_byte`      | `u8`        | The last data byte in ticker (padding follows)                             |
| `bump`                 | `u8`        |                                                                            |
| `pad0`                 | `[u8; 2]`   |                                                                            |

### `ExecuteOrderRecord`

Discriminator `06646b3ca4e23861` · `accounts::execute_order_record::ExecuteOrderRecord`.

| Field                    | Type                                                            |
| ------------------------ | --------------------------------------------------------------- |
| `order`                  | `Pubkey`                                                        |
| `executor`               | `Pubkey`                                                        |
| `balance_states`         | [`[ExecuteOrderBalanceRecord; 14]`](#executeorderbalancerecord) |
| `active_balance_count`   | `u8`                                                            |
| `inactive_balance_count` | `u8`                                                            |
| `reserved0`              | `[u8; 6]`                                                       |
| `order_start_health`     | [`WrappedI80F48`](#wrappedi80f48)                               |

### `FeeState`

Discriminator `3fe01055c124ebdc` · `accounts::fee_state::FeeState`.

| Field                      | Type                              | Description                                                                                                                                                              |
| -------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `key`                      | `Pubkey`                          | The fee state's own key. A PDA derived from just `b"feestate"`                                                                                                           |
| `global_fee_admin`         | `Pubkey`                          | Can modify fees                                                                                                                                                          |
| `global_fee_wallet`        | `Pubkey`                          | The base wallet for all protocol fees. All SOL fees go to this wallet. All non-SOL fees go to the cannonical ATA of this wallet for that asset.                          |
| `placeholder0`             | `u64`                             |                                                                                                                                                                          |
| `bank_init_flat_sol_fee`   | `u32`                             | Flat fee assessed when a new bank is initialized, in lamports. \* In SOL, in native decimals.                                                                            |
| `bump_seed`                | `u8`                              |                                                                                                                                                                          |
| `padding0`                 | `[u8; 3]`                         |                                                                                                                                                                          |
| `liquidation_max_fee`      | [`WrappedI80F48`](#wrappedi80f48) | Liquidators can claim at this premium, when liquidating an asset in receivership liquidation, e.g. (1 + this) \* amount repaid >= asset seized \* A percentage           |
| `program_fee_fixed`        | [`WrappedI80F48`](#wrappedi80f48) | Fee collected by the program owner from all groups \* A percentage                                                                                                       |
| `program_fee_rate`         | [`WrappedI80F48`](#wrappedi80f48) | Fee collected by the program owner from all groups \* A percentage                                                                                                       |
| `panic_state`              | [`PanicState`](#panicstate)       | When the global admin pauses the protocol in the event of an emergency, information about the pause duration will be stored here and propagated to groups.               |
| `placeholder1`             | `u64`                             |                                                                                                                                                                          |
| `liquidation_flat_sol_fee` | `u32`                             | Flat fee assessed for insurance/program use when a liquidation is executed \* In SOL, in native decimals.                                                                |
| `order_init_flat_sol_fee`  | `u32`                             | Flat fee assessed for preventing spam use when creating an order \* In SOL, in native decimals.                                                                          |
| `order_execution_max_fee`  | [`WrappedI80F48`](#wrappedi80f48) | Take-profit Orders can be executed at this premium, which Keepers are allowed to keep (no pun intended) e.g. (1 + this) \* amount repaid >= asset seized \* A percentage |
| `reserved1`                | `[u8; 32]`                        |                                                                                                                                                                          |

### `Lending`

Discriminator `87c75210f983b6f1` · `accounts::lending::Lending`.

| Field                          | Type     | Description                                                 |
| ------------------------------ | -------- | ----------------------------------------------------------- |
| `mint`                         | `Pubkey` |                                                             |
| `f_token_mint`                 | `Pubkey` |                                                             |
| `lending_id`                   | `u16`    |                                                             |
| `decimals`                     | `u8`     | number of decimals for the fToken, same as underlying mint  |
| `rewards_rate_model`           | `Pubkey` | PDA of rewards rate model (LRRM)                            |
| `liquidity_exchange_price`     | `u64`    | exchange price in the liquidity layer (no rewards)          |
| `token_exchange_price`         | `u64`    | exchange price between fToken and underlying (with rewards) |
| `last_update_timestamp`        | `u64`    | unix timestamp when exchange prices were updated last       |
| `token_reserves_liquidity`     | `Pubkey` |                                                             |
| `supply_position_on_liquidity` | `Pubkey` |                                                             |
| `bump`                         | `u8`     |                                                             |

### `LiquidationRecord`

Discriminator `5f74178459d2f5a2` · `accounts::liquidation_record::LiquidationRecord`.

| Field                  | Type                                         | Description                                                                                                                                                                            |
| ---------------------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `key`                  | `Pubkey`                                     | This account's own key. A PDA derived from `marginfi_account`                                                                                                                          |
| `marginfi_account`     | `Pubkey`                                     | Account this record tracks                                                                                                                                                             |
| `record_payer`         | `Pubkey`                                     | The key that paid to create this account. At some point, we may allow this wallet to reclaim the rent paid to open a record.                                                           |
| `liquidation_receiver` | `Pubkey`                                     | The liquidator taking receivership of the `marginfi_account` to complete a liquidation. Pays the liquidation fee. \* Always pubkey default unless actively within a liquidation event. |
| `entries`              | [`[LiquidationEntry; 4]`](#liquidationentry) | Basic historical data for the last few liquidation events on this account                                                                                                              |
| `cache`                | [`LiquidationCache`](#liquidationcache)      |                                                                                                                                                                                        |
| `reserved0`            | `[u8; 64]`                                   |                                                                                                                                                                                        |
| `reserved2`            | `[u8; 16]`                                   |                                                                                                                                                                                        |
| `reserved3`            | `[u8; 8]`                                    |                                                                                                                                                                                        |

### `MarginfiAccount`

Discriminator `43b2826d7e721c2a` · `accounts::marginfi_account::MarginfiAccount`.

| Field                           | Type                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ------------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `group`                         | `Pubkey`                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `authority`                     | `Pubkey`                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `lending_account`               | [`LendingAccount`](#lendingaccount) |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `account_flags`                 | `u64`                               | The flags that indicate the state of the account. This is u64 bitfield, where each bit represents a flag. Flags:MarginfiAccount - 1: `ACCOUNT_DISABLED` - Indicates that the account is disabled and no further actions can be taken on it. - 2: `ACCOUNT_IN_FLASHLOAN` - Only set when an account is within a flash loan, e.g. when start_flashloan is called, then unset when the flashloan ends. - 4: `ACCOUNT_FLAG_DEPRECATED` - Deprecated, available for future use - 8: `ACCOUNT_TRANSFER_AUTHORITY_DEPRECATED` - the admin has flagged with account to be moved, original owner can now call `set_account_transfer_authority` - 16: `ACCOUNT_IN_RECEIVERSHIP` - the account is eligible to be liquidated and has entered receivership, a liquidator is able to control borrows and withdraws until the end of the tx. This flag will only appear within a tx. - 32: `ACCOUNT_IN_DELEVERAGE - the account is being deleveraged by the risk admin - 64: `ACCOUNT_FROZEN\` - the admin has frozen the account; only the group admin may perform actions until unfrozen. |
| `emissions_destination_account` | `Pubkey`                            | Wallet whose canonical ATA receives off-chain emissions distributions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `health_cache`                  | [`HealthCache`](#healthcache)       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `migrated_from`                 | `Pubkey`                            | If this account was migrated from another one, store the original account key                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `migrated_to`                   | `Pubkey`                            | If this account has been migrated to another one, store the destination account key                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `last_update`                   | `u64`                               | Unix timestamp (u64) of the last account interaction. Note: Bank.last_update uses i64.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `account_index`                 | `u16`                               | If a PDA-based account, the account index, a seed used to derive the PDA that can be chosen arbitrarily (0.1.5 or later). Otherwise, does nothing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `third_party_index`             | `u16`                               | If a PDA-based account (0.1.5 or later), a "vendor specific" id. Values < PDA_FREE_THRESHOLD can be used by anyone with no restrictions. Values >= PDA_FREE_THRESHOLD can only be used by a particular program via CPI. These values require being added to a list, contact us for more details. For legacy non-pda accounts, does nothing. Note: use a unique seed to tag accounts related to some particular program or campaign so you can easily fetch them all later.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `bump`                          | `u8`                                | This account's bump, if a PDA-based account (0.1.5 or later). Otherwise, does nothing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `pad0`                          | `[u8; 3]`                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `liquidation_record`            | `Pubkey`                            | Stores information related to liquidations made against this account. A pda of this account's key, and "liq_record" \* Typically pubkey default if this account has never been liquidated or close to liquidation \* Opening this account is permissionless. Typically the liquidator pays, but e.g. we may also charge the user if they are opening a risky position on the front end.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `padding0`                      | `[u64; 7]`                          |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

### `MarginfiGroup`

Discriminator `b617adf097ceb643` · `accounts::marginfi_group::MarginfiGroup`.

| Field                                        | Type                                          | Description                                                                                                                                                                                                                                                                                                                                |
| -------------------------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `admin`                                      | `Pubkey`                                      | Broadly able to modify anything, and can set/remove other admins at will.                                                                                                                                                                                                                                                                  |
| `group_flags`                                | `u64`                                         | Bitmask for group settings flags. \* Bit 0 (1): `PROGRAM_FEES_ENABLED` — If set, program-level fees are enabled. \* Bits 1-63: Reserved for future use.                                                                                                                                                                                    |
| `fee_state_cache`                            | [`FeeStateCache`](#feestatecache)             | Caches information from the global `FeeState` so the FeeState can be omitted on certain ixes                                                                                                                                                                                                                                               |
| `banks`                                      | `u16`                                         | For groups initialized in versions 0.1.2 or greater, this is an authoritative count of the number of banks under this group. For groups initialized prior to 0.1.2, a non-authoritative count of the number of banks initiated after 0.1.2 went live.                                                                                      |
| `pad0`                                       | `[u8; 6]`                                     |                                                                                                                                                                                                                                                                                                                                            |
| `emode_admin`                                | `Pubkey`                                      | This admin can configure collateral ratios above (but not below) the collateral ratio of certain banks, e.g. allow SOL to count as 90% collateral when borrowing an LST instead of the default rate.                                                                                                                                       |
| `delegate_curve_admin`                       | `Pubkey`                                      | Can modify the fields in `config.interest_rate_config` but nothing else, for every bank under this group                                                                                                                                                                                                                                   |
| `delegate_limit_admin`                       | `Pubkey`                                      | Can modify the `deposit_limit`, `borrow_limit`, `total_asset_value_init_limit` but nothing else, for every bank under this group                                                                                                                                                                                                           |
| `delegate_emissions_admin`                   | `Pubkey`                                      | Can modify the emissions `flags`, `emissions_rate` and `emissions_mint`, but nothing else, for every bank under this group                                                                                                                                                                                                                 |
| `panic_state_cache`                          | [`PanicStateCache`](#panicstatecache)         | When program keeper temporarily puts the program into panic mode, information about the duration of the lockup will be available here.                                                                                                                                                                                                     |
| `deleverage_withdraw_window_cache`           | [`WithdrawWindowCache`](#withdrawwindowcache) | Keeps track of the liquidity withdrawn from the group over the day as a result of deleverages. Used as a protection mechanism against too big (and unwanted) withdrawals (e.g. when the risk admin is compromised).                                                                                                                        |
| `risk_admin`                                 | `Pubkey`                                      | Can run bankruptcy and forced deleverage ixes to e.g. sunset risky/illiquid assets                                                                                                                                                                                                                                                         |
| `metadata_admin`                             | `Pubkey`                                      | Can modify a Bank's metadata, and nothing else.                                                                                                                                                                                                                                                                                            |
| `emode_max_init_leverage`                    | `u32`                                         | Maximum leverage allowed for emode positions (initial margin), stored as u32 basis. Use `u32_to_basis` to convert to I80F48. Range: 1-100.                                                                                                                                                                                                 |
| `emode_max_maint_leverage`                   | `u32`                                         | Maximum leverage allowed for emode positions (maintenance margin), stored as u32 basis. Must be > emode_max_init_leverage. Range: 1-100.                                                                                                                                                                                                   |
| `padding`                                    | `[u8; 8]`                                     | Reserved for future use                                                                                                                                                                                                                                                                                                                    |
| `rate_limiter`                               | [`GroupRateLimiter`](#groupratelimiter)       | Rate limiter for controlling aggregate withdraw/borrow outflow across all banks. Tracks net outflow in USD.                                                                                                                                                                                                                                |
| `rate_limiter_last_admin_update_slot`        | `u64`                                         | Last slot covered by an admin group rate limiter aggregation update.                                                                                                                                                                                                                                                                       |
| `rate_limiter_last_admin_update_seq`         | `u64`                                         | Monotonic sequence number for admin group rate limiter updates. This is used to enforce strict ordering and prevent duplicate/replayed batches when slot ranges overlap or multiple updates happen in the same slot.                                                                                                                       |
| `deleverage_withdraw_last_admin_update_slot` | `u64`                                         | Last slot covered by an admin deleverage withdraw-limit aggregation update.                                                                                                                                                                                                                                                                |
| `deleverage_withdraw_last_admin_update_seq`  | `u64`                                         | Monotonic sequence number for admin deleverage withdraw-limit updates.                                                                                                                                                                                                                                                                     |
| `delegate_flow_admin`                        | `Pubkey`                                      | Can modify flow-control status for the group, i.e. update the withdraw caches with flow information from banks. Typically this is a hot wallet that lives in e.g. some cron job. If compromised, flow control can be effectively disabled until the admin is restored, which does not itself compromise any funds, and is merely annoying. |
| `padding0`                                   | `[[u64; 2]; 2]`                               |                                                                                                                                                                                                                                                                                                                                            |
| `padding1`                                   | `[[u64; 2]; 32]`                              |                                                                                                                                                                                                                                                                                                                                            |

### `MinimalObligation`

Discriminator `a8ce8d6a584caca7` · `accounts::minimal_obligation::MinimalObligation`.

| Field                                    | Type                                                               | Description                                                                                                                                                                                                                                                                                                                                                        |
| ---------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `tag`                                    | `u64`                                                              |                                                                                                                                                                                                                                                                                                                                                                    |
| `last_update_slot`                       | `u64`                                                              | Kamino obligations are only good for one slot, e.g. `refresh_obligation` must have run within the same slot as any ix that needs a non-stale obligation e.g. withdraw.                                                                                                                                                                                             |
| `last_update_stale`                      | `u8`                                                               | True if the obligation is stale, which will cause various ixes like withdraw to fail. Typically set to true in any tx that modifies obligation balance, and set to false at the end of a successful `refresh_obligation` \* 0 = false, 1 = true                                                                                                                    |
| `last_update_price_status`               | `u8`                                                               | Each bit represents a passed check in price status. \* 63 = all checks passed Otherwise: \* PRICE_LOADED =        0b_0000_0001; // 1 \* PRICE_AGE_CHECKED =   0b_0000_0010; // 2 \* TWAP_CHECKED =        0b_0000_0100; // 4 \* TWAP_AGE_CHECKED =    0b_0000_1000; // 8 \* HEURISTIC_CHECKED =   0b_0001_0000; // 16 \* PRICE_USAGE_ALLOWED = 0b_0010_0000; // 32 |
| `last_update_placeholder`                | `[u8; 6]`                                                          |                                                                                                                                                                                                                                                                                                                                                                    |
| `lending_market`                         | `Pubkey`                                                           |                                                                                                                                                                                                                                                                                                                                                                    |
| `owner`                                  | `Pubkey`                                                           | For mrgn banks, the bank's Liquidity Vault Authority (a pda which can be derived if the bank key is known)                                                                                                                                                                                                                                                         |
| `deposits`                               | [`[MinimalObligationCollateral; 8]`](#minimalobligationcollateral) |                                                                                                                                                                                                                                                                                                                                                                    |
| `lowest_reserve_deposit_liquidation_ltv` | `u64`                                                              |                                                                                                                                                                                                                                                                                                                                                                    |
| `deposited_value_sf`                     | `[u8; 16]`                                                         |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part1`                          | `[u8; 512]`                                                        |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part2`                          | `[u8; 512]`                                                        |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part3`                          | `[u8; 512]`                                                        |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part4`                          | `[u8; 512]`                                                        |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part5a`                         | `[u8; 64]`                                                         |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part5c`                         | `[u8; 24]`                                                         |                                                                                                                                                                                                                                                                                                                                                                    |

### `MinimalReserve`

Discriminator `2bf2ccca1af73b7f` · `accounts::minimal_reserve::MinimalReserve`.

| Field                             | Type         | Description                                                                                                                                                                                                                                                                                                                                                        |
| --------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `version`                         | `u64`        |                                                                                                                                                                                                                                                                                                                                                                    |
| `slot`                            | `u64`        | Kamino reserves are only good for one slot, e.g. `refresh_reserve` must have run within the same slot as any ix that needs a non-stale reserve e.g. withdraw.                                                                                                                                                                                                      |
| `stale`                           | `u8`         | True if the reserve is stale, which will cause various ixes like withdraw to fail. Typically set to true in any tx that modifies reserve balance, and set to false at the end of a successful `refresh_reserve` \* 0 = false, 1 = true                                                                                                                             |
| `price_status`                    | `u8`         | Each bit represents a passed check in price status. \* 63 = all checks passed Otherwise: \* PRICE_LOADED =        0b_0000_0001; // 1 \* PRICE_AGE_CHECKED =   0b_0000_0010; // 2 \* TWAP_CHECKED =        0b_0000_0100; // 4 \* TWAP_AGE_CHECKED =    0b_0000_1000; // 8 \* HEURISTIC_CHECKED =   0b_0001_0000; // 16 \* PRICE_USAGE_ALLOWED = 0b_0010_0000; // 32 |
| `placeholder`                     | `[u8; 6]`    |                                                                                                                                                                                                                                                                                                                                                                    |
| `lending_market`                  | `Pubkey`     |                                                                                                                                                                                                                                                                                                                                                                    |
| `farm_collateral`                 | `Pubkey`     |                                                                                                                                                                                                                                                                                                                                                                    |
| `farm_debt`                       | `Pubkey`     |                                                                                                                                                                                                                                                                                                                                                                    |
| `mint_pubkey`                     | `Pubkey`     |                                                                                                                                                                                                                                                                                                                                                                    |
| `supply_vault`                    | `Pubkey`     | \* A PDA                                                                                                                                                                                                                                                                                                                                                           |
| `fee_vault`                       | `Pubkey`     | \* A PDA                                                                                                                                                                                                                                                                                                                                                           |
| `available_amount`                | `u64`        | In simple terms: (amount in supply vault - outstanding borrows) \* In token, with `mint_decimals`                                                                                                                                                                                                                                                                  |
| `borrowed_amount_sf`              | `[u8; 16]`   | \* In token, with `mint_decimals` \* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino.                                                                                                                                                                                                                                                                     |
| `market_price_sf`                 | `[u8; 16]`   | \* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino.                                                                                                                                                                                                                                                                                                       |
| `market_price_last_updated_ts`    | `u64`        |                                                                                                                                                                                                                                                                                                                                                                    |
| `mint_decimals`                   | `u64`        |                                                                                                                                                                                                                                                                                                                                                                    |
| `deposit_limit_crossed_timestamp` | `u64`        |                                                                                                                                                                                                                                                                                                                                                                    |
| `borrow_limit_crossed_timestamp`  | `u64`        |                                                                                                                                                                                                                                                                                                                                                                    |
| `cumulative_borrow_rate_bsf`      | `[u8; 48]`   |                                                                                                                                                                                                                                                                                                                                                                    |
| `accumulated_protocol_fees_sf`    | `[u8; 16]`   | \* In token, with `mint_decimals` \* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino.                                                                                                                                                                                                                                                                     |
| `accumulated_referrer_fees_sf`    | `[u8; 16]`   | \* In token, with `mint_decimals` \* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino.                                                                                                                                                                                                                                                                     |
| `pending_referrer_fees_sf`        | `[u8; 16]`   | \* In token, with `mint_decimals` \* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino.                                                                                                                                                                                                                                                                     |
| `absolute_referral_rate_sf`       | `[u8; 16]`   | \* In token, with `mint_decimals` \* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino.                                                                                                                                                                                                                                                                     |
| `token_program`                   | `Pubkey`     | Token or Token22. If token22, note that Kamino does not support all Token22 extensions.                                                                                                                                                                                                                                                                            |
| `padding2_part1`                  | `[u8; 256]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding2_part2`                  | `[u8; 128]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding2_part3`                  | `[u8; 24]`   |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding3`                        | `[u8; 512]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part1`                   | `[u8; 512]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part2`                   | `[u8; 512]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part3`                   | `[u8; 128]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding_part4`                   | `[u8; 48]`   |                                                                                                                                                                                                                                                                                                                                                                    |
| `collateral_mint_pubkey`          | `Pubkey`     | Mints collateral tokens \* A PDA \* technically 6 decimals, but uses `mint_decimals` regardless for all purposes \* authority = lending_market_authority                                                                                                                                                                                                           |
| `mint_total_supply`               | `u64`        | Total number of collateral tokens \* uses `mint_decimals`, even though it's technically 6 decimals under the hood                                                                                                                                                                                                                                                  |
| `collateral_supply_vault`         | `Pubkey`     | \* A PDA                                                                                                                                                                                                                                                                                                                                                           |
| `padding1_reserve_collateral`     | `[u8; 512]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding2_reserve_collateral`     | `[u8; 512]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding4_part1`                  | `[u8; 4096]` |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding4_part2`                  | `[u8; 512]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding4_part3`                  | `[u8; 256]`  |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding4_part4`                  | `[u8; 64]`   |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding4_part5`                  | `[u8; 32]`   |                                                                                                                                                                                                                                                                                                                                                                    |
| `padding4_part6`                  | `[u8; 8]`    |                                                                                                                                                                                                                                                                                                                                                                    |

### `MinimalSpotMarket`

Discriminator `64b1086ba8414127` · `accounts::minimal_spot_market::MinimalSpotMarket`.

| Field                         | Type            | Description                                                                                                                       |
| ----------------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `pubkey`                      | `Pubkey`        | The address of the spot market. It is a pda of the market index                                                                   |
| `oracle`                      | `Pubkey`        | The oracle used to price the markets deposits/borrows                                                                             |
| `mint`                        | `Pubkey`        | The token mint of the market                                                                                                      |
| `vault`                       | `Pubkey`        | The vault used to store the market's deposits                                                                                     |
| `padding1`                    | `[[u64; 4]; 9]` |                                                                                                                                   |
| `padding2`                    | `[u8; 8]`       |                                                                                                                                   |
| `deposit_balance`             | `[u8; 16]`      | All the fields we need for testing (stored as raw bytes for simplicity)                                                           |
| `borrow_balance`              | `[u8; 16]`      |                                                                                                                                   |
| `cumulative_deposit_interest` | `[u8; 16]`      |                                                                                                                                   |
| `cumulative_borrow_interest`  | `[u8; 16]`      |                                                                                                                                   |
| `padding3`                    | `[u64; 9]`      |                                                                                                                                   |
| `last_interest_ts`            | `u64`           | Last time the cumulative deposit and borrow interest was updated Offset: 568 bytes from start of struct (including discriminator) |
| `padding4`                    | `[u64; 13]`     |                                                                                                                                   |
| `decimals`                    | `u32`           |                                                                                                                                   |
| `market_index`                | `u16`           |                                                                                                                                   |
| `padding5`                    | `[u16; 24]`     |                                                                                                                                   |
| `padding6`                    | `[u8; 1]`       |                                                                                                                                   |
| `pool_id`                     | `u8`            |                                                                                                                                   |
| `padding7`                    | `[u64; 5]`      | Padding to reach 776 bytes total (including discriminator)                                                                        |

### `MinimalUser`

Discriminator `9f755fe3ef973aec` · `accounts::minimal_user::MinimalUser`.

| Field            | Type                                 | Description                                                         |
| ---------------- | ------------------------------------ | ------------------------------------------------------------------- |
| `authority`      | `Pubkey`                             | The owner/authority of the account                                  |
| `delegate`       | `Pubkey`                             | An addresses that can control the account on the authority's behalf |
| `name`           | `[u8; 32]`                           | Encoded display name for the account                                |
| `spot_positions` | [`[SpotPosition; 8]`](#spotposition) | The user's spot positions (8 positions)                             |
| `padding1`       | `[u64; 256]`                         | Skip to the fields we need at the end                               |
| `padding2`       | `[u64; 128]`                         |                                                                     |
| `padding3`       | `[u64; 64]`                          |                                                                     |
| `padding4`       | `[u64; 32]`                          |                                                                     |
| `padding5`       | `[u64; 8]`                           |                                                                     |
| `padding6`       | `[u64; 2]`                           |                                                                     |
| `padding7`       | `[u16; 1]`                           |                                                                     |
| `sub_account_id` | `u16`                                | Sub account id for this user account                                |
| `status`         | [`UserStatus`](#userstatus)          |                                                                     |
| `padding8`       | `[u8; 27]`                           |                                                                     |

### `Order`

Discriminator `86addfb94d561c33` · `accounts::order::Order`.

| Field              | Type                                    | Description                                                                                                                                                                                            |
| ------------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `marginfi_account` | `Pubkey`                                |                                                                                                                                                                                                        |
| `stop_loss`        | [`WrappedI80F48`](#wrappedi80f48)       |                                                                                                                                                                                                        |
| `take_profit`      | [`WrappedI80F48`](#wrappedi80f48)       |                                                                                                                                                                                                        |
| `placeholder`      | `u64`                                   | Reserved for future use                                                                                                                                                                                |
| `max_slippage`     | `u32`                                   | \* a %, as u32, out of 100%, e.g. 50% = .5 \* u32::MAX                                                                                                                                                 |
| `pad0`             | `[u8; 4]`                               |                                                                                                                                                                                                        |
| `tags`             | `[u16; 2]`                              | Active tags (currently 2). Remaining capacity is stored in padding for layout compatibility. Padding byte `ORDER_TAG_PADDING - 1` stores the tag count for forward compatibility. (u16 \* 2 = 4 bytes) |
| `pad1`             | `[u8; 4]`                               |                                                                                                                                                                                                        |
| `tags_padding`     | `[u8; 32]`                              |                                                                                                                                                                                                        |
| `trigger`          | [`OrderTriggerType`](#ordertriggertype) | Stop Loss (0), Take Profit (1), or Both (2)                                                                                                                                                            |
| `bump`             | `u8`                                    | Bump to derive this pda                                                                                                                                                                                |
| `pad2`             | `[u8; 6]`                               |                                                                                                                                                                                                        |
| `reserved1`        | `[[u8; 32]; 4]`                         |                                                                                                                                                                                                        |

### `SolendMinimalReserve`

Discriminator `01` · `accounts::solend_minimal_reserve::SolendMinimalReserve`.

| Field                                      | Type        | Description                             |
| ------------------------------------------ | ----------- | --------------------------------------- |
| `last_update_slot`                         | `u64`       | Last slot when supply and rates updated |
| `last_update_stale`                        | `u8`        | True when marked stale                  |
| `lending_market`                           | `Pubkey`    | Lending market address                  |
| `liquidity_mint_pubkey`                    | `Pubkey`    |                                         |
| `liquidity_mint_decimals`                  | `u8`        |                                         |
| `liquidity_supply_pubkey`                  | `Pubkey`    |                                         |
| `liquidity_pyth_oracle_pubkey`             | `Pubkey`    |                                         |
| `liquidity_switchboard_oracle_pubkey`      | `Pubkey`    |                                         |
| `liquidity_available_amount`               | `u64`       |                                         |
| `liquidity_borrowed_amount_wads`           | `[u8; 16]`  |                                         |
| `liquidity_cumulative_borrow_rate_wads`    | `[u8; 16]`  |                                         |
| `liquidity_market_price`                   | `[u8; 16]`  |                                         |
| `collateral_mint_pubkey`                   | `Pubkey`    |                                         |
| `collateral_mint_total_supply`             | `u64`       |                                         |
| `collateral_supply_pubkey`                 | `Pubkey`    |                                         |
| `config_optimal_utilization_rate`          | `u8`        |                                         |
| `config_loan_to_value_ratio`               | `u8`        |                                         |
| `config_liquidation_bonus`                 | `u8`        |                                         |
| `config_liquidation_threshold`             | `u8`        |                                         |
| `padding_to_fees64`                        | `[u8; 64]`  |                                         |
| `padding_to_fees6`                         | `[u8; 6]`   |                                         |
| `liquidity_accumulated_protocol_fees_wads` | `[u8; 16]`  |                                         |
| `padding_final128`                         | `[u8; 128]` |                                         |
| `padding_final64`                          | `[u8; 64]`  |                                         |
| `padding_final32`                          | `[u8; 32]`  |                                         |
| `padding_final6`                           | `[u8; 6]`   |                                         |

### `StakedSettings`

Discriminator `9d8c064d59adad7d` · `accounts::staked_settings::StakedSettings`.

| Field                          | Type                              | Description                                                                                       |
| ------------------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------- |
| `key`                          | `Pubkey`                          | This account's own key. A PDA derived from `marginfi_group` and `STAKED_SETTINGS_SEED`            |
| `marginfi_group`               | `Pubkey`                          | Group for which these settings apply                                                              |
| `oracle`                       | `Pubkey`                          | Generally, the Pyth push oracle for SOL                                                           |
| `asset_weight_init`            | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                   |
| `asset_weight_maint`           | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                   |
| `deposit_limit`                | `u64`                             |                                                                                                   |
| `total_asset_value_init_limit` | `u64`                             |                                                                                                   |
| `oracle_max_age`               | `u16`                             |                                                                                                   |
| `risk_tier`                    | [`RiskTier`](#risktier)           |                                                                                                   |
| `pad0`                         | `[u8; 5]`                         |                                                                                                   |
| `reserved0`                    | `[u8; 8]`                         | The following values are irrelevant because staked collateral positions do not support borrowing. |
| `reserved1`                    | `[u8; 32]`                        |                                                                                                   |
| `reserved2`                    | `[u8; 64]`                        |                                                                                                   |

## Events

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

### `DeleverageEvent`

Discriminator `a1086cccd1c60c1e` · `events::deleverage_event::DeleverageEventEvent`.

| Field                          | Type     |
| ------------------------------ | -------- |
| `marginfi_account`             | `Pubkey` |
| `risk_admin`                   | `Pubkey` |
| `deleveragee_assets_seized`    | `f64`    |
| `deleveragee_liability_repaid` | `f64`    |

### `DeleverageWithdrawFlowEvent`

Discriminator `6d5a8bc80acc54b0` · `events::deleverage_withdraw_flow_event::DeleverageWithdrawFlowEventEvent`.

| Field               | Type     | Description                                                  |
| ------------------- | -------- | ------------------------------------------------------------ |
| `group`             | `Pubkey` |                                                              |
| `bank`              | `Pubkey` |                                                              |
| `mint`              | `Pubkey` |                                                              |
| `outflow_usd`       | `u32`    | Equity-denominated outflow value in USD, rounded to integer. |
| `current_timestamp` | `i64`    | Unix timestamp when the flow was recorded                    |

### `EditStakedSettingsEvent`

Discriminator `1d3a9bbf4bdc91ce` · `events::edit_staked_settings_event::EditStakedSettingsEventEvent`.

| Field      | Type                                                    |
| ---------- | ------------------------------------------------------- |
| `group`    | `Pubkey`                                                |
| `settings` | [`StakedSettingsEditConfig`](#stakedsettingseditconfig) |

### `HealthPulseEvent`

Discriminator `b79fda6e3ddc4101` · `events::health_pulse_event::HealthPulseEventEvent`.

| Field          | Type                          |
| -------------- | ----------------------------- |
| `account`      | `Pubkey`                      |
| `health_cache` | [`HealthCache`](#healthcache) |

### `KeeperCloseOrderEvent`

Discriminator `2e980bae5c9d4d40` · `events::keeper_close_order_event::KeeperCloseOrderEventEvent`.

| Field    | Type                                        |
| -------- | ------------------------------------------- |
| `header` | [`AccountEventHeader`](#accounteventheader) |
| `order`  | `Pubkey`                                    |

### `LendingAccountBorrowEvent`

Discriminator `df60510a9c631a3b` · `events::lending_account_borrow_event::LendingAccountBorrowEventEvent`.

| Field    | Type                                        |
| -------- | ------------------------------------------- |
| `header` | [`AccountEventHeader`](#accounteventheader) |
| `bank`   | `Pubkey`                                    |
| `mint`   | `Pubkey`                                    |
| `amount` | `u64`                                       |

### `LendingAccountDepositEvent`

Discriminator `a136edd969f87a97` · `events::lending_account_deposit_event::LendingAccountDepositEventEvent`.

| Field    | Type                                        |
| -------- | ------------------------------------------- |
| `header` | [`AccountEventHeader`](#accounteventheader) |
| `bank`   | `Pubkey`                                    |
| `mint`   | `Pubkey`                                    |
| `amount` | `u64`                                       |

### `LendingAccountLiquidateEvent`

Discriminator `a6a0f99ab72717f2` · `events::lending_account_liquidate_event::LendingAccountLiquidateEventEvent`.

| Field                                   | Type                                          |
| --------------------------------------- | --------------------------------------------- |
| `header`                                | [`AccountEventHeader`](#accounteventheader)   |
| `liquidatee_marginfi_account`           | `Pubkey`                                      |
| `liquidatee_marginfi_account_authority` | `Pubkey`                                      |
| `asset_bank`                            | `Pubkey`                                      |
| `asset_mint`                            | `Pubkey`                                      |
| `liability_bank`                        | `Pubkey`                                      |
| `liability_mint`                        | `Pubkey`                                      |
| `liquidatee_pre_health`                 | `f64`                                         |
| `liquidatee_post_health`                | `f64`                                         |
| `pre_balances`                          | [`LiquidationBalances`](#liquidationbalances) |
| `post_balances`                         | [`LiquidationBalances`](#liquidationbalances) |

### `LendingAccountRepayEvent`

Discriminator `10dc376f07501019` · `events::lending_account_repay_event::LendingAccountRepayEventEvent`.

| Field           | Type                                        |
| --------------- | ------------------------------------------- |
| `header`        | [`AccountEventHeader`](#accounteventheader) |
| `bank`          | `Pubkey`                                    |
| `mint`          | `Pubkey`                                    |
| `amount`        | `u64`                                       |
| `close_balance` | `bool`                                      |

### `LendingAccountWithdrawEvent`

Discriminator `03dc94f321f93658` · `events::lending_account_withdraw_event::LendingAccountWithdrawEventEvent`.

| Field           | Type                                        |
| --------------- | ------------------------------------------- |
| `header`        | [`AccountEventHeader`](#accounteventheader) |
| `bank`          | `Pubkey`                                    |
| `mint`          | `Pubkey`                                    |
| `amount`        | `u64`                                       |
| `close_balance` | `bool`                                      |

### `LendingPoolBankAccrueInterestEvent`

Discriminator `6875bb9c6f9a6aba` · `events::lending_pool_bank_accrue_interest_event::LendingPoolBankAccrueInterestEventEvent`.

| Field                 | Type                                    |
| --------------------- | --------------------------------------- |
| `header`              | [`GroupEventHeader`](#groupeventheader) |
| `bank`                | `Pubkey`                                |
| `mint`                | `Pubkey`                                |
| `delta`               | `u64`                                   |
| `fees_collected`      | `f64`                                   |
| `insurance_collected` | `f64`                                   |

### `LendingPoolBankCollectFeesEvent`

Discriminator `657761faa9af9cfd` · `events::lending_pool_bank_collect_fees_event::LendingPoolBankCollectFeesEventEvent`.

| Field                        | Type                                    |
| ---------------------------- | --------------------------------------- |
| `header`                     | [`GroupEventHeader`](#groupeventheader) |
| `bank`                       | `Pubkey`                                |
| `mint`                       | `Pubkey`                                |
| `group_fees_collected`       | `f64`                                   |
| `group_fees_outstanding`     | `f64`                                   |
| `insurance_fees_collected`   | `f64`                                   |
| `insurance_fees_outstanding` | `f64`                                   |

### `LendingPoolBankConfigureEvent`

Discriminator `f623e96e5d98eb28` · `events::lending_pool_bank_configure_event::LendingPoolBankConfigureEventEvent`.

| Field    | Type                                    |
| -------- | --------------------------------------- |
| `header` | [`GroupEventHeader`](#groupeventheader) |
| `bank`   | `Pubkey`                                |
| `mint`   | `Pubkey`                                |
| `config` | [`BankConfigOpt`](#bankconfigopt)       |

### `LendingPoolBankConfigureFrozenEvent`

Discriminator `180a371231969db3` · `events::lending_pool_bank_configure_frozen_event::LendingPoolBankConfigureFrozenEventEvent`.

| Field           | Type                                    |
| --------------- | --------------------------------------- |
| `header`        | [`GroupEventHeader`](#groupeventheader) |
| `bank`          | `Pubkey`                                |
| `mint`          | `Pubkey`                                |
| `deposit_limit` | `u64`                                   |
| `borrow_limit`  | `u64`                                   |

### `LendingPoolBankConfigureOracleEvent`

Discriminator `778c6efd9640d23e` · `events::lending_pool_bank_configure_oracle_event::LendingPoolBankConfigureOracleEventEvent`.

| Field          | Type                                    |
| -------------- | --------------------------------------- |
| `header`       | [`GroupEventHeader`](#groupeventheader) |
| `bank`         | `Pubkey`                                |
| `oracle_setup` | `u8`                                    |
| `oracle`       | `Pubkey`                                |

### `LendingPoolBankCreateEvent`

Discriminator `ecdcc93fef7e88f9` · `events::lending_pool_bank_create_event::LendingPoolBankCreateEventEvent`.

| Field    | Type                                    |
| -------- | --------------------------------------- |
| `header` | [`GroupEventHeader`](#groupeventheader) |
| `bank`   | `Pubkey`                                |
| `mint`   | `Pubkey`                                |

### `LendingPoolBankHandleBankruptcyEvent`

Discriminator `a64d298c245e0a39` · `events::lending_pool_bank_handle_bankruptcy_event::LendingPoolBankHandleBankruptcyEventEvent`.

| Field               | Type                                        |
| ------------------- | ------------------------------------------- |
| `header`            | [`AccountEventHeader`](#accounteventheader) |
| `bank`              | `Pubkey`                                    |
| `mint`              | `Pubkey`                                    |
| `bad_debt`          | `f64`                                       |
| `covered_amount`    | `f64`                                       |
| `socialized_amount` | `f64`                                       |

### `LendingPoolBankSetFixedOraclePriceEvent`

Discriminator `41480855e5145a1a` · `events::lending_pool_bank_set_fixed_oracle_price_event::LendingPoolBankSetFixedOraclePriceEventEvent`.

| Field    | Type                                    |
| -------- | --------------------------------------- |
| `header` | [`GroupEventHeader`](#groupeventheader) |
| `bank`   | `Pubkey`                                |
| `price`  | [`WrappedI80F48`](#wrappedi80f48)       |

### `LendingPoolSuperAdminDepositEvent`

Discriminator `6398d31e3aa5d247` · `events::lending_pool_super_admin_deposit_event::LendingPoolSuperAdminDepositEventEvent`.

| Field                 | Type                                    | Description                                                                              |
| --------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------- |
| `header`              | [`GroupEventHeader`](#groupeventheader) |                                                                                          |
| `bank`                | `Pubkey`                                |                                                                                          |
| `mint`                | `Pubkey`                                |                                                                                          |
| `transfer_amount`     | `u64`                                   | Amount requested in SPL transfer instruction.                                            |
| `vault_inflow_amount` | `u64`                                   | Assumed vault inflow. Token-2022 transfer fees are not handled by this instruction path. |

### `LendingPoolSuperAdminWithdrawEvent`

Discriminator `6ba8e8b590a1fc25` · `events::lending_pool_super_admin_withdraw_event::LendingPoolSuperAdminWithdrawEventEvent`.

| Field                  | Type                                    |
| ---------------------- | --------------------------------------- |
| `header`               | [`GroupEventHeader`](#groupeventheader) |
| `bank`                 | `Pubkey`                                |
| `mint`                 | `Pubkey`                                |
| `vault_outflow_amount` | `u64`                                   |

### `LiquidationReceiverEvent`

Discriminator `2883e0dc975318e6` · `events::liquidation_receiver_event::LiquidationReceiverEventEvent`.

| Field                         | Type     |
| ----------------------------- | -------- |
| `marginfi_account`            | `Pubkey` |
| `liquidation_receiver`        | `Pubkey` |
| `liquidatee_assets_seized`    | `f64`    |
| `liquidatee_liability_repaid` | `f64`    |
| `lamps_fee_paid`              | `u32`    |

### `MarginfiAccountCloseOrderEvent`

Discriminator `9e227a621792e5d4` · `events::marginfi_account_close_order_event::MarginfiAccountCloseOrderEventEvent`.

| Field    | Type                                        |
| -------- | ------------------------------------------- |
| `header` | [`AccountEventHeader`](#accounteventheader) |
| `order`  | `Pubkey`                                    |

### `MarginfiAccountCreateEvent`

Discriminator `b70575687ac74433` · `events::marginfi_account_create_event::MarginfiAccountCreateEventEvent`.

| Field    | Type                                        |
| -------- | ------------------------------------------- |
| `header` | [`AccountEventHeader`](#accounteventheader) |

### `MarginfiAccountFreezeEvent`

Discriminator `dbdb39b24b56927a` · `events::marginfi_account_freeze_event::MarginfiAccountFreezeEventEvent`.

| Field    | Type                                        |
| -------- | ------------------------------------------- |
| `header` | [`AccountEventHeader`](#accounteventheader) |
| `frozen` | `bool`                                      |

### `MarginfiAccountPlaceOrderEvent`

Discriminator `01694f1c8ef26391` · `events::marginfi_account_place_order_event::MarginfiAccountPlaceOrderEventEvent`.

| Field         | Type                                        |
| ------------- | ------------------------------------------- |
| `header`      | [`AccountEventHeader`](#accounteventheader) |
| `order`       | `Pubkey`                                    |
| `trigger`     | [`OrderTriggerType`](#ordertriggertype)     |
| `stop_loss`   | [`WrappedI80F48`](#wrappedi80f48)           |
| `take_profit` | [`WrappedI80F48`](#wrappedi80f48)           |
| `tags`        | `[u16; 2]`                                  |

### `MarginfiAccountTransferToNewAccount`

Discriminator `3b69ab6edf885059` · `events::marginfi_account_transfer_to_new_account::MarginfiAccountTransferToNewAccountEvent`.

| Field                   | Type                                        |
| ----------------------- | ------------------------------------------- |
| `header`                | [`AccountEventHeader`](#accounteventheader) |
| `old_account`           | `Pubkey`                                    |
| `old_account_authority` | `Pubkey`                                    |
| `new_account_authority` | `Pubkey`                                    |

### `MarginfiGroupConfigureEvent`

Discriminator `f168aca729c3c7aa` · `events::marginfi_group_configure_event::MarginfiGroupConfigureEventEvent`.

| Field    | Type                                    |
| -------- | --------------------------------------- |
| `header` | [`GroupEventHeader`](#groupeventheader) |
| `admin`  | `Option<Pubkey>`                        |
| `flags`  | `u64`                                   |

### `MarginfiGroupCreateEvent`

Discriminator `e97d3d0e62f088fd` · `events::marginfi_group_create_event::MarginfiGroupCreateEventEvent`.

| Field    | Type                                    |
| -------- | --------------------------------------- |
| `header` | [`GroupEventHeader`](#groupeventheader) |

### `RateLimitFlowEvent`

Discriminator `e50549c8006b696d` · `events::rate_limit_flow_event::RateLimitFlowEventEvent`.

| Field               | Type     | Description                                               |
| ------------------- | -------- | --------------------------------------------------------- |
| `group`             | `Pubkey` |                                                           |
| `bank`              | `Pubkey` |                                                           |
| `mint`              | `Pubkey` |                                                           |
| `flow_direction`    | `u8`     | 0 = outflow (withdraw/borrow), 1 = inflow (deposit/repay) |
| `native_amount`     | `u64`    | Amount in native tokens                                   |
| `mint_decimals`     | `u8`     |                                                           |
| `current_timestamp` | `i64`    | Unix timestamp when the flow was recorded                 |

### `SetKeeperCloseFlagsEvent`

Discriminator `c1e65d8075576015` · `events::set_keeper_close_flags_event::SetKeeperCloseFlagsEventEvent`.

| Field       | Type                                        |
| ----------- | ------------------------------------------- |
| `header`    | [`AccountEventHeader`](#accounteventheader) |
| `bank_keys` | `Option<Vec<Pubkey>>`                       |

## Types

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

### `AccountEventHeader`

Struct `types::AccountEventHeader`.

| Field                        | Type             |
| ---------------------------- | ---------------- |
| `signer`                     | `Option<Pubkey>` |
| `marginfi_account`           | `Pubkey`         |
| `marginfi_account_authority` | `Pubkey`         |
| `marginfi_group`             | `Pubkey`         |

### `Balance`

Struct `types::Balance`.

| Field                   | Type                              | Description                                                                                                                                                                             |
| ----------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `active`                | `u8`                              | Whether this balance slot is in use (nonzero = active)                                                                                                                                  |
| `bank_pk`               | `Pubkey`                          | The bank this balance corresponds to                                                                                                                                                    |
| `bank_asset_tag`        | `u8`                              | Inherited from the bank when the position is first created and CANNOT BE CHANGED after that. Note that all balances created before the addition of this feature use `ASSET_TAG_DEFAULT` |
| `tag`                   | `u16`                             | Tag used by orders to reference this balance (0 means unused/unassigned). A tag may also have a non-zero value while having no orders.                                                  |
| `pad0`                  | `[u8; 4]`                         |                                                                                                                                                                                         |
| `asset_shares`          | [`WrappedI80F48`](#wrappedi80f48) | The user's asset (deposit) shares in the bank. Multiply by `bank.asset_share_value` for the token amount.                                                                               |
| `liability_shares`      | [`WrappedI80F48`](#wrappedi80f48) | The user's liability (borrow) shares in the bank. Multiply by `bank.liability_share_value` for the token amount.                                                                        |
| `emissions_outstanding` | [`WrappedI80F48`](#wrappedi80f48) | Unclaimed emissions rewards for this position                                                                                                                                           |
| `last_update`           | `u64`                             | Unix timestamp (u64) of the last emissions calculation for this position                                                                                                                |
| `padding`               | `[u64; 1]`                        | Reserved for future use                                                                                                                                                                 |

### `BankCache`

> _From the program's IDL:_
>
> A read-only cache of the bank's key metrics, e.g. spot interest/fee rates.

Struct `types::BankCache`.

| Field                               | Type                              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ----------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `base_rate`                         | `u32`                             | Actual (spot) interest/fee rates of the bank, based on utilization \* APR (annual percentage rate) values \* From 0-1000%, as u32, e.g. u32::MAX = 1000%, u32::MAX/2 = 500%, etc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `lending_rate`                      | `u32`                             | Equivalent to `base_rate` \* utilization \* From 0-1000%, as u32, e.g. u32::MAX = 1000%, u32::MAX/2 = 500%, etc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `borrowing_rate`                    | `u32`                             | Equivalent to `base_rate` \* (1 + ir_fees) + fixed_fees \* From 0-1000%, as u32, e.g. u32::MAX = 1000%, u32::MAX/2 = 500%, etc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `interest_accumulated_for`          | `u32`                             | \* in seconds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `accumulated_since_last_update`     | [`WrappedI80F48`](#wrappedi80f48) | equivalent to (share value increase in the last `interest_accumulated_for` seconds \* shares), i.e. the delta in `asset_share_value`, in token. \* Note: if the tx that triggered this cache update increased or decreased the net shares, this value still reports using the PRE-CHANGE share amount, since interest is always earned on that amount. \* in token, in native decimals, as I80F48                                                                                                                                                                                                                                                                                                                                           |
| `last_oracle_price`                 | [`WrappedI80F48`](#wrappedi80f48) | Oracle price used in the last instruction that consumed an oracle price \* Only updated when instruction uses an oracle price, not updated for operations that don't require prices (e.g., deposit, repay) \* Price in USD, with no price bias \* Zero if never updated                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `last_oracle_price_timestamp`       | `i64`                             | Unix timestamp (seconds) when last_oracle_price was last updated \* Used to determine staleness of cached price \* Zero if never updated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `last_oracle_price_confidence`      | [`WrappedI80F48`](#wrappedi80f48) | Confidence interval reported by the oracle when last_oracle_price was fetched \* Always non-negative \* Zero if never updated \* Note: this value is the confidence reported by oracles, multiplied by `STD_DEV_MULTIPLE`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `liq_cache_flags`                   | `u8`                              | Liquidation cache flags, set during receivership flow. \* 1 (LIQ_CACHE_LOCKED_FLAG) - We "lock" the liquidation cache when writing to it in Start Liquidate as an additional safeguard, if the liquidation prices stored here were to be edited between start and end, it would completely break the risk engine. End validates that the lock is set, panics if not, and removes it - which prevents footguns if the cache was e.g. accidently set to default. The lock is also removed when a Balance is closed via withdraw_all, repay_all, or close_balance, but only when the account has ACCOUNT_IN_RECEIVERSHIP set, so that operations on unrelated accounts sharing the same bank do not interfere with an in-progress liquidation. |
| `padding`                           | `[u8; 23]`                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `liquidation_price_rt`              | [`WrappedI80F48`](#wrappedi80f48) | Cached real-time price for receivership liquidation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `liquidation_price_rt_confidence`   | [`WrappedI80F48`](#wrappedi80f48) | Cached real-time price confidence for receivership liquidation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `liquidation_price_twap`            | [`WrappedI80F48`](#wrappedi80f48) | Cached TWAP price for receivership liquidation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `liquidation_price_twap_confidence` | [`WrappedI80F48`](#wrappedi80f48) | Cached TWAP price confidence for receivership liquidation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

### `BankConfig`

Struct `types::BankConfig`.

| Field                          | Type                                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------------------ | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `asset_weight_init`            | [`WrappedI80F48`](#wrappedi80f48)               | Discount factor for asset values in initial margin calculation (0 to 1). E.g., 0.8 means assets count as 80% of their value for borrowing purposes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `asset_weight_maint`           | [`WrappedI80F48`](#wrappedi80f48)               | Discount factor for asset values in maintenance margin calculation (0 to 2). Used for liquidation eligibility. Generally >= asset_weight_init.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `liability_weight_init`        | [`WrappedI80F48`](#wrappedi80f48)               | Premium factor for liability values in initial margin calculation (>= 1). E.g., 1.2 means liabilities count as 120% of their value for borrowing purposes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `liability_weight_maint`       | [`WrappedI80F48`](#wrappedi80f48)               | Premium factor for liability values in maintenance margin calculation (>= 1). Used for liquidation eligibility. Generally <= liability_weight_init.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `deposit_limit`                | `u64`                                           | Maximum total deposits allowed in this bank, in native token units (0 = no limit)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `interest_rate_config`         | [`InterestRateConfig`](#interestrateconfig)     | Interest rate model configuration                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `operational_state`            | [`BankOperationalState`](#bankoperationalstate) | Current operational state of the bank (Paused, Operational, ReduceOnly, KilledByBankruptcy)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `oracle_setup`                 | [`OracleSetup`](#oraclesetup)                   | Oracle type used for price feeds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `oracle_keys`                  | `[Pubkey; 5]`                                   | Oracle account keys (usage depends on oracle_setup type)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `pad0`                         | `[u8; 6]`                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `borrow_limit`                 | `u64`                                           | Maximum total borrows allowed in this bank, in native token units (0 = no limit)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `risk_tier`                    | [`RiskTier`](#risktier)                         | Risk tier for this bank (Collateral or Isolated)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `asset_tag`                    | `u8`                                            | Determines what kinds of assets users of this bank can interact with. Options: \* `ASSET_TAG_DEFAULT` (0) - A regular asset that can be comingled with any other regular asset or with `ASSET_TAG_SOL` \* `ASSET_TAG_SOL` (1) - Accounts with a SOL position can comingle with **either** `ASSET_TAG_DEFAULT` or `ASSET_TAG_STAKED` positions, but not both \* `ASSET_TAG_STAKED` (2) - Staked SOL assets. Accounts with a STAKED position can only deposit other STAKED assets or SOL (`ASSET_TAG_SOL`) and can only borrow SOL \* `ASSET_TAG_KAMINO` (3) - Treated the same as `ASSET_TAG_DEFAULT` \* `ASSET_TAG_DRIFT` (4) - Treated the same as `ASSET_TAG_DEFAULT` \* `ASSET_TAG_SOLEND` (5) - Treated the same as `ASSET_TAG_DEFAULT` |
| `config_flags`                 | `u8`                                            | Flags for various config options \* 1 - Always set if bank created in 0.1.4 or later, or if migrated to the new pyth oracle setup from a prior version. Not set in 0.1.3 or earlier banks using pyth that have not yet migrated. Does nothing for banks that use switchboard. \* 2, 4, 8, 16, etc - reserved for future use.                                                                                                                                                                                                                                                                                                                                                                                                                |
| `pad1`                         | `[u8; 5]`                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `total_asset_value_init_limit` | `u64`                                           | USD denominated limit for calculating asset value for initialization margin requirements. Example, if total SOL deposits are equal to $1M and the limit it set to $500K, then SOL assets will be discounted by 50%. In other words the max value of liabilities that can be backed by the asset is $500K. This is useful for limiting the damage of oracle attacks. Value is UI USD value, for example value 100 -> $100                                                                                                                                                                                                                                                                                                                    |
| `oracle_max_age`               | `u16`                                           | Time window in seconds for the oracle price feed to be considered live.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `padding0`                     | `[u8; 2]`                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `oracle_max_confidence`        | `u32`                                           | From 0-100%, if the confidence exceeds this value, the oracle is considered invalid. Note: the confidence adjustment is capped at 5% regardless of this value. \* 0 falls back to using the default 10% instead, i.e., U32_MAX_DIV_10 \* A %, as u32, e.g. 100% = u32::MAX, 50% = u32::MAX/2, etc.                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `fixed_price`                  | [`WrappedI80F48`](#wrappedi80f48)               | Stored oracle price for `OracleSetup::Fixed`, otherwise does nothing                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `padding1`                     | `[u8; 16]`                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

### `BankConfigCompact`

Struct `types::BankConfigCompact`.

| Field                          | Type                                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------------------ | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `asset_weight_init`            | [`WrappedI80F48`](#wrappedi80f48)                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `asset_weight_maint`           | [`WrappedI80F48`](#wrappedi80f48)                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `liability_weight_init`        | [`WrappedI80F48`](#wrappedi80f48)                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `liability_weight_maint`       | [`WrappedI80F48`](#wrappedi80f48)                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `deposit_limit`                | `u64`                                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `interest_rate_config`         | [`InterestRateConfigCompact`](#interestrateconfigcompact) |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `operational_state`            | [`BankOperationalState`](#bankoperationalstate)           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `borrow_limit`                 | `u64`                                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `risk_tier`                    | [`RiskTier`](#risktier)                                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `asset_tag`                    | `u8`                                                      | Determines what kinds of assets users of this bank can interact with. Options: \* `ASSET_TAG_DEFAULT` (0) - A regular asset that can be comingled with any other regular asset or with `ASSET_TAG_SOL` \* `ASSET_TAG_SOL` (1) - Accounts with a SOL position can comingle with **either** `ASSET_TAG_DEFAULT` or `ASSET_TAG_STAKED` positions, but not both \* `ASSET_TAG_STAKED` (2) - Staked SOL assets. Accounts with a STAKED position can only deposit other STAKED assets or SOL (`ASSET_TAG_SOL`) and can only borrow SOL \* `ASSET_TAG_KAMINO` (3) - Treated the same as `ASSET_TAG_DEFAULT` \* `ASSET_TAG_DRIFT` (4) - Treated the same as `ASSET_TAG_DEFAULT` \* `ASSET_TAG_SOLEND` (5) - Treated the same as `ASSET_TAG_DEFAULT` |
| `config_flags`                 | `u8`                                                      | Flags for various config options \* 1 - Always set if bank created in 0.1.4 or later, or if migrated to the new oracle setup from a prior version. Not set in 0.1.3 or earlier banks that have not yet migrated. \* 2, 4, 8, 16, etc - reserved for future use.                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `pad0`                         | `[u8; 5]`                                                 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `total_asset_value_init_limit` | `u64`                                                     | USD denominated limit for calculating asset value for initialization margin requirements. Example, if total SOL deposits are equal to $1M and the limit it set to $500K, then SOL assets will be discounted by 50%. In other words the max value of liabilities that can be backed by the asset is $500K. This is useful for limiting the damage of oracle attacks. Value is UI USD value, for example value 100 -> $100                                                                                                                                                                                                                                                                                                                    |
| `oracle_max_age`               | `u16`                                                     | Time window in seconds for the oracle price feed to be considered live.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `oracle_max_confidence`        | `u32`                                                     | From 0-100%, if the confidence exceeds this value, the oracle is considered invalid. Note: the confidence adjustment is capped at 5% regardless of this value. \* 0% = use the default (10%) \* A %, as u32, e.g. 100% = u32::MAX, 50% = u32::MAX/2, etc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

### `BankConfigOpt`

Struct `types::BankConfigOpt`.

| Field                                | Type                                                      |
| ------------------------------------ | --------------------------------------------------------- |
| `asset_weight_init`                  | [`Option<WrappedI80F48>`](#wrappedi80f48)                 |
| `asset_weight_maint`                 | [`Option<WrappedI80F48>`](#wrappedi80f48)                 |
| `liability_weight_init`              | [`Option<WrappedI80F48>`](#wrappedi80f48)                 |
| `liability_weight_maint`             | [`Option<WrappedI80F48>`](#wrappedi80f48)                 |
| `deposit_limit`                      | `Option<u64>`                                             |
| `borrow_limit`                       | `Option<u64>`                                             |
| `operational_state`                  | [`Option<BankOperationalState>`](#bankoperationalstate)   |
| `interest_rate_config`               | [`Option<InterestRateConfigOpt>`](#interestrateconfigopt) |
| `risk_tier`                          | [`Option<RiskTier>`](#risktier)                           |
| `asset_tag`                          | `Option<u8>`                                              |
| `total_asset_value_init_limit`       | `Option<u64>`                                             |
| `oracle_max_confidence`              | `Option<u32>`                                             |
| `oracle_max_age`                     | `Option<u16>`                                             |
| `permissionless_bad_debt_settlement` | `Option<bool>`                                            |
| `freeze_settings`                    | `Option<bool>`                                            |
| `tokenless_repayments_allowed`       | `Option<bool>`                                            |

### `BankOperationalState`

Enum `types::BankOperationalState`.

| Variant              |
| -------------------- |
| `Paused`             |
| `Operational`        |
| `ReduceOnly`         |
| `KilledByBankruptcy` |

### `BankRateLimiter`

> _From the program's IDL:_
>
> Per-bank rate limiting configuration and state.\
> Tracks net outflow in native tokens.

Struct `types::BankRateLimiter`.

| Field    | Type                                  | Description                                 |
| -------- | ------------------------------------- | ------------------------------------------- |
| `hourly` | [`RateLimitWindow`](#ratelimitwindow) | Hourly window rate limiter (native tokens). |
| `daily`  | [`RateLimitWindow`](#ratelimitwindow) | Daily window rate limiter (native tokens).  |

### `DeleverageEvent`

Struct `types::DeleverageEvent`. Same fields as the [`DeleverageEvent`](#deleverageevent) event.

### `DeleverageWithdrawFlowEvent`

> _From the program's IDL:_
>
> Emitted for deleverage-only withdraw outflows.\
> The delegate flow admin aggregates these off-chain and updates the deleverage daily withdraws via `update_deleverage_withdrawals`.

Struct `types::DeleverageWithdrawFlowEvent`. Same fields as the [`DeleverageWithdrawFlowEvent`](#deleveragewithdrawflowevent) event.

### `DriftConfigCompact`

> _From the program's IDL:_
>
> Used to configure Drift banks. A simplified version of `BankConfigCompact` which omits most values related to interest since Drift banks cannot earn interest or be borrowed against.

Struct `types::DriftConfigCompact`.

| Field                          | Type                                            | Description                                                    |
| ------------------------------ | ----------------------------------------------- | -------------------------------------------------------------- |
| `oracle`                       | `Pubkey`                                        |                                                                |
| `asset_weight_init`            | [`WrappedI80F48`](#wrappedi80f48)               |                                                                |
| `asset_weight_maint`           | [`WrappedI80F48`](#wrappedi80f48)               |                                                                |
| `deposit_limit`                | `u64`                                           |                                                                |
| `oracle_setup`                 | [`OracleSetup`](#oraclesetup)                   | Either `DriftPythPull` or `DriftSwitchboardPull`               |
| `operational_state`            | [`BankOperationalState`](#bankoperationalstate) | Bank operational state - allows starting banks in paused state |
| `risk_tier`                    | [`RiskTier`](#risktier)                         | Risk tier - determines if assets can be borrowed in isolation  |
| `config_flags`                 | `u8`                                            | Config flags for future-proofing                               |
| `total_asset_value_init_limit` | `u64`                                           |                                                                |
| `oracle_max_age`               | `u16`                                           |                                                                |
| `oracle_max_confidence`        | `u32`                                           | Oracle confidence threshold (0 = use default 10%)              |

### `EditStakedSettingsEvent`

Struct `types::EditStakedSettingsEvent`. Same fields as the [`EditStakedSettingsEvent`](#editstakedsettingsevent) event.

### `EmodeConfig`

> _From the program's IDL:_
>
> An emode configuration. Each bank has one such configuration, but this may also be the intersection of many configurations (see `reconcile_emode_configs`). For example, the risk engine creates such an intersection from all the emode config of all banks the user is borrowing from.

Struct `types::EmodeConfig`.

| Field     | Type                              |
| --------- | --------------------------------- |
| `entries` | [`[EmodeEntry; 10]`](#emodeentry) |

### `EmodeEntry`

Struct `types::EmodeEntry`.

| Field                       | Type                              | Description                                                                                                                                                                                                                                      |
| --------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `collateral_bank_emode_tag` | `u16`                             | emode_tag of the bank(s) whose collateral you wish to treat preferentially.                                                                                                                                                                      |
| `flags`                     | `u8`                              | \* APPLIES_TO_ISOLATED (1) - (NOT YET IMPLEMENTED) if set, isolated banks with this tag also benefit. If not set, isolated banks continue to offer zero collateral, even if they use this tag. \* 2, 4, 8, 16, 32, etc - reserved for future use |
| `pad0`                      | `[u8; 5]`                         |                                                                                                                                                                                                                                                  |
| `asset_weight_init`         | [`WrappedI80F48`](#wrappedi80f48) | Note: If set below the collateral bank's weight, does nothing.                                                                                                                                                                                   |
| `asset_weight_maint`        | [`WrappedI80F48`](#wrappedi80f48) | Note: If set below the collateral bank's weight, does nothing.                                                                                                                                                                                   |

### `EmodeSettings`

> _From the program's IDL:_
>
> Controls the bank's e-mode configuration, allowing certain collateral sources to be treated more favorably as collateral when used to borrow from this bank.

Struct `types::EmodeSettings`.

| Field          | Type                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `emode_tag`    | `u16`                         | This bank's NON-unique id that other banks will use to determine what emode rate to use when this bank is offered as collateral. For example, all stablecoin banks might share the same emode_tag, and in their entries, each such stablecoin bank will recognize that collateral sources with this "stable" tag get preferential weights. When a new stablecoin is added that is considered riskier, it may get a new, less favorable emode tag, and eventually get upgraded to the same one as the other stables \* 0 is in an invalid tag and will do nothing. |
| `pad0`         | `[u8; 6]`                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `timestamp`    | `i64`                         | Unix timestamp from the system clock when emode state was last updated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `flags`        | `u64`                         | EMODE_ON (1) - If set, at least one entry is configured 2, 4, 8, etc, Reserved for future use                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `emode_config` | [`EmodeConfig`](#emodeconfig) |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

### `ExecuteOrderBalanceRecord`

Struct `types::ExecuteOrderBalanceRecord`.

| Field      | Type                              |
| ---------- | --------------------------------- |
| `bank`     | `Pubkey`                          |
| `is_asset` | `u8`                              |
| `pad0`     | `[u8; 5]`                         |
| `tag`      | `u16`                             |
| `shares`   | [`WrappedI80F48`](#wrappedi80f48) |

### `FeeStateCache`

> _From the program's IDL:_
>
> Cached fee configuration propagated from the global FeeState

Struct `types::FeeStateCache`.

| Field               | Type                              | Description                                        |
| ------------------- | --------------------------------- | -------------------------------------------------- |
| `global_fee_wallet` | `Pubkey`                          | The wallet that receives program-level fees        |
| `program_fee_fixed` | [`WrappedI80F48`](#wrappedi80f48) | Fixed fee APR charged to borrowers (program-level) |
| `program_fee_rate`  | [`WrappedI80F48`](#wrappedi80f48) | Proportional fee rate on interest (program-level)  |
| `last_update`       | `i64`                             | Unix timestamp of the last fee state propagation   |

### `GroupEventHeader`

Struct `types::GroupEventHeader`.

| Field            | Type             |
| ---------------- | ---------------- |
| `signer`         | `Option<Pubkey>` |
| `marginfi_group` | `Pubkey`         |

### `GroupRateLimiter`

> _From the program's IDL:_
>
> Per-group rate limiting configuration and state.\
> Tracks aggregate net outflow in USD.

Struct `types::GroupRateLimiter`.

| Field    | Type                                  | Description                       |
| -------- | ------------------------------------- | --------------------------------- |
| `hourly` | [`RateLimitWindow`](#ratelimitwindow) | Hourly window rate limiter (USD). |
| `daily`  | [`RateLimitWindow`](#ratelimitwindow) | Daily window rate limiter (USD).  |

### `HealthCache`

> _From the program's IDL:_
>
> A read-only cache of the internal risk engine's information. Only valid in borrow/withdraw if the tx does not fail. To see the state in any context, e.g. to figure out if the risk engine is failing due to some bad price information, use `pulse_health`.

Struct `types::HealthCache`.

| Field                     | Type                              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `asset_value`             | [`WrappedI80F48`](#wrappedi80f48) | Internal risk engine asset value, using initial weight (e.g. what is used for borrowing purposes), with all confidence adjustments, and other discounts on price. \* Uses EMA price \* In dollars                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `liability_value`         | [`WrappedI80F48`](#wrappedi80f48) | Internal risk engine liability value, using initial weight (e.g. what is used for borrowing purposes), with all confidence adjustments, and other discounts on price. \* Uses EMA price \* In dollars                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `asset_value_maint`       | [`WrappedI80F48`](#wrappedi80f48) | Internal risk engine asset value, using maintenance weight (e.g. what is used for liquidation purposes), with all confidence adjustments. \* Zero if the risk engine failed to load \* Uses SPOT price \* In dollars                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `liability_value_maint`   | [`WrappedI80F48`](#wrappedi80f48) | Internal risk engine liability value, using maintenance weight (e.g. what is used for liquidation purposes), with all confidence adjustments. \* Zero if the risk engine failed to load \* Uses SPOT price \* In dollars                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `asset_value_equity`      | [`WrappedI80F48`](#wrappedi80f48) | The "true" value of assets without any confidence or weight adjustments. Internally, used only for bankruptcies. \* Zero if the risk engine failed to load \* Uses EMA price \* In dollars                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `liability_value_equity`  | [`WrappedI80F48`](#wrappedi80f48) | The "true" value of liabilities without any confidence or weight adjustments. Internally, used only for bankruptcies. \* Zero if the risk engine failed to load \* Uses EMA price \* In dollars                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `timestamp`               | `i64`                             | Unix timestamp from the system clock when this cache was last updated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `flags`                   | `u32`                             | The flags that indicate the state of the health cache. This is a u32 bitfield, where each bit represents a flag. \* HEALTHY = 1 - If set, the account cannot be liquidated. If 0, the account is unhealthy and can be liquidated. \* ENGINE STATUS = 2 - If set, the engine did not error during the last health pulse. If 0, the engine would have errored and this cache is likely invalid. `RiskEngineInitRejected` is ignored and will allow the flag to be set anyways. \* ORACLE OK = 4 - If set, the engine did not error due to an oracle issue. If 0, engine was passed a bad bank or oracle account, or an oracle was stale. Check the order in which accounts were passed and ensure each balance has the correct banks/oracles, and that oracle cranks ran recently enough. Check `internal_err` and `err_index` for more details in some circumstances. Invalid if generated after borrow/withdraw (these instructions will ignore oracle issues if health is still satisfactory with some balance zeroed out). \* 8, 16, 32, 64, 128, etc - reserved for future use |
| `mrgn_err`                | `u32`                             | If the engine errored, look here for the error code. If the engine returns ok, you may also check here to see if the risk engine rejected this tx (3009).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `prices`                  | `[[u8; 8]; 16]`                   | Each price corresponds to that index of Balances in the LendingAccount. Useful for debugging or liquidator consumption, to determine how a user's position is priced internally. \* An f64 stored as bytes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `internal_err`            | `u32`                             | Errors in asset oracles are ignored (with prices treated as zero). If you see a zero price and the `ORACLE_OK` flag is not set, check here to see what error was ignored internally.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `err_index`               | `u8`                              | Index in `balances` where `internal_err` appeared                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `program_version`         | `u8`                              | Since 0.1.3, the version will be encoded here. See PROGRAM_VERSION.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `pad0`                    | `[u8; 2]`                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `internal_liq_err`        | `u32`                             | Error code from the liquidation health check during the last health pulse (0 if none)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `internal_bankruptcy_err` | `u32`                             | Error code from the bankruptcy check during the last health pulse (0 if none)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `reserved0`               | `[u8; 32]`                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `reserved1`               | `[u8; 16]`                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

### `HealthPulseEvent`

Struct `types::HealthPulseEvent`. Same fields as the [`HealthPulseEvent`](#healthpulseevent) event.

### `InterestRateConfig`

Struct `types::InterestRateConfig`.

| Field                      | Type                              | Description                                                                                                                                                                                                                                               |
| -------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `optimal_utilization_rate` | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `plateau_interest_rate`    | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `max_interest_rate`        | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `insurance_fee_fixed_apr`  | [`WrappedI80F48`](#wrappedi80f48) | Goes to insurance, funds `collected_insurance_fees_outstanding`                                                                                                                                                                                           |
| `insurance_ir_fee`         | [`WrappedI80F48`](#wrappedi80f48) | Goes to insurance, funds `collected_insurance_fees_outstanding`                                                                                                                                                                                           |
| `protocol_fixed_fee_apr`   | [`WrappedI80F48`](#wrappedi80f48) | Earned by the group, goes to `collected_group_fees_outstanding`                                                                                                                                                                                           |
| `protocol_ir_fee`          | [`WrappedI80F48`](#wrappedi80f48) | Earned by the group, goes to `collected_group_fees_outstanding`                                                                                                                                                                                           |
| `protocol_origination_fee` | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `zero_util_rate`           | `u32`                             | The base rate at utilization = 0 \* a %, as u32, out of 1000%, e.g. 100% = 0.1 \* u32::MAX                                                                                                                                                                |
| `hundred_util_rate`        | `u32`                             | The base rate at utilization = 100 \* a %, as u32, out of 1000%, e.g. 100% = 0.1 \* u32::MAX                                                                                                                                                              |
| `points`                   | [`[RatePoint; 5]`](#ratepoint)    | The base rate at various points between 0 and 100%, exclusive. Essentially a piece-wise linear curve. \* always in ascending order, e.g. points\[0] = first kink point, points\[1] = second kink point, and so forth. \* points where util = 0 are unused |
| `curve_type`               | `u8`                              | Determines which interest rate curve implementation is active. 0 (INTEREST_CURVE_LEGACY) = legacy three point curve, 1 (INTEREST_CURVE_SEVEN_POINT) = multi-point curve.                                                                                  |
| `pad0`                     | `[u8; 7]`                         |                                                                                                                                                                                                                                                           |
| `padding1`                 | `[u8; 32]`                        |                                                                                                                                                                                                                                                           |
| `padding2`                 | `[u8; 16]`                        |                                                                                                                                                                                                                                                           |
| `padding3`                 | `[u8; 8]`                         |                                                                                                                                                                                                                                                           |

### `InterestRateConfigCompact`

Struct `types::InterestRateConfigCompact`.

| Field                      | Type                              | Description                                                                                                                                                                                                                                               |
| -------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `insurance_fee_fixed_apr`  | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `insurance_ir_fee`         | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `protocol_fixed_fee_apr`   | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `protocol_ir_fee`          | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `protocol_origination_fee` | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `zero_util_rate`           | `u32`                             | The base rate at utilization = 0 \* a %, as u32, out of 1000%, e.g. 100% = 0.1 \* u32::MAX                                                                                                                                                                |
| `hundred_util_rate`        | `u32`                             | The base rate at utilization = 100 \* a %, as u32, out of 1000%, e.g. 100% = 0.1 \* u32::MAX                                                                                                                                                              |
| `points`                   | [`[RatePoint; 5]`](#ratepoint)    | The base rate at various points between 0 and 100%, exclusive. Essentially a piece-wise linear curve. \* always in ascending order, e.g. points\[0] = first kink point, points\[1] = second kink point, and so forth. \* points where util = 0 are unused |

### `InterestRateConfigOpt`

Struct `types::InterestRateConfigOpt`.

| Field                      | Type                                      | Description                                                                                                                                                                                                                                               |
| -------------------------- | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `insurance_fee_fixed_apr`  | [`Option<WrappedI80F48>`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `insurance_ir_fee`         | [`Option<WrappedI80F48>`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `protocol_fixed_fee_apr`   | [`Option<WrappedI80F48>`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `protocol_ir_fee`          | [`Option<WrappedI80F48>`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `protocol_origination_fee` | [`Option<WrappedI80F48>`](#wrappedi80f48) |                                                                                                                                                                                                                                                           |
| `zero_util_rate`           | `Option<u32>`                             | The base rate at utilization = 0 \* a %, as u32, out of 1000%, e.g. 100% = 0.1 \* u32::MAX                                                                                                                                                                |
| `hundred_util_rate`        | `Option<u32>`                             | The base rate at utilization = 100 \* a %, as u32, out of 1000%, e.g. 100% = 0.1 \* u32::MAX                                                                                                                                                              |
| `points`                   | [`Option<[RatePoint; 5]>`](#ratepoint)    | The base rate at various points between 0 and 100%, exclusive. Essentially a piece-wise linear curve. \* always in ascending order, e.g. points\[0] = first kink point, points\[1] = second kink point, and so forth. \* points where util = 0 are unused |

### `JuplendConfigCompact`

> _From the program's IDL:_
>
> Used to configure JupLend banks. A simplified version of `BankConfigCompact` which omits most values related to interest since JupLend banks cannot earn interest or be borrowed against. Note: JupLend banks do not take an\
> Operational State, they always start in `Paused` state and are set to `Operational` via `juplend_init_position` (seed deposit + protocol fToken vault).

Struct `types::JuplendConfigCompact`.

| Field                          | Type                              | Description                                          |
| ------------------------------ | --------------------------------- | ---------------------------------------------------- |
| `oracle`                       | `Pubkey`                          |                                                      |
| `asset_weight_init`            | [`WrappedI80F48`](#wrappedi80f48) |                                                      |
| `asset_weight_maint`           | [`WrappedI80F48`](#wrappedi80f48) |                                                      |
| `deposit_limit`                | `u64`                             |                                                      |
| `oracle_setup`                 | [`OracleSetup`](#oraclesetup)     | Either `JuplendPythPull` or `JuplendSwitchboardPull` |
| `risk_tier`                    | [`RiskTier`](#risktier)           | Isolated or Collateral                               |
| `config_flags`                 | `u8`                              | Config flags for future-proofing, currently ignored  |
| `total_asset_value_init_limit` | `u64`                             | In $                                                 |
| `oracle_max_age`               | `u16`                             | In seconds                                           |
| `oracle_max_confidence`        | `u32`                             | Oracle confidence threshold (0 = use default 10%)    |

### `KaminoConfigCompact`

> _From the program's IDL:_
>
> Used to configure Kamino banks. A simplified version of `BankConfigCompact` which omits most values related to interest since Kamino banks cannot earn interest or be borrowed against.

Struct `types::KaminoConfigCompact`.

| Field                          | Type                                            | Description                                                    |
| ------------------------------ | ----------------------------------------------- | -------------------------------------------------------------- |
| `oracle`                       | `Pubkey`                                        |                                                                |
| `asset_weight_init`            | [`WrappedI80F48`](#wrappedi80f48)               |                                                                |
| `asset_weight_maint`           | [`WrappedI80F48`](#wrappedi80f48)               |                                                                |
| `deposit_limit`                | `u64`                                           |                                                                |
| `oracle_setup`                 | [`OracleSetup`](#oraclesetup)                   | Either `KaminoPythPush` or `KaminoSwitchboardPull`             |
| `operational_state`            | [`BankOperationalState`](#bankoperationalstate) | Bank operational state - allows starting banks in paused state |
| `risk_tier`                    | [`RiskTier`](#risktier)                         | Risk tier - determines if assets can be borrowed in isolation  |
| `config_flags`                 | `u8`                                            | Config flags for future-proofing                               |
| `total_asset_value_init_limit` | `u64`                                           |                                                                |
| `oracle_max_age`               | `u16`                                           | Currently unused: Kamino's oracle age applies to kamino banks. |
| `oracle_max_confidence`        | `u32`                                           | Oracle confidence threshold (0 = use default 10%)              |

### `KeeperCloseOrderEvent`

Struct `types::KeeperCloseOrderEvent`. Same fields as the [`KeeperCloseOrderEvent`](#keepercloseorderevent) event.

### `LendingAccount`

> _From the program's IDL:_
>
> The lending account holds up to 16 balance positions for a user.

Struct `types::LendingAccount`.

| Field           | Type                        | Description                                                                 |
| --------------- | --------------------------- | --------------------------------------------------------------------------- |
| `balances`      | [`[Balance; 16]`](#balance) | Array of balance positions (max 16). Sorted in descending order by bank_pk. |
| `last_tag_used` | `u16`                       | Last allocated balance tag (u16), used to find the next unused tag.         |
| `pad1`          | `[u8; 6]`                   | Reserved for future use                                                     |
| `padding`       | `[u64; 7]`                  | Reserved for future use                                                     |

### `LendingAccountBorrowEvent`

Struct `types::LendingAccountBorrowEvent`. Same fields as the [`LendingAccountBorrowEvent`](#lendingaccountborrowevent) event.

### `LendingAccountDepositEvent`

Struct `types::LendingAccountDepositEvent`. Same fields as the [`LendingAccountDepositEvent`](#lendingaccountdepositevent) event.

### `LendingAccountLiquidateEvent`

Struct `types::LendingAccountLiquidateEvent`. Same fields as the [`LendingAccountLiquidateEvent`](#lendingaccountliquidateevent) event.

### `LendingAccountRepayEvent`

Struct `types::LendingAccountRepayEvent`. Same fields as the [`LendingAccountRepayEvent`](#lendingaccountrepayevent) event.

### `LendingAccountWithdrawEvent`

Struct `types::LendingAccountWithdrawEvent`. Same fields as the [`LendingAccountWithdrawEvent`](#lendingaccountwithdrawevent) event.

### `LendingPoolBankAccrueInterestEvent`

Struct `types::LendingPoolBankAccrueInterestEvent`. Same fields as the [`LendingPoolBankAccrueInterestEvent`](#lendingpoolbankaccrueinterestevent) event.

### `LendingPoolBankCollectFeesEvent`

Struct `types::LendingPoolBankCollectFeesEvent`. Same fields as the [`LendingPoolBankCollectFeesEvent`](#lendingpoolbankcollectfeesevent) event.

### `LendingPoolBankConfigureEvent`

Struct `types::LendingPoolBankConfigureEvent`. Same fields as the [`LendingPoolBankConfigureEvent`](#lendingpoolbankconfigureevent) event.

### `LendingPoolBankConfigureFrozenEvent`

Struct `types::LendingPoolBankConfigureFrozenEvent`. Same fields as the [`LendingPoolBankConfigureFrozenEvent`](#lendingpoolbankconfigurefrozenevent) event.

### `LendingPoolBankConfigureOracleEvent`

Struct `types::LendingPoolBankConfigureOracleEvent`. Same fields as the [`LendingPoolBankConfigureOracleEvent`](#lendingpoolbankconfigureoracleevent) event.

### `LendingPoolBankCreateEvent`

Struct `types::LendingPoolBankCreateEvent`. Same fields as the [`LendingPoolBankCreateEvent`](#lendingpoolbankcreateevent) event.

### `LendingPoolBankHandleBankruptcyEvent`

Struct `types::LendingPoolBankHandleBankruptcyEvent`. Same fields as the [`LendingPoolBankHandleBankruptcyEvent`](#lendingpoolbankhandlebankruptcyevent) event.

### `LendingPoolBankSetFixedOraclePriceEvent`

Struct `types::LendingPoolBankSetFixedOraclePriceEvent`. Same fields as the [`LendingPoolBankSetFixedOraclePriceEvent`](#lendingpoolbanksetfixedoraclepriceevent) event.

### `LendingPoolSuperAdminDepositEvent`

Struct `types::LendingPoolSuperAdminDepositEvent`. Same fields as the [`LendingPoolSuperAdminDepositEvent`](#lendingpoolsuperadmindepositevent) event.

### `LendingPoolSuperAdminWithdrawEvent`

Struct `types::LendingPoolSuperAdminWithdrawEvent`. Same fields as the [`LendingPoolSuperAdminWithdrawEvent`](#lendingpoolsuperadminwithdrawevent) event.

### `LiquidationBalances`

Struct `types::LiquidationBalances`.

| Field                          | Type  |
| ------------------------------ | ----- |
| `liquidatee_asset_balance`     | `f64` |
| `liquidatee_liability_balance` | `f64` |
| `liquidator_asset_balance`     | `f64` |
| `liquidator_liability_balance` | `f64` |

### `LiquidationCache`

Struct `types::LiquidationCache`.

| Field                    | Type                              | Description                                                                                                                                                                                                                                |
| ------------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `asset_value_maint`      | [`WrappedI80F48`](#wrappedi80f48) | Internal risk engine asset value snapshot taken when liquidation begins, using maintenance weight with all confidence adjustments. \* Uses SPOT price \* In dollars                                                                        |
| `liability_value_maint`  | [`WrappedI80F48`](#wrappedi80f48) | Internal risk engine liability value snapshot taken when liquidation begins, using maintenance weight with all confidence adjustments. \* Uses SPOT price \* In dollars                                                                    |
| `asset_value_equity`     | [`WrappedI80F48`](#wrappedi80f48) | Actual cash value of assets pre-liquidation (inclusive of price adjustment for oracle confidence, but without any weights) \* Liquidator is allowed to seize up to `liability_value_equity` - this amount \* Uses EMA price \* In dollars  |
| `liability_value_equity` | [`WrappedI80F48`](#wrappedi80f48) | Actual cash value of liabilities pre-liquidation (inclusive of price adjustment for oracle confidence, but without any weights) \* Liquidator is allowed to seize up to this amount - `asset_value_equity` \* Uses EMA price \* In dollars |
| `placeholder`            | `u64`                             |                                                                                                                                                                                                                                            |
| `reserved0`              | `[u8; 32]`                        |                                                                                                                                                                                                                                            |

### `LiquidationEntry`

> _From the program's IDL:_
>
> Used to record key details of the last few liquidation events on the account

Struct `types::LiquidationEntry`.

| Field                 | Type       | Description                                    |
| --------------------- | ---------- | ---------------------------------------------- |
| `asset_amount_seized` | `[u8; 8]`  | Dollar amount seized \* An f64 stored as bytes |
| `liab_amount_repaid`  | `[u8; 8]`  | Dollar amount repaid \* An f64 stored as bytes |
| `placeholder0`        | `u64`      |                                                |
| `timestamp`           | `i64`      |                                                |
| `reserved0`           | `[u8; 16]` |                                                |

### `LiquidationReceiverEvent`

Struct `types::LiquidationReceiverEvent`. Same fields as the [`LiquidationReceiverEvent`](#liquidationreceiverevent) event.

### `MarginfiAccountCloseOrderEvent`

Struct `types::MarginfiAccountCloseOrderEvent`. Same fields as the [`MarginfiAccountCloseOrderEvent`](#marginfiaccountcloseorderevent) event.

### `MarginfiAccountCreateEvent`

Struct `types::MarginfiAccountCreateEvent`. Same fields as the [`MarginfiAccountCreateEvent`](#marginfiaccountcreateevent) event.

### `MarginfiAccountFreezeEvent`

Struct `types::MarginfiAccountFreezeEvent`. Same fields as the [`MarginfiAccountFreezeEvent`](#marginfiaccountfreezeevent) event.

### `MarginfiAccountPlaceOrderEvent`

Struct `types::MarginfiAccountPlaceOrderEvent`. Same fields as the [`MarginfiAccountPlaceOrderEvent`](#marginfiaccountplaceorderevent) event.

### `MarginfiAccountTransferToNewAccount`

Struct `types::MarginfiAccountTransferToNewAccount`. Same fields as the [`MarginfiAccountTransferToNewAccount`](#marginfiaccounttransfertonewaccount) event.

### `MarginfiGroupConfigureEvent`

Struct `types::MarginfiGroupConfigureEvent`. Same fields as the [`MarginfiGroupConfigureEvent`](#marginfigroupconfigureevent) event.

### `MarginfiGroupCreateEvent`

Struct `types::MarginfiGroupCreateEvent`. Same fields as the [`MarginfiGroupCreateEvent`](#marginfigroupcreateevent) event.

### `MinimalObligationCollateral`

Struct `types::MinimalObligationCollateral`.

| Field                                                        | Type       | Description                                                                                                                                   |
| ------------------------------------------------------------ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `deposit_reserve`                                            | `Pubkey`   |                                                                                                                                               |
| `deposited_amount`                                           | `u64`      | In collateral token (NOT liquidity token), use `collateral_to_liquidity` to convert back to liquidity token! \* Always 6 decimals             |
| `market_value_sf`                                            | `[u8; 16]` | \* In dollars, based on last oracle price update \* Actually an I68F60, stored as a u128 (i.e. BN) in Kamino. \* A float (arbitrary decimals) |
| `borrowed_amount_against_this_collateral_in_elevation_group` | `u64`      |                                                                                                                                               |
| `padding`                                                    | `[u64; 9]` |                                                                                                                                               |

### `OracleSetup`

Enum `types::OracleSetup`.

| Variant                  |
| ------------------------ |
| `None`                   |
| `PythLegacy`             |
| `SwitchboardV2`          |
| `PythPushOracle`         |
| `SwitchboardPull`        |
| `StakedWithPythPush`     |
| `KaminoPythPush`         |
| `KaminoSwitchboardPull`  |
| `Fixed`                  |
| `DriftPythPull`          |
| `DriftSwitchboardPull`   |
| `SolendPythPull`         |
| `SolendSwitchboardPull`  |
| `FixedKamino`            |
| `FixedDrift`             |
| `JuplendPythPull`        |
| `JuplendSwitchboardPull` |
| `FixedJuplend`           |

### `OrderTrigger`

Enum `types::OrderTrigger`.

| Variant      | Fields                                                                                                                  |
| ------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `StopLoss`   | `threshold`: [`WrappedI80F48`](#wrappedi80f48), `max_slippage`: `u32`                                                   |
| `TakeProfit` | `threshold`: [`WrappedI80F48`](#wrappedi80f48), `max_slippage`: `u32`                                                   |
| `Both`       | `stop_loss`: [`WrappedI80F48`](#wrappedi80f48), `take_profit`: [`WrappedI80F48`](#wrappedi80f48), `max_slippage`: `u32` |

### `OrderTriggerType`

Enum `types::OrderTriggerType`.

| Variant      |
| ------------ |
| `StopLoss`   |
| `TakeProfit` |
| `Both`       |

### `PanicState`

> _From the program's IDL:_
>
> Panic state for emergency protocol pausing

Struct `types::PanicState`.

| Field                        | Type      | Description                                                                                                                          |
| ---------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `pause_flags`                | `u8`      | Whether the protocol is currently paused (1 = paused, 0 = not paused)                                                                |
| `daily_pause_count`          | `u8`      | Number of times paused today (resets every 24 hours)                                                                                 |
| `consecutive_pause_count`    | `u8`      | Number of consecutive pauses (resets when unpause happens)                                                                           |
| `reserved`                   | `[u8; 5]` |                                                                                                                                      |
| `pause_start_timestamp`      | `i64`     | Timestamp when the current pause started (0 if not paused) \* When a pause is extended before expiring, this could be in the future. |
| `last_daily_reset_timestamp` | `i64`     | Timestamp of the last daily reset (for tracking daily pause count)                                                                   |
| `reserved_space`             | `[u8; 8]` | Reserved for future use (making total struct 32 bytes)                                                                               |

### `PanicStateCache`

> _From the program's IDL:_
>
> Cached panic state information for fast checking during user operations

Struct `types::PanicStateCache`.

| Field                   | Type      | Description                                                           |
| ----------------------- | --------- | --------------------------------------------------------------------- |
| `pause_flags`           | `u8`      | Whether the protocol is currently paused (1 = paused, 0 = not paused) |
| `reserved`              | `[u8; 7]` |                                                                       |
| `pause_start_timestamp` | `i64`     | Timestamp when the current pause started (0 if not paused)            |
| `last_cache_update`     | `i64`     | Timestamp when this cache was last updated                            |

### `RateLimitFlowEvent`

> _From the program's IDL:_
>
> Emitted when a bank-level inflow or outflow is recorded.\
> The delegate flow admin aggregates these off-chain and updates the group rate limiter via `update_group_rate_limiter`.

Struct `types::RateLimitFlowEvent`. Same fields as the [`RateLimitFlowEvent`](#ratelimitflowevent) event.

### `RateLimitWindow`

> _From the program's IDL:_
>
> A sliding window rate limiter that tracks net outflow over a time window.\
> Uses weighted blend of previous and current windows for smooth transitions.\
> Net outflow = (withdraws + borrows) - (deposits + repays).\
> A negative net outflow increases remaining capacity for subsequent outflows.

Struct `types::RateLimitWindow`.

| Field                 | Type  | Description                                                                                                                               |
| --------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `max_outflow`         | `u64` | Maximum net outflow allowed per window (0 = disabled). For bank-level: denominated in native tokens. For group-level: denominated in USD. |
| `window_duration`     | `u64` | Window duration in seconds (e.g., 3600 for hourly, 86400 for daily).                                                                      |
| `window_start`        | `i64` | Unix timestamp when the current window started.                                                                                           |
| `prev_window_outflow` | `i64` | Net outflow accumulated in the previous window. Signed to allow tracking when inflows exceed outflows.                                    |
| `cur_window_outflow`  | `i64` | Net outflow accumulated in the current window. Signed to allow tracking when inflows exceed outflows.                                     |

### `RatePoint`

Struct `types::RatePoint`.

| Field  | Type  | Description                                                                                      |
| ------ | ----- | ------------------------------------------------------------------------------------------------ |
| `util` | `u32` | The utilization rate where `rate` applies \* a %, as u32, out of 100%, e.g. 50% = .5 \* u32::MAX |
| `rate` | `u32` | The base rate that applies \* a %, as u32, out of 1000%, e.g. 100% = 0.1 \* u32::MAX             |

### `RiskTier`

Enum `types::RiskTier`.

| Variant      |
| ------------ |
| `Collateral` |
| `Isolated`   |

### `SetKeeperCloseFlagsEvent`

Struct `types::SetKeeperCloseFlagsEvent`. Same fields as the [`SetKeeperCloseFlagsEvent`](#setkeepercloseflagsevent) event.

### `SolendConfigCompact`

> _From the program's IDL:_
>
> Used to configure Solend banks. A simplified version of `BankConfigCompact` which omits most values related to interest since Solend banks cannot earn interest or be borrowed against.

Struct `types::SolendConfigCompact`.

| Field                          | Type                                            | Description                                                    |
| ------------------------------ | ----------------------------------------------- | -------------------------------------------------------------- |
| `oracle`                       | `Pubkey`                                        |                                                                |
| `asset_weight_init`            | [`WrappedI80F48`](#wrappedi80f48)               |                                                                |
| `asset_weight_maint`           | [`WrappedI80F48`](#wrappedi80f48)               |                                                                |
| `deposit_limit`                | `u64`                                           |                                                                |
| `oracle_setup`                 | [`OracleSetup`](#oraclesetup)                   | Either `SolendPythPull` or `SolendSwitchboardPull`             |
| `operational_state`            | [`BankOperationalState`](#bankoperationalstate) | Bank operational state - allows starting banks in paused state |
| `risk_tier`                    | [`RiskTier`](#risktier)                         | Risk tier - determines if assets can be borrowed in isolation  |
| `config_flags`                 | `u8`                                            | Config flags for future-proofing                               |
| `total_asset_value_init_limit` | `u64`                                           |                                                                |
| `oracle_max_age`               | `u16`                                           |                                                                |
| `oracle_max_confidence`        | `u32`                                           | Oracle confidence threshold (0 = use default 10%)              |

### `SpotBalanceType`

Enum `types::SpotBalanceType`.

| Variant   |
| --------- |
| `Deposit` |
| `Borrow`  |

### `SpotPosition`

> _From the program's IDL:_
>
> Minimal representation of a spot position within a User account

Struct `types::SpotPosition`.

| Field                 | Type                                  | Description                                                                        |
| --------------------- | ------------------------------------- | ---------------------------------------------------------------------------------- |
| `scaled_balance`      | `u64`                                 | The scaled balance of the position. \* Precision: SPOT_BALANCE_PRECISION           |
| `open_bids`           | `i64`                                 | How many spot bids the user has open \* Precision: token mint precision            |
| `open_asks`           | `i64`                                 | How many spot asks the user has open \* Precision: token mint precision            |
| `cumulative_deposits` | `i64`                                 | The cumulative deposits/borrows a user has made \* Precision: token mint precision |
| `market_index`        | `u16`                                 | The market index of the corresponding spot market                                  |
| `balance_type`        | [`SpotBalanceType`](#spotbalancetype) | Whether the position is deposit or borrow                                          |
| `open_orders`         | `u8`                                  | Number of open orders                                                              |
| `padding`             | `[u8; 4]`                             | Padding                                                                            |

### `StakedSettingsConfig`

Struct `types::StakedSettingsConfig`.

| Field                          | Type                              | Description                                                                                                                                                                                                    |
| ------------------------------ | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `oracle`                       | `Pubkey`                          |                                                                                                                                                                                                                |
| `asset_weight_init`            | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                |
| `asset_weight_maint`           | [`WrappedI80F48`](#wrappedi80f48) |                                                                                                                                                                                                                |
| `deposit_limit`                | `u64`                             |                                                                                                                                                                                                                |
| `total_asset_value_init_limit` | `u64`                             |                                                                                                                                                                                                                |
| `oracle_max_age`               | `u16`                             |                                                                                                                                                                                                                |
| `risk_tier`                    | [`RiskTier`](#risktier)           | WARN: You almost certainly want "Collateral", using Isolated risk tier makes the asset worthless as collateral, and is generally useful only when creating a staked collateral pool for rewards purposes only. |

### `StakedSettingsEditConfig`

Struct `types::StakedSettingsEditConfig`.

| Field                          | Type                                      | Description                                                                                                                                                                                                                                                               |
| ------------------------------ | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `oracle`                       | `Option<Pubkey>`                          |                                                                                                                                                                                                                                                                           |
| `asset_weight_init`            | [`Option<WrappedI80F48>`](#wrappedi80f48) |                                                                                                                                                                                                                                                                           |
| `asset_weight_maint`           | [`Option<WrappedI80F48>`](#wrappedi80f48) |                                                                                                                                                                                                                                                                           |
| `deposit_limit`                | `Option<u64>`                             |                                                                                                                                                                                                                                                                           |
| `total_asset_value_init_limit` | `Option<u64>`                             |                                                                                                                                                                                                                                                                           |
| `oracle_max_age`               | `Option<u16>`                             |                                                                                                                                                                                                                                                                           |
| `risk_tier`                    | [`Option<RiskTier>`](#risktier)           | WARN: You almost certainly want "Collateral", using Isolated risk tier makes the asset worthless as collateral, making all outstanding accounts eligible to be liquidated, and is generally useful only when creating a staked collateral pool for rewards purposes only. |

### `UserStatus`

Enum `types::UserStatus`.

| Variant                |
| ---------------------- |
| `Active`               |
| `BeingLiquidated`      |
| `Bankrupt`             |
| `ReduceOnly`           |
| `AdvancedLp`           |
| `ProtectedMakerOrders` |

### `WithdrawWindowCache`

> _From the program's IDL:_
>
> Tracks deleverage withdrawal limits to protect against compromised risk admin

Struct `types::WithdrawWindowCache`.

| Field                        | Type  | Description                                                                   |
| ---------------------------- | ----- | ----------------------------------------------------------------------------- |
| `daily_limit`                | `u32` | Maximum USD value that can be withdrawn per day via deleverage (0 = no limit) |
| `withdrawn_today`            | `u32` | USD value withdrawn today via deleverage (approximate, rounded)               |
| `last_daily_reset_timestamp` | `i64` | Unix timestamp of the last daily counter reset                                |

### `WrappedI80F48`

Struct `types::WrappedI80F48`.

| Field   | Type       |
| ------- | ---------- |
| `value` | `[u8; 16]` |

---

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