carbon-marginfi-v2-decoder 1.0.0

MarginfiV2 Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
pub mod config_group_fee_schema;
pub mod configure_bank_rate_limits_schema;
pub mod configure_deleverage_withdrawal_limit_schema;
pub mod configure_group_rate_limits_schema;
pub mod cpi_event_schema;
pub mod drift_deposit_schema;
pub mod drift_harvest_reward_schema;
pub mod drift_init_user_schema;
pub mod drift_withdraw_schema;
pub mod edit_global_fee_state_schema;
pub mod edit_staked_settings_schema;
pub mod end_deleverage_schema;
pub mod end_liquidation_schema;
pub mod init_bank_metadata_schema;
pub mod init_global_fee_state_schema;
pub mod init_staked_settings_schema;
pub mod juplend_deposit_schema;
pub mod juplend_init_position_schema;
pub mod juplend_withdraw_schema;
pub mod kamino_deposit_schema;
pub mod kamino_harvest_reward_schema;
pub mod kamino_init_obligation_schema;
pub mod kamino_withdraw_schema;
pub mod lending_account_borrow_schema;
pub mod lending_account_clear_emissions_schema;
pub mod lending_account_close_balance_schema;
pub mod lending_account_deposit_schema;
pub mod lending_account_end_flashloan_schema;
pub mod lending_account_liquidate_schema;
pub mod lending_account_pulse_health_schema;
pub mod lending_account_repay_schema;
pub mod lending_account_start_flashloan_schema;
pub mod lending_account_withdraw_schema;
pub mod lending_pool_accrue_bank_interest_schema;
pub mod lending_pool_add_bank_drift_schema;
pub mod lending_pool_add_bank_juplend_schema;
pub mod lending_pool_add_bank_kamino_schema;
pub mod lending_pool_add_bank_permissionless_schema;
pub mod lending_pool_add_bank_schema;
pub mod lending_pool_add_bank_solend_schema;
pub mod lending_pool_add_bank_with_seed_schema;
pub mod lending_pool_clone_bank_schema;
pub mod lending_pool_clone_emode_schema;
pub mod lending_pool_close_bank_schema;
pub mod lending_pool_collect_bank_fees_schema;
pub mod lending_pool_configure_bank_emode_schema;
pub mod lending_pool_configure_bank_interest_only_schema;
pub mod lending_pool_configure_bank_limits_only_schema;
pub mod lending_pool_configure_bank_oracle_schema;
pub mod lending_pool_configure_bank_schema;
pub mod lending_pool_force_tokenless_repay_complete_schema;
pub mod lending_pool_handle_bankruptcy_schema;
pub mod lending_pool_pulse_bank_price_cache_schema;
pub mod lending_pool_reclaim_emissions_vault_schema;
pub mod lending_pool_set_fixed_oracle_price_schema;
pub mod lending_pool_update_fees_destination_account_schema;
pub mod lending_pool_withdraw_fees_permissionless_schema;
pub mod lending_pool_withdraw_fees_schema;
pub mod lending_pool_withdraw_insurance_schema;
pub mod marginfi_account_close_order_schema;
pub mod marginfi_account_close_schema;
pub mod marginfi_account_end_execute_order_schema;
pub mod marginfi_account_init_liq_record_schema;
pub mod marginfi_account_initialize_pda_schema;
pub mod marginfi_account_initialize_schema;
pub mod marginfi_account_keeper_close_order_schema;
pub mod marginfi_account_place_order_schema;
pub mod marginfi_account_set_freeze_schema;
pub mod marginfi_account_set_keeper_close_flags_schema;
pub mod marginfi_account_start_execute_order_schema;
pub mod marginfi_account_update_emissions_destination_account_schema;
pub mod marginfi_group_configure_schema;
pub mod marginfi_group_initialize_schema;
pub mod migrate_curve_schema;
pub mod panic_pause_schema;
pub mod panic_unpause_permissionless_schema;
pub mod panic_unpause_schema;
pub mod propagate_fee_state_schema;
pub mod propagate_staked_settings_schema;
pub mod purge_deleverage_balance_schema;
pub mod solend_deposit_schema;
pub mod solend_init_obligation_schema;
pub mod solend_withdraw_schema;
pub mod start_deleverage_schema;
pub mod start_liquidation_schema;
pub mod super_admin_deposit_schema;
pub mod super_admin_withdraw_schema;
pub mod transfer_to_new_account_pda_schema;
pub mod transfer_to_new_account_schema;
pub mod update_deleverage_withdrawals_schema;
pub mod update_group_rate_limiter_schema;
pub mod write_bank_metadata_schema;

use juniper::GraphQLObject;
pub use {
    config_group_fee_schema::*, configure_bank_rate_limits_schema::*,
    configure_deleverage_withdrawal_limit_schema::*, configure_group_rate_limits_schema::*,
    cpi_event_schema::*, drift_deposit_schema::*, drift_harvest_reward_schema::*,
    drift_init_user_schema::*, drift_withdraw_schema::*, edit_global_fee_state_schema::*,
    edit_staked_settings_schema::*, end_deleverage_schema::*, end_liquidation_schema::*,
    init_bank_metadata_schema::*, init_global_fee_state_schema::*, init_staked_settings_schema::*,
    juplend_deposit_schema::*, juplend_init_position_schema::*, juplend_withdraw_schema::*,
    kamino_deposit_schema::*, kamino_harvest_reward_schema::*, kamino_init_obligation_schema::*,
    kamino_withdraw_schema::*, lending_account_borrow_schema::*,
    lending_account_clear_emissions_schema::*, lending_account_close_balance_schema::*,
    lending_account_deposit_schema::*, lending_account_end_flashloan_schema::*,
    lending_account_liquidate_schema::*, lending_account_pulse_health_schema::*,
    lending_account_repay_schema::*, lending_account_start_flashloan_schema::*,
    lending_account_withdraw_schema::*, lending_pool_accrue_bank_interest_schema::*,
    lending_pool_add_bank_drift_schema::*, lending_pool_add_bank_juplend_schema::*,
    lending_pool_add_bank_kamino_schema::*, lending_pool_add_bank_permissionless_schema::*,
    lending_pool_add_bank_schema::*, lending_pool_add_bank_solend_schema::*,
    lending_pool_add_bank_with_seed_schema::*, lending_pool_clone_bank_schema::*,
    lending_pool_clone_emode_schema::*, lending_pool_close_bank_schema::*,
    lending_pool_collect_bank_fees_schema::*, lending_pool_configure_bank_emode_schema::*,
    lending_pool_configure_bank_interest_only_schema::*,
    lending_pool_configure_bank_limits_only_schema::*,
    lending_pool_configure_bank_oracle_schema::*, lending_pool_configure_bank_schema::*,
    lending_pool_force_tokenless_repay_complete_schema::*,
    lending_pool_handle_bankruptcy_schema::*, lending_pool_pulse_bank_price_cache_schema::*,
    lending_pool_reclaim_emissions_vault_schema::*, lending_pool_set_fixed_oracle_price_schema::*,
    lending_pool_update_fees_destination_account_schema::*,
    lending_pool_withdraw_fees_permissionless_schema::*, lending_pool_withdraw_fees_schema::*,
    lending_pool_withdraw_insurance_schema::*, marginfi_account_close_order_schema::*,
    marginfi_account_close_schema::*, marginfi_account_end_execute_order_schema::*,
    marginfi_account_init_liq_record_schema::*, marginfi_account_initialize_pda_schema::*,
    marginfi_account_initialize_schema::*, marginfi_account_keeper_close_order_schema::*,
    marginfi_account_place_order_schema::*, marginfi_account_set_freeze_schema::*,
    marginfi_account_set_keeper_close_flags_schema::*,
    marginfi_account_start_execute_order_schema::*,
    marginfi_account_update_emissions_destination_account_schema::*,
    marginfi_group_configure_schema::*, marginfi_group_initialize_schema::*,
    migrate_curve_schema::*, panic_pause_schema::*, panic_unpause_permissionless_schema::*,
    panic_unpause_schema::*, propagate_fee_state_schema::*, propagate_staked_settings_schema::*,
    purge_deleverage_balance_schema::*, solend_deposit_schema::*, solend_init_obligation_schema::*,
    solend_withdraw_schema::*, start_deleverage_schema::*, start_liquidation_schema::*,
    super_admin_deposit_schema::*, super_admin_withdraw_schema::*,
    transfer_to_new_account_pda_schema::*, transfer_to_new_account_schema::*,
    update_deleverage_withdrawals_schema::*, update_group_rate_limiter_schema::*,
    write_bank_metadata_schema::*,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "InstructionMetadata")]
pub struct InstructionMetadataGraphQL {
    pub signature: String,
    pub instruction_index: carbon_core::graphql::primitives::U32,
    pub stack_height: carbon_core::graphql::primitives::U32,
    pub slot: Option<carbon_core::graphql::primitives::U64>,
}

impl From<carbon_core::postgres::metadata::InstructionRowMetadata> for InstructionMetadataGraphQL {
    fn from(metadata: carbon_core::postgres::metadata::InstructionRowMetadata) -> Self {
        Self {
            signature: metadata.signature,
            instruction_index: carbon_core::graphql::primitives::U32(
                (*metadata.instruction_index) as u32,
            ),
            stack_height: carbon_core::graphql::primitives::U32((*metadata.stack_height) as u32),
            slot: metadata
                .slot
                .map(|v| carbon_core::graphql::primitives::U64(*v)),
        }
    }
}