# Sharky decoder (Carbon 2.0)

> Decode Sharky instructions and accounts in Rust with carbon-sharky-decoder 2.0.0. Program ID SHARKobtfF1bHhxD2eqftjHBdVSCbKo9JtgK71FhELP.

`carbon-sharky-decoder` decodes the instructions and accounts of the Sharky program (`SHARKobtfF1bHhxD2eqftjHBdVSCbKo9JtgK71FhELP`): 35 instructions, 9 account types. 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-sharky-decoder`](https://crates.io/crates/carbon-sharky-decoder/2.0.0) 2.0.0                 |
| Install          | `cargo add carbon-sharky-decoder@2.0.0`                                                               |
| Program ID       | `SHARKobtfF1bHhxD2eqftjHBdVSCbKo9JtgK71FhELP` (`carbon_sharky_decoder::PROGRAM_ID`)                   |
| Category         | [Lending](https://carbon.sevenlabs.org/decoders/lending.md)                                           |
| Decoder          | `carbon_sharky_decoder::SharkyDecoder`                                                                |
| Instruction enum | `instructions::SharkyInstruction`                                                                     |
| Account enum     | `accounts::SharkyAccount`                                                                             |
| Features         | `serde`, `postgres`, `graphql` (none enabled by default)                                              |
| API docs         | [docs.rs/carbon-sharky-decoder/2.0.0](https://docs.rs/carbon-sharky-decoder/2.0.0)                    |
| Source           | [decoders/sharky-decoder](https://github.com/sevenlabs-hq/carbon/tree/v2.0.0/decoders/sharky-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), [marginfi v2](https://carbon.sevenlabs.org/decoders/marginfi-v2.md), [Meteora Vault](https://carbon.sevenlabs.org/decoders/meteora-vault.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 Sharky transactions from the public RPC and prints every decoded `AddLiquidityTokenPool` instruction. Add the dependencies:

```sh
cargo add carbon-core@2.0.0 carbon-sharky-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_sharky_decoder::{instructions::SharkyInstruction, SharkyDecoder, 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(SharkyDecoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

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

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

Each `AddLiquidityTokenPool` instruction prints one line with the transaction signature and the decoded `AddLiquidityTokenPool` 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.

### 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 `EscrowPDA` 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_sharky_decoder::{accounts::SharkyAccount, SharkyDecoder, 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(SharkyDecoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

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

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

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

### `AddLiquidityTokenPool`

Discriminator `e7ca2b0a7bc476ac` · data `AddLiquidityTokenPool` · accounts `AddLiquidityTokenPoolInstructionAccounts`.

| Field         | Type  |
| ------------- | ----- |
| `usdc_amount` | `u64` |

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

Fields of `AddLiquidityTokenPoolInstructionAccounts`, in account order:

| #  | Field           | Type               |
| -- | --------------- | ------------------ |
| 0  | `orderbook`     | `Pubkey`           |
| 1  | `pool`          | `Pubkey`           |
| 2  | `usdc_vault`    | `Pubkey`           |
| 3  | `lender`        | `Pubkey`           |
| 4  | `lender_usdc`   | `Pubkey`           |
| 5  | `loan_mint`     | `Pubkey`           |
| 6  | `token_program` | `Pubkey`           |
| 7… | `remaining`     | `Vec<AccountMeta>` |

### `CloseEscrowValueMintAtaAdmin`

Discriminator `04860129a8f8dd1c` · data `CloseEscrowValueMintAtaAdmin` · accounts `CloseEscrowValueMintAtaAdminInstructionAccounts`.

| Field         | Type |
| ------------- | ---- |
| `escrow_bump` | `u8` |

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

Fields of `CloseEscrowValueMintAtaAdminInstructionAccounts`, in account order:

| #  | Field                             | Type               |
| -- | --------------------------------- | ------------------ |
| 0  | `loan`                            | `Pubkey`           |
| 1  | `lender`                          | `Pubkey`           |
| 2  | `escrow`                          | `Pubkey`           |
| 3  | `escrow_value_mint_token_account` | `Pubkey`           |
| 4  | `admin`                           | `Pubkey`           |
| 5  | `system_program`                  | `Pubkey`           |
| 6  | `token_program`                   | `Pubkey`           |
| 7  | `associated_token_program`        | `Pubkey`           |
| 8… | `remaining`                       | `Vec<AccountMeta>` |

### `CloseNftList`

Discriminator `23087952da4efca2` · data `CloseNftList` · accounts `CloseNftListInstructionAccounts`.

No data fields.

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

Fields of `CloseNftListInstructionAccounts`, in account order:

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

### `CloseOrderBook`

> _From the program's IDL:_
>
> Closes an order book, must be signed by sharky key

Discriminator `db8649dbb4075ece` · data `CloseOrderBook` · accounts `CloseOrderBookInstructionAccounts`.

No data fields.

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

Fields of `CloseOrderBookInstructionAccounts`, in account order:

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

### `CloseTokenOrderbook`

Discriminator `e304e16dcfeb476a` · data `CloseTokenOrderbook` · accounts `CloseTokenOrderbookInstructionAccounts`.

No data fields.

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

Fields of `CloseTokenOrderbookInstructionAccounts`, in account order:

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

### `CloseTokenPool`

Discriminator `02fb3604f2c8ae8f` · data `CloseTokenPool` · accounts `CloseTokenPoolInstructionAccounts`.

No data fields.

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

Fields of `CloseTokenPoolInstructionAccounts`, in account order:

| #   | Field               | Type               |
| --- | ------------------- | ------------------ |
| 0   | `orderbook`         | `Pubkey`           |
| 1   | `pool`              | `Pubkey`           |
| 2   | `usdc_vault`        | `Pubkey`           |
| 3   | `collateral_vault`  | `Pubkey`           |
| 4   | `lender`            | `Pubkey`           |
| 5   | `lender_usdc`       | `Pubkey`           |
| 6   | `lender_collateral` | `Pubkey`           |
| 7   | `loan_mint`         | `Pubkey`           |
| 8   | `collateral_mint`   | `Pubkey`           |
| 9   | `token_program`     | `Pubkey`           |
| 10… | `remaining`         | `Vec<AccountMeta>` |

### `CreateNftList`

Discriminator `f326c64cac407f18` · data `CreateNftList` · accounts `CreateNftListInstructionAccounts`.

| Field             | Type     |
| ----------------- | -------- |
| `collection_name` | `String` |

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

Fields of `CreateNftListInstructionAccounts`, in account order:

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

### `CreateOrderBook`

> _From the program's IDL:_
>
> Creates an order book, must be signed by sharky key

Discriminator `997209336444f0c5` · data `CreateOrderBook` · accounts `CreateOrderBookInstructionAccounts`.

| Field                 | Type                              |
| --------------------- | --------------------------------- |
| `order_book_type`     | [`OrderBookType`](#orderbooktype) |
| `apy`                 | [`APY`](#apy)                     |
| `loan_terms`          | [`BookLoanTerms`](#bookloanterms) |
| `fee_permillicentage` | `u16`                             |
| `fee_authority`       | `Pubkey`                          |

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

Fields of `CreateOrderBookInstructionAccounts`, in account order:

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

### `CreateProgramVersion`

Discriminator `67d800ee5c6bdb79` · data `CreateProgramVersion` · accounts `CreateProgramVersionInstructionAccounts`.

| Field     | Type |
| --------- | ---- |
| `version` | `u8` |

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

Fields of `CreateProgramVersionInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `authority`       | `Pubkey`           |
| 1  | `program_version` | `Pubkey`           |
| 2  | `system_program`  | `Pubkey`           |
| 3  | `rent`            | `Pubkey`           |
| 4… | `remaining`       | `Vec<AccountMeta>` |

### `CreateTokenOrderbook`

Discriminator `88965e5dd4a2ded6` · data `CreateTokenOrderbook` · accounts `CreateTokenOrderbookInstructionAccounts`.

| Field                 | Type          |
| --------------------- | ------------- |
| `duration`            | `u64`         |
| `apr`                 | `u32`         |
| `fee_permillicentage` | `u16`         |
| `fee_authority`       | `Pubkey`      |
| `min_liquidity`       | `Option<u64>` |
| `max_liquidity`       | `Option<u64>` |

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

Fields of `CreateTokenOrderbookInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `orderbook`       | `Pubkey`           |
| 1  | `loan_mint`       | `Pubkey`           |
| 2  | `collateral_mint` | `Pubkey`           |
| 3  | `authority`       | `Pubkey`           |
| 4  | `system_program`  | `Pubkey`           |
| 5… | `remaining`       | `Vec<AccountMeta>` |

### `CreateTokenPool`

Discriminator `17a91b7a93a9d198` · data `CreateTokenPool` · accounts `CreateTokenPoolInstructionAccounts`.

| Field                        | Type  |
| ---------------------------- | ----- |
| `nonce`                      | `u64` |
| `initial_usdc_liquidity`     | `u64` |
| `required_collateral_amount` | `u64` |

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

Fields of `CreateTokenPoolInstructionAccounts`, in account order:

| #   | Field              | Type               |
| --- | ------------------ | ------------------ |
| 0   | `orderbook`        | `Pubkey`           |
| 1   | `pool`             | `Pubkey`           |
| 2   | `usdc_vault`       | `Pubkey`           |
| 3   | `collateral_vault` | `Pubkey`           |
| 4   | `lender`           | `Pubkey`           |
| 5   | `lender_usdc_ata`  | `Pubkey`           |
| 6   | `loan_mint`        | `Pubkey`           |
| 7   | `collateral_mint`  | `Pubkey`           |
| 8   | `token_program`    | `Pubkey`           |
| 9   | `system_program`   | `Pubkey`           |
| 10… | `remaining`        | `Vec<AccountMeta>` |

### `ExtendLoanCore`

> _From the program's IDL:_
>
> Extend a loan with a new loan (core)

Discriminator `8de35be5c626964f` · data `ExtendLoanCore` · accounts `ExtendLoanCoreInstructionAccounts`.

| Field           | Type     |
| --------------- | -------- |
| `expected_loan` | `String` |

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

Fields of `ExtendLoanCoreInstructionAccounts`, in account order:

| #   | Field              | Type               |
| --- | ------------------ | ------------------ |
| 0   | `loan`             | `Pubkey`           |
| 1   | `new_loan`         | `Pubkey`           |
| 2   | `borrower`         | `Pubkey`           |
| 3   | `lender`           | `Pubkey`           |
| 4   | `new_lender`       | `Pubkey`           |
| 5   | `escrow`           | `Pubkey`           |
| 6   | `new_escrow`       | `Pubkey`           |
| 7   | `value_mint`       | `Pubkey`           |
| 8   | `collateral_mint`  | `Pubkey`           |
| 9   | `collection`       | `Option<Pubkey>`   |
| 10  | `order_book`       | `Pubkey`           |
| 11  | `fee_authority`    | `Pubkey`           |
| 12  | `system_program`   | `Pubkey`           |
| 13  | `rent`             | `Pubkey`           |
| 14  | `log_wrapper`      | `Option<Pubkey>`   |
| 15  | `mpl_core_program` | `Pubkey`           |
| 16… | `remaining`        | `Vec<AccountMeta>` |

### `ExtendLoanV3`

Discriminator `471b11834e493e5c` · data `ExtendLoanV3` · accounts `ExtendLoanV3InstructionAccounts`.

| Field           | Type     |
| --------------- | -------- |
| `expected_loan` | `String` |

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

Fields of `ExtendLoanV3InstructionAccounts`, in account order:

| #   | Field                                 | Type               |
| --- | ------------------------------------- | ------------------ |
| 0   | `loan`                                | `Pubkey`           |
| 1   | `new_loan`                            | `Pubkey`           |
| 2   | `borrower`                            | `Pubkey`           |
| 3   | `borrower_collateral_token_account`   | `Pubkey`           |
| 4   | `lender`                              | `Pubkey`           |
| 5   | `new_lender`                          | `Pubkey`           |
| 6   | `escrow`                              | `Pubkey`           |
| 7   | `escrow_collateral_token_account`     | `Pubkey`           |
| 8   | `new_escrow`                          | `Pubkey`           |
| 9   | `new_escrow_collateral_token_account` | `Pubkey`           |
| 10  | `value_mint`                          | `Pubkey`           |
| 11  | `collateral_mint`                     | `Pubkey`           |
| 12  | `order_book`                          | `Pubkey`           |
| 13  | `fee_authority`                       | `Pubkey`           |
| 14  | `metadata`                            | `Pubkey`           |
| 15  | `edition`                             | `Pubkey`           |
| 16  | `system_program`                      | `Pubkey`           |
| 17  | `token_program`                       | `Pubkey`           |
| 18  | `associated_token_program`            | `Pubkey`           |
| 19  | `rent`                                | `Pubkey`           |
| 20  | `mpl_token_metadata_program`          | `Pubkey`           |
| 21… | `remaining`                           | `Vec<AccountMeta>` |

### `ExtendLoanV3Compressed`

> _From the program's IDL:_
>
> Extend a loan with a new loan (cNFT)

Discriminator `94a14b578a22833e` · data `ExtendLoanV3Compressed` · accounts `ExtendLoanV3CompressedInstructionAccounts`.

| Field               | Type       |
| ------------------- | ---------- |
| `expected_loan`     | `String`   |
| `cnft_root`         | `[u8; 32]` |
| `cnft_data_hash`    | `[u8; 32]` |
| `cnft_creator_hash` | `[u8; 32]` |
| `cnft_nonce`        | `u64`      |
| `cnft_index`        | `u32`      |

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

Fields of `ExtendLoanV3CompressedInstructionAccounts`, in account order:

| #   | Field                   | Type               |
| --- | ----------------------- | ------------------ |
| 0   | `loan`                  | `Pubkey`           |
| 1   | `new_loan`              | `Pubkey`           |
| 2   | `borrower`              | `Pubkey`           |
| 3   | `lender`                | `Pubkey`           |
| 4   | `new_lender`            | `Pubkey`           |
| 5   | `escrow`                | `Pubkey`           |
| 6   | `new_escrow`            | `Pubkey`           |
| 7   | `value_mint`            | `Pubkey`           |
| 8   | `order_book`            | `Pubkey`           |
| 9   | `fee_authority`         | `Pubkey`           |
| 10  | `tree_authority`        | `Pubkey`           |
| 11  | `log_wrapper`           | `Pubkey`           |
| 12  | `merkle_tree`           | `Pubkey`           |
| 13  | `system_program`        | `Pubkey`           |
| 14  | `token_program`         | `Pubkey`           |
| 15  | `mpl_bubblegum_program` | `Pubkey`           |
| 16  | `compression_program`   | `Pubkey`           |
| 17  | `rent`                  | `Pubkey`           |
| 18… | `remaining`             | `Vec<AccountMeta>` |

### `ExtendTokenLoan`

Discriminator `39213d664656a482` · data `ExtendTokenLoan` · accounts `ExtendTokenLoanInstructionAccounts`.

| Field               | Type     |
| ------------------- | -------- |
| `new_usdc_amount`   | `u64`    |
| `expected_new_loan` | `String` |

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

Fields of `ExtendTokenLoanInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `orderbook`                | `Pubkey`           |
| 1   | `old_loan`                 | `Pubkey`           |
| 2   | `new_loan`                 | `Pubkey`           |
| 3   | `old_pool`                 | `Pubkey`           |
| 4   | `new_pool`                 | `Pubkey`           |
| 5   | `old_lender_usdc`          | `Pubkey`           |
| 6   | `old_collateral_vault`     | `Pubkey`           |
| 7   | `new_usdc_vault`           | `Pubkey`           |
| 8   | `new_collateral_vault`     | `Pubkey`           |
| 9   | `borrower`                 | `Pubkey`           |
| 10  | `borrower_usdc`            | `Pubkey`           |
| 11  | `borrower_collateral`      | `Pubkey`           |
| 12  | `loan_mint`                | `Pubkey`           |
| 13  | `collateral_mint`          | `Pubkey`           |
| 14  | `fee_authority`            | `Pubkey`           |
| 15  | `burn_wallet`              | `Pubkey`           |
| 16  | `price_update`             | `Pubkey`           |
| 17  | `token_program`            | `Pubkey`           |
| 18  | `associated_token_program` | `Pubkey`           |
| 19  | `system_program`           | `Pubkey`           |
| 20… | `remaining`                | `Vec<AccountMeta>` |

### `ForecloseLoanCore`

> _From the program's IDL:_
>
> Forecloses on a taken lone that has met some condition (core)

Discriminator `cf235493770ec385` · data `ForecloseLoanCore` · accounts `ForecloseLoanCoreInstructionAccounts`.

No data fields.

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

Fields of `ForecloseLoanCoreInstructionAccounts`, in account order:

| #   | Field              | Type               |
| --- | ------------------ | ------------------ |
| 0   | `loan`             | `Pubkey`           |
| 1   | `escrow`           | `Pubkey`           |
| 2   | `collateral_mint`  | `Pubkey`           |
| 3   | `collection`       | `Option<Pubkey>`   |
| 4   | `borrower`         | `Pubkey`           |
| 5   | `lender`           | `Pubkey`           |
| 6   | `system_program`   | `Pubkey`           |
| 7   | `rent`             | `Pubkey`           |
| 8   | `log_wrapper`      | `Option<Pubkey>`   |
| 9   | `mpl_core_program` | `Pubkey`           |
| 10… | `remaining`        | `Vec<AccountMeta>` |

### `ForecloseLoanV3`

> _From the program's IDL:_
>
> Forecloses on a taken lone that has met some condition

Discriminator `88b8323ab75c3fd8` · data `ForecloseLoanV3` · accounts `ForecloseLoanV3InstructionAccounts`.

No data fields.

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

Fields of `ForecloseLoanV3InstructionAccounts`, in account order:

| #   | Field                               | Type               |
| --- | ----------------------------------- | ------------------ |
| 0   | `loan`                              | `Pubkey`           |
| 1   | `escrow`                            | `Pubkey`           |
| 2   | `escrow_collateral_token_account`   | `Pubkey`           |
| 3   | `collateral_mint`                   | `Pubkey`           |
| 4   | `borrower`                          | `Pubkey`           |
| 5   | `lender`                            | `Pubkey`           |
| 6   | `lender_collateral_token_account`   | `Pubkey`           |
| 7   | `borrower_collateral_token_account` | `Pubkey`           |
| 8   | `metadata`                          | `Pubkey`           |
| 9   | `edition`                           | `Pubkey`           |
| 10  | `system_program`                    | `Pubkey`           |
| 11  | `token_program`                     | `Pubkey`           |
| 12  | `associated_token_program`          | `Pubkey`           |
| 13  | `rent`                              | `Pubkey`           |
| 14  | `mpl_token_metadata_program`        | `Pubkey`           |
| 15… | `remaining`                         | `Vec<AccountMeta>` |

### `ForecloseLoanV3Compressed`

> _From the program's IDL:_
>
> Forecloses on a taken lone that has met some condition (cNFT)

Discriminator `c2c105c17385e7c5` · data `ForecloseLoanV3Compressed` · accounts `ForecloseLoanV3CompressedInstructionAccounts`.

| Field               | Type       |
| ------------------- | ---------- |
| `cnft_root`         | `[u8; 32]` |
| `cnft_data_hash`    | `[u8; 32]` |
| `cnft_creator_hash` | `[u8; 32]` |
| `cnft_nonce`        | `u64`      |
| `cnft_index`        | `u32`      |

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

Fields of `ForecloseLoanV3CompressedInstructionAccounts`, in account order:

| #   | Field                   | Type               |
| --- | ----------------------- | ------------------ |
| 0   | `loan`                  | `Pubkey`           |
| 1   | `escrow`                | `Pubkey`           |
| 2   | `borrower`              | `Pubkey`           |
| 3   | `lender`                | `Pubkey`           |
| 4   | `tree_authority`        | `Pubkey`           |
| 5   | `log_wrapper`           | `Pubkey`           |
| 6   | `merkle_tree`           | `Pubkey`           |
| 7   | `system_program`        | `Pubkey`           |
| 8   | `token_program`         | `Pubkey`           |
| 9   | `mpl_bubblegum_program` | `Pubkey`           |
| 10  | `compression_program`   | `Pubkey`           |
| 11  | `rent`                  | `Pubkey`           |
| 12… | `remaining`             | `Vec<AccountMeta>` |

### `ForecloseTokenLoan`

Discriminator `c538e1490be8211e` · data `ForecloseTokenLoan` · accounts `ForecloseTokenLoanInstructionAccounts`.

No data fields.

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

Fields of `ForecloseTokenLoanInstructionAccounts`, in account order:

| #   | Field                   | Type               |
| --- | ----------------------- | ------------------ |
| 0   | `orderbook`             | `Pubkey`           |
| 1   | `loan`                  | `Pubkey`           |
| 2   | `borrower`              | `Pubkey`           |
| 3   | `pool`                  | `Pubkey`           |
| 4   | `lender`                | `Pubkey`           |
| 5   | `lender_collateral_ata` | `Pubkey`           |
| 6   | `collateral_vault`      | `Pubkey`           |
| 7   | `loan_mint`             | `Pubkey`           |
| 8   | `collateral_mint`       | `Pubkey`           |
| 9   | `token_program`         | `Pubkey`           |
| 10… | `remaining`             | `Vec<AccountMeta>` |

### `OfferLoan`

> _From the program's IDL:_
>
> Offers a loan for a given order book

Discriminator `2c0c4c90d2d0ef55` · data `OfferLoan` · accounts `OfferLoanInstructionAccounts`.

| Field                | Type                                      |
| -------------------- | ----------------------------------------- |
| `escrow_bump`        | `u8`                                      |
| `principal_lamports` | `u64`                                     |
| `terms_choice`       | [`Option<LoanTermsSpec>`](#loantermsspec) |

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

Fields of `OfferLoanInstructionAccounts`, in account order:

| #   | Field                        | Type               |
| --- | ---------------------------- | ------------------ |
| 0   | `lender`                     | `Pubkey`           |
| 1   | `lender_value_token_account` | `Pubkey`           |
| 2   | `value_mint`                 | `Pubkey`           |
| 3   | `loan`                       | `Pubkey`           |
| 4   | `escrow`                     | `Pubkey`           |
| 5   | `escrow_token_account`       | `Pubkey`           |
| 6   | `order_book`                 | `Pubkey`           |
| 7   | `system_program`             | `Pubkey`           |
| 8   | `token_program`              | `Pubkey`           |
| 9   | `associated_token_program`   | `Pubkey`           |
| 10  | `rent`                       | `Pubkey`           |
| 11… | `remaining`                  | `Vec<AccountMeta>` |

### `RepayLoanCore`

> _From the program's IDL:_
>
> Repays a given loan in exchange for the NFT (core)

Discriminator `f084bad66543d78c` · data `RepayLoanCore` · accounts `RepayLoanCoreInstructionAccounts`.

No data fields.

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

Fields of `RepayLoanCoreInstructionAccounts`, in account order:

| #   | Field              | Type               |
| --- | ------------------ | ------------------ |
| 0   | `loan`             | `Pubkey`           |
| 1   | `borrower`         | `Pubkey`           |
| 2   | `lender`           | `Pubkey`           |
| 3   | `escrow`           | `Pubkey`           |
| 4   | `value_mint`       | `Pubkey`           |
| 5   | `collateral_mint`  | `Pubkey`           |
| 6   | `collection`       | `Option<Pubkey>`   |
| 7   | `order_book`       | `Pubkey`           |
| 8   | `fee_authority`    | `Pubkey`           |
| 9   | `system_program`   | `Pubkey`           |
| 10  | `rent`             | `Pubkey`           |
| 11  | `log_wrapper`      | `Option<Pubkey>`   |
| 12  | `mpl_core_program` | `Pubkey`           |
| 13… | `remaining`        | `Vec<AccountMeta>` |

### `RepayLoanV3`

> _From the program's IDL:_
>
> Repays a given loan in exchange for the NFT

Discriminator `617b55364c103d9d` · data `RepayLoanV3` · accounts `RepayLoanV3InstructionAccounts`.

No data fields.

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

Fields of `RepayLoanV3InstructionAccounts`, in account order:

| #   | Field                               | Type               |
| --- | ----------------------------------- | ------------------ |
| 0   | `loan`                              | `Pubkey`           |
| 1   | `borrower`                          | `Pubkey`           |
| 2   | `borrower_collateral_token_account` | `Pubkey`           |
| 3   | `lender`                            | `Pubkey`           |
| 4   | `escrow`                            | `Pubkey`           |
| 5   | `escrow_collateral_token_account`   | `Pubkey`           |
| 6   | `value_mint`                        | `Pubkey`           |
| 7   | `collateral_mint`                   | `Pubkey`           |
| 8   | `order_book`                        | `Pubkey`           |
| 9   | `fee_authority`                     | `Pubkey`           |
| 10  | `metadata`                          | `Pubkey`           |
| 11  | `edition`                           | `Pubkey`           |
| 12  | `system_program`                    | `Pubkey`           |
| 13  | `token_program`                     | `Pubkey`           |
| 14  | `associated_token_program`          | `Pubkey`           |
| 15  | `rent`                              | `Pubkey`           |
| 16  | `mpl_token_metadata_program`        | `Pubkey`           |
| 17… | `remaining`                         | `Vec<AccountMeta>` |

### `RepayLoanV3Compressed`

> _From the program's IDL:_
>
> Repays a given loan in exchange for the NFT (cNFT)

Discriminator `9f9ff5a8bf9a6406` · data `RepayLoanV3Compressed` · accounts `RepayLoanV3CompressedInstructionAccounts`.

| Field               | Type       |
| ------------------- | ---------- |
| `cnft_root`         | `[u8; 32]` |
| `cnft_data_hash`    | `[u8; 32]` |
| `cnft_creator_hash` | `[u8; 32]` |
| `cnft_nonce`        | `u64`      |
| `cnft_index`        | `u32`      |

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

Fields of `RepayLoanV3CompressedInstructionAccounts`, in account order:

| #   | Field                   | Type               |
| --- | ----------------------- | ------------------ |
| 0   | `loan`                  | `Pubkey`           |
| 1   | `borrower`              | `Pubkey`           |
| 2   | `lender`                | `Pubkey`           |
| 3   | `escrow`                | `Pubkey`           |
| 4   | `value_mint`            | `Pubkey`           |
| 5   | `order_book`            | `Pubkey`           |
| 6   | `fee_authority`         | `Pubkey`           |
| 7   | `tree_authority`        | `Pubkey`           |
| 8   | `log_wrapper`           | `Pubkey`           |
| 9   | `merkle_tree`           | `Pubkey`           |
| 10  | `system_program`        | `Pubkey`           |
| 11  | `token_program`         | `Pubkey`           |
| 12  | `mpl_bubblegum_program` | `Pubkey`           |
| 13  | `compression_program`   | `Pubkey`           |
| 14  | `rent`                  | `Pubkey`           |
| 15… | `remaining`             | `Vec<AccountMeta>` |

### `RepayTokenLoan`

Discriminator `d032d027bd9919fb` · data `RepayTokenLoan` · accounts `RepayTokenLoanInstructionAccounts`.

No data fields.

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

Fields of `RepayTokenLoanInstructionAccounts`, in account order:

| #   | Field                      | Type               |
| --- | -------------------------- | ------------------ |
| 0   | `orderbook`                | `Pubkey`           |
| 1   | `loan`                     | `Pubkey`           |
| 2   | `pool`                     | `Pubkey`           |
| 3   | `lender_usdc`              | `Pubkey`           |
| 4   | `collateral_vault`         | `Pubkey`           |
| 5   | `borrower`                 | `Pubkey`           |
| 6   | `borrower_usdc`            | `Pubkey`           |
| 7   | `borrower_collateral`      | `Pubkey`           |
| 8   | `loan_mint`                | `Pubkey`           |
| 9   | `collateral_mint`          | `Pubkey`           |
| 10  | `token_program`            | `Pubkey`           |
| 11  | `associated_token_program` | `Pubkey`           |
| 12  | `system_program`           | `Pubkey`           |
| 13… | `remaining`                | `Vec<AccountMeta>` |

### `RescindLoan`

> _From the program's IDL:_
>
> Removes an offered but not taken loan

Discriminator `4040a0d33324b19e` · data `RescindLoan` · accounts `RescindLoanInstructionAccounts`.

No data fields.

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

Fields of `RescindLoanInstructionAccounts`, in account order:

| #  | Field                        | Type               |
| -- | ---------------------------- | ------------------ |
| 0  | `loan`                       | `Pubkey`           |
| 1  | `lender_value_token_account` | `Option<Pubkey>`   |
| 2  | `lender`                     | `Pubkey`           |
| 3  | `value_mint`                 | `Pubkey`           |
| 4  | `escrow`                     | `Pubkey`           |
| 5  | `escrow_token_account`       | `Pubkey`           |
| 6  | `system_program`             | `Pubkey`           |
| 7  | `token_program`              | `Pubkey`           |
| 8… | `remaining`                  | `Vec<AccountMeta>` |

### `TakeLoanCore`

> _From the program's IDL:_
>
> Takes an offered loan in exchange for a valid NFT (core)

Discriminator `b26fec3c9f6ceafe` · data `TakeLoanCore` · accounts `TakeLoanCoreInstructionAccounts`.

| Field            | Type          |
| ---------------- | ------------- |
| `expected_loan`  | `String`      |
| `nft_list_index` | `Option<u32>` |

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

Fields of `TakeLoanCoreInstructionAccounts`, in account order:

| #   | Field              | Type               |
| --- | ------------------ | ------------------ |
| 0   | `lender`           | `Pubkey`           |
| 1   | `borrower`         | `Pubkey`           |
| 2   | `collateral_mint`  | `Pubkey`           |
| 3   | `collection`       | `Option<Pubkey>`   |
| 4   | `loan`             | `Pubkey`           |
| 5   | `escrow`           | `Pubkey`           |
| 6   | `order_book`       | `Pubkey`           |
| 7   | `system_program`   | `Pubkey`           |
| 8   | `rent`             | `Pubkey`           |
| 9   | `log_wrapper`      | `Option<Pubkey>`   |
| 10  | `mpl_core_program` | `Pubkey`           |
| 11… | `remaining`        | `Vec<AccountMeta>` |

### `TakeLoanV3`

> _From the program's IDL:_
>
> Takes an offered loan in exchange for a valid NFT (migration off cardinal)

Discriminator `ff73dc3a1a9d70b9` · data `TakeLoanV3` · accounts `TakeLoanV3InstructionAccounts`.

| Field                      | Type          |
| -------------------------- | ------------- |
| `expected_loan`            | `String`      |
| `nft_list_index`           | `Option<u32>` |
| `skip_freezing_collateral` | `bool`        |

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

Fields of `TakeLoanV3InstructionAccounts`, in account order:

| #   | Field                               | Type               |
| --- | ----------------------------------- | ------------------ |
| 0   | `lender`                            | `Pubkey`           |
| 1   | `borrower`                          | `Pubkey`           |
| 2   | `borrower_collateral_token_account` | `Pubkey`           |
| 3   | `collateral_mint`                   | `Pubkey`           |
| 4   | `loan`                              | `Pubkey`           |
| 5   | `escrow`                            | `Pubkey`           |
| 6   | `escrow_collateral_token_account`   | `Pubkey`           |
| 7   | `order_book`                        | `Pubkey`           |
| 8   | `metadata`                          | `Pubkey`           |
| 9   | `edition`                           | `Pubkey`           |
| 10  | `system_program`                    | `Pubkey`           |
| 11  | `token_program`                     | `Pubkey`           |
| 12  | `associated_token_program`          | `Pubkey`           |
| 13  | `rent`                              | `Pubkey`           |
| 14  | `mpl_token_metadata_program`        | `Pubkey`           |
| 15… | `remaining`                         | `Vec<AccountMeta>` |

### `TakeLoanV3Compressed`

> _From the program's IDL:_
>
> Takes an offered loan in exchange for a valid NFT (cNFT)

Discriminator `f1726a4f1059e97d` · data `TakeLoanV3Compressed` · accounts `TakeLoanV3CompressedInstructionAccounts`.

| Field            | Type                    |
| ---------------- | ----------------------- |
| `expected_loan`  | `String`                |
| `nft_list_index` | `Option<u32>`           |
| `cnft_args`      | [`CnftArgs`](#cnftargs) |

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

Fields of `TakeLoanV3CompressedInstructionAccounts`, in account order:

| #   | Field                   | Type               |
| --- | ----------------------- | ------------------ |
| 0   | `lender`                | `Pubkey`           |
| 1   | `borrower`              | `Pubkey`           |
| 2   | `loan`                  | `Pubkey`           |
| 3   | `escrow`                | `Pubkey`           |
| 4   | `order_book`            | `Pubkey`           |
| 5   | `collateral_mint`       | `Pubkey`           |
| 6   | `tree_authority`        | `Pubkey`           |
| 7   | `log_wrapper`           | `Pubkey`           |
| 8   | `merkle_tree`           | `Pubkey`           |
| 9   | `system_program`        | `Pubkey`           |
| 10  | `token_program`         | `Pubkey`           |
| 11  | `mpl_bubblegum_program` | `Pubkey`           |
| 12  | `compression_program`   | `Pubkey`           |
| 13  | `rent`                  | `Pubkey`           |
| 14… | `remaining`             | `Vec<AccountMeta>` |

### `TakeTokenLoan`

Discriminator `ddd87f0a6bbd986f` · data `TakeTokenLoan` · accounts `TakeTokenLoanInstructionAccounts`.

| Field           | Type     |
| --------------- | -------- |
| `usdc_amount`   | `u64`    |
| `expected_loan` | `String` |

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

Fields of `TakeTokenLoanInstructionAccounts`, in account order:

| #   | Field                 | Type               |
| --- | --------------------- | ------------------ |
| 0   | `orderbook`           | `Pubkey`           |
| 1   | `loan`                | `Pubkey`           |
| 2   | `pool`                | `Pubkey`           |
| 3   | `usdc_vault`          | `Pubkey`           |
| 4   | `collateral_vault`    | `Pubkey`           |
| 5   | `borrower`            | `Pubkey`           |
| 6   | `borrower_usdc`       | `Pubkey`           |
| 7   | `borrower_collateral` | `Pubkey`           |
| 8   | `fee_authority`       | `Pubkey`           |
| 9   | `burn_wallet`         | `Pubkey`           |
| 10  | `price_update`        | `Pubkey`           |
| 11  | `loan_mint`           | `Pubkey`           |
| 12  | `collateral_mint`     | `Pubkey`           |
| 13  | `token_program`       | `Pubkey`           |
| 14  | `system_program`      | `Pubkey`           |
| 15… | `remaining`           | `Vec<AccountMeta>` |

### `UpdateNftList`

Discriminator `d70d19bb0b5d228f` · data `UpdateNftList` · accounts `UpdateNftListInstructionAccounts`.

| Field   | Type                               |
| ------- | ---------------------------------- |
| `mints` | [`Vec<UpdateIndex>`](#updateindex) |

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

Fields of `UpdateNftListInstructionAccounts`, in account order:

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

### `UpdateOrderBook`

> _From the program's IDL:_
>
> Updates an order book, must be signed by sharky key

Discriminator `1f489fe8dc995a6d` · data `UpdateOrderBook` · accounts `UpdateOrderBookInstructionAccounts`.

| Field                 | Type                                      |
| --------------------- | ----------------------------------------- |
| `order_book_type`     | [`Option<OrderBookType>`](#orderbooktype) |
| `apy`                 | [`Option<APY>`](#apy)                     |
| `loan_terms`          | [`Option<BookLoanTerms>`](#bookloanterms) |
| `fee_permillicentage` | `Option<u16>`                             |
| `fee_authority`       | `Option<Pubkey>`                          |

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

Fields of `UpdateOrderBookInstructionAccounts`, in account order:

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

### `UpdateProgramVersion`

Discriminator `eb84d7e1d52b2b26` · data `UpdateProgramVersion` · accounts `UpdateProgramVersionInstructionAccounts`.

| Field     | Type |
| --------- | ---- |
| `version` | `u8` |

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

Fields of `UpdateProgramVersionInstructionAccounts`, in account order:

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

### `UpdateTokenOrderbook`

Discriminator `13f883459602298f` · data `UpdateTokenOrderbook` · accounts `UpdateTokenOrderbookInstructionAccounts`.

| Field                 | Type             |
| --------------------- | ---------------- |
| `duration`            | `Option<u64>`    |
| `apr`                 | `Option<u32>`    |
| `fee_permillicentage` | `Option<u16>`    |
| `fee_authority`       | `Option<Pubkey>` |
| `min_liquidity`       | `Option<u64>`    |
| `max_liquidity`       | `Option<u64>`    |

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

Fields of `UpdateTokenOrderbookInstructionAccounts`, in account order:

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

### `UpdateTokenPool`

Discriminator `e11cb50ddc401f66` · data `UpdateTokenPool` · accounts `UpdateTokenPoolInstructionAccounts`.

| Field                            | Type  |
| -------------------------------- | ----- |
| `new_required_collateral_amount` | `u64` |

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

Fields of `UpdateTokenPoolInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `orderbook` | `Pubkey`           |
| 1  | `pool`      | `Pubkey`           |
| 2  | `lender`    | `Pubkey`           |
| 3… | `remaining` | `Vec<AccountMeta>` |

### `WithdrawLiquidityTokenPool`

Discriminator `3767142327b7b440` · data `WithdrawLiquidityTokenPool` · accounts `WithdrawLiquidityTokenPoolInstructionAccounts`.

No data fields.

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

Fields of `WithdrawLiquidityTokenPoolInstructionAccounts`, in account order:

| #  | Field           | Type               |
| -- | --------------- | ------------------ |
| 0  | `orderbook`     | `Pubkey`           |
| 1  | `pool`          | `Pubkey`           |
| 2  | `usdc_vault`    | `Pubkey`           |
| 3  | `lender`        | `Pubkey`           |
| 4  | `lender_usdc`   | `Pubkey`           |
| 5  | `loan_mint`     | `Pubkey`           |
| 6  | `token_program` | `Pubkey`           |
| 7… | `remaining`     | `Vec<AccountMeta>` |

## Accounts

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

### `EscrowPDA`

Discriminator `6d7589b5403041eb` · `accounts::escrow_p_d_a::EscrowPDA`.

| Field  | Type |
| ------ | ---- |
| `bump` | `u8` |

### `Loan`

Discriminator `14c34675a5e3b601` · `accounts::loan::Loan`.

| Field                | Type                      | Description                                      |
| -------------------- | ------------------------- | ------------------------------------------------ |
| `version`            | `u8`                      |                                                  |
| `principal_lamports` | `u64`                     | amount in tokens, decimals included              |
| `order_book`         | `Pubkey`                  |                                                  |
| `value_token_mint`   | `Pubkey`                  | Token mint for what the loan is in (spl address) |
| `escrow_bump_seed`   | `u8`                      |                                                  |
| `loan_state`         | [`LoanState`](#loanstate) | stores start and duration                        |

### `NFTList`

Discriminator `2ef468e29823aaef` · `accounts::n_f_t_list::NFTList`.

| Field             | Type     |
| ----------------- | -------- |
| `version`         | `u8`     |
| `collection_name` | `String` |

### `OrderBook`

Discriminator `37e67dda952741f8` · `accounts::order_book::OrderBook`.

| Field                 | Type                              |
| --------------------- | --------------------------------- |
| `version`             | `u8`                              |
| `order_book_type`     | [`OrderBookType`](#orderbooktype) |
| `apy`                 | [`APY`](#apy)                     |
| `loan_terms`          | [`BookLoanTerms`](#bookloanterms) |
| `fee_permillicentage` | `u16`                             |
| `fee_authority`       | `Pubkey`                          |

### `PriceUpdateV2`

Discriminator `22f123639d7ef4cd` · `accounts::price_update_v2::PriceUpdateV2`.

| Field                | Type                                      |
| -------------------- | ----------------------------------------- |
| `write_authority`    | `Pubkey`                                  |
| `verification_level` | [`VerificationLevel`](#verificationlevel) |
| `price_message`      | [`PriceFeedMessage`](#pricefeedmessage)   |
| `posted_slot`        | `u64`                                     |

### `ProgramVersion`

Discriminator `8a68f4c5ce2f9f9a` · `accounts::program_version::ProgramVersion`.

| Field     | Type  |
| --------- | ----- |
| `version` | `u8`  |
| `bump`    | `u8`  |
| `updated` | `i64` |

### `TokenLendingLoan`

Discriminator `30fa85552a0b2d9a` · `accounts::token_lending_loan::TokenLendingLoan`.

| Field                        | Type      |
| ---------------------------- | --------- |
| `orderbook`                  | `Pubkey`  |
| `borrower`                   | `Pubkey`  |
| `pool`                       | `Pubkey`  |
| `principal_usdc_amount`      | `u64`     |
| `collateral_required_amount` | `u64`     |
| `start_ts`                   | `i64`     |
| `end_ts`                     | `i64`     |
| `apr`                        | `u32`     |
| `version`                    | `u8`      |
| `padding`                    | `[u8; 3]` |

### `TokenLendingOrderBook`

Discriminator `c0475ca36355271b` · `accounts::token_lending_order_book::TokenLendingOrderBook`.

| Field                      | Type      |
| -------------------------- | --------- |
| `fee_authority`            | `Pubkey`  |
| `loan_mint`                | `Pubkey`  |
| `collateral_mint`          | `Pubkey`  |
| `collateral_token_program` | `Pubkey`  |
| `duration`                 | `u64`     |
| `min_liquidity`            | `u64`     |
| `max_liquidity`            | `u64`     |
| `apr`                      | `u32`     |
| `fee_permillicentage`      | `u16`     |
| `collateral_decimals`      | `u8`      |
| `version`                  | `u8`      |
| `bump`                     | `u8`      |
| `padding`                  | `[u8; 7]` |

### `TokenLendingPool`

Discriminator `213b0d8799697f92` · `accounts::token_lending_pool::TokenLendingPool`.

| Field                               | Type      |
| ----------------------------------- | --------- |
| `orderbook`                         | `Pubkey`  |
| `lender`                            | `Pubkey`  |
| `usdc_vault`                        | `Pubkey`  |
| `collateral_vault`                  | `Pubkey`  |
| `nonce`                             | `u64`     |
| `total_usdc_liquidity`              | `u64`     |
| `available_usdc_liquidity`          | `u64`     |
| `collateral_required_amount`        | `u64`     |
| `total_usdc_interest`               | `u64`     |
| `total_loan_count`                  | `u64`     |
| `active_loan_count`                 | `u64`     |
| `total_defaulted_loan_count`        | `u64`     |
| `total_defaulted_usdc_amount`       | `u64`     |
| `total_defaulted_collateral_amount` | `u64`     |
| `version`                           | `u8`      |
| `bump`                              | `u8`      |
| `padding`                           | `[u8; 6]` |

## Types

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

### `APY`

> _From the program's IDL:_
>
> APY settings on an \[`OrderBook`]

Enum `types::APY`.

| Variant | Fields       |
| ------- | ------------ |
| `Fixed` | `apy`: `u32` |

`Fixed` fields:

| Field | Type  | Description              |
| ----- | ----- | ------------------------ |
| `apy` | `u32` | Thousandths of a percent |

### `BookLoanTerms`

Enum `types::BookLoanTerms`.

| Variant         | Fields                                     |
| --------------- | ------------------------------------------ |
| `Fixed`         | `terms`: [`LoanTermsSpec`](#loantermsspec) |
| `LenderChooses` |                                            |

### `CnftArgs`

Struct `types::CnftArgs`.

| Field               | Type       |
| ------------------- | ---------- |
| `cnft_root`         | `[u8; 32]` |
| `cnft_data_hash`    | `[u8; 32]` |
| `cnft_creator_hash` | `[u8; 32]` |
| `cnft_nonce`        | `u64`      |
| `cnft_index`        | `u32`      |

### `LoanOffer`

Struct `types::LoanOffer`.

| Field           | Type                              |
| --------------- | --------------------------------- |
| `lender_wallet` | `Pubkey`                          |
| `terms_spec`    | [`LoanTermsSpec`](#loantermsspec) |
| `offer_time`    | `i64`                             |

### `LoanState`

Enum `types::LoanState`.

| Variant | Fields                             |
| ------- | ---------------------------------- |
| `Offer` | `offer`: [`LoanOffer`](#loanoffer) |
| `Taken` | `taken`: [`TakenLoan`](#takenloan) |

### `LoanTerms`

Enum `types::LoanTerms`.

| Variant | Fields                                                          |
| ------- | --------------------------------------------------------------- |
| `Time`  | `start`: `i64`, `duration`: `u64`, `total_owed_lamports`: `u64` |

`Time` fields:

| Field                 | Type  | Description                  |
| --------------------- | ----- | ---------------------------- |
| `start`               | `i64` | This is a \[`UnixTimeStamp`] |
| `duration`            | `u64` |                              |
| `total_owed_lamports` | `u64` |                              |

### `LoanTermsSpec`

Enum `types::LoanTermsSpec`.

| Variant | Fields            |
| ------- | ----------------- |
| `Time`  | `duration`: `u64` |

### `OrderBookType`

Enum `types::OrderBookType`.

| Variant      | Fields                     |
| ------------ | -------------------------- |
| `Collection` | `collection_key`: `Pubkey` |
| `NFTList`    | `list_account`: `Pubkey`   |

### `PriceFeedMessage`

Struct `types::PriceFeedMessage`.

| Field               | Type       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `feed_id`           | `[u8; 32]` | `FeedId` but avoid the type alias because of compatibility issues with Anchor's `idl-build` feature.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `price`             | `i64`      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `conf`              | `u64`      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `exponent`          | `i32`      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `publish_time`      | `i64`      | The timestamp of this price update in seconds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `prev_publish_time` | `i64`      | The timestamp of the previous price update. This field is intended to allow users to identify the single unique price update for any moment in time: for any time t, the unique update is the one such that prev_publish_time < t <= publish_time. Note that there may not be such an update while we are migrating to the new message-sending logic, as some price updates on pythnet may not be sent to other chains (because the message-sending logic may not have triggered). We can solve this problem by making the message-sending mandatory (which we can do once publishers have migrated over). Additionally, this field may be equal to publish_time if the message is sent on a slot where where the aggregation was unsuccesful. This problem will go away once all publishers have migrated over to a recent version of pyth-agent. |
| `ema_price`         | `i64`      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `ema_conf`          | `u64`      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |

### `TakenLoan`

Struct `types::TakenLoan`.

| Field                  | Type                      | Description                                                             |
| ---------------------- | ------------------------- | ----------------------------------------------------------------------- |
| `nft_collateral_mint`  | `Pubkey`                  |                                                                         |
| `lender_note_mint`     | `Pubkey`                  |                                                                         |
| `borrower_note_mint`   | `Pubkey`                  |                                                                         |
| `apy`                  | [`APY`](#apy)             | Thousandths of a percent (allows to have 3 decimal points of precision) |
| `terms`                | [`LoanTerms`](#loanterms) |                                                                         |
| `is_collateral_frozen` | `u8`                      |                                                                         |

### `UpdateIndex`

Struct `types::UpdateIndex`.

| Field   | Type     |
| ------- | -------- |
| `index` | `u32`    |
| `mint`  | `Pubkey` |

### `VerificationLevel`

> _From the program's IDL:_
>
> Pyth price updates are bridged to all blockchains via Wormhole.\
> Using the price updates on another chain requires verifying the signatures of the Wormhole guardians. The usual process is to check the signatures for two thirds of the total number of guardians, but this can be cumbersome on\
> Solana because of the transaction size limits, so we also allow for partial verification. This enum represents how much a price update has been verified:
>
> - If `Full`, we have verified the signatures for two thirds of the current guardians.
> - If `Partial`, only `num_signatures` guardian signatures have been checked.
>
> **Warning**
>
> Using partially verified price updates is dangerous, as it lowers the threshold of guardians that need to collude to produce a malicious price update.

Enum `types::VerificationLevel`.

| Variant   | Fields                 |
| --------- | ---------------------- |
| `Partial` | `num_signatures`: `u8` |
| `Full`    |                        |

---

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