carbon-meteora-vault-decoder 1.0.0

Meteora vault program decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
pub mod add_strategy_row;
pub mod collect_dust_row;
pub mod cpi_event_row;
pub mod deposit_row;
pub mod deposit_strategy_row;
pub mod enable_vault_row;
pub mod initialize_row;
pub mod initialize_strategy_row;
pub mod remove_strategy2_row;
pub mod remove_strategy_row;
pub mod set_operator_row;
pub mod withdraw2_row;
pub mod withdraw_directly_from_strategy_row;
pub mod withdraw_row;
pub mod withdraw_strategy_row;

pub use self::{
    add_strategy_row::*, collect_dust_row::*, cpi_event_row::*, deposit_row::*,
    deposit_strategy_row::*, enable_vault_row::*, initialize_row::*, initialize_strategy_row::*,
    remove_strategy2_row::*, remove_strategy_row::*, set_operator_row::*, withdraw2_row::*,
    withdraw_directly_from_strategy_row::*, withdraw_row::*, withdraw_strategy_row::*,
};
use super::MeteoraVaultInstruction;

pub struct MeteoraVaultInstructionsMigration;

impl sqlx_migrator::Migration<sqlx::Postgres> for MeteoraVaultInstructionsMigration {
    fn app(&self) -> &str {
        "meteora-vault"
    }

    fn name(&self) -> &str {
        "meteora_vault_instructions"
    }

    fn operations(&self) -> Vec<Box<dyn sqlx_migrator::Operation<sqlx::Postgres>>> {
        vec![
            Box::new(AddStrategyMigrationOperation),
            Box::new(CollectDustMigrationOperation),
            Box::new(DepositMigrationOperation),
            Box::new(DepositStrategyMigrationOperation),
            Box::new(EnableVaultMigrationOperation),
            Box::new(InitializeMigrationOperation),
            Box::new(InitializeStrategyMigrationOperation),
            Box::new(RemoveStrategyMigrationOperation),
            Box::new(RemoveStrategy2MigrationOperation),
            Box::new(SetOperatorMigrationOperation),
            Box::new(WithdrawMigrationOperation),
            Box::new(Withdraw2MigrationOperation),
            Box::new(WithdrawDirectlyFromStrategyMigrationOperation),
            Box::new(WithdrawStrategyMigrationOperation),
            Box::new(CpiEventMigrationOperation),
        ]
    }

    fn parents(&self) -> Vec<Box<dyn sqlx_migrator::Migration<sqlx::Postgres>>> {
        vec![]
    }
}

pub struct MeteoraVaultInstructionWithMetadata(
    pub MeteoraVaultInstruction,
    pub carbon_core::instruction::InstructionMetadata,
    pub Vec<solana_instruction::AccountMeta>,
);

impl
    From<(
        MeteoraVaultInstruction,
        carbon_core::instruction::InstructionMetadata,
        Vec<solana_instruction::AccountMeta>,
    )> for MeteoraVaultInstructionWithMetadata
{
    fn from(
        value: (
            MeteoraVaultInstruction,
            carbon_core::instruction::InstructionMetadata,
            Vec<solana_instruction::AccountMeta>,
        ),
    ) -> Self {
        MeteoraVaultInstructionWithMetadata(value.0, value.1, value.2)
    }
}

#[async_trait::async_trait]
impl carbon_core::postgres::operations::Insert for MeteoraVaultInstructionWithMetadata {
    async fn insert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
        let MeteoraVaultInstructionWithMetadata(decoded_instruction, metadata, raw_accounts) = self;
        match decoded_instruction {
            MeteoraVaultInstruction::Initialize { data, .. } => {
                let row = initialize_row::InitializeRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::EnableVault { data, .. } => {
                let row = enable_vault_row::EnableVaultRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::SetOperator { data, .. } => {
                let row = set_operator_row::SetOperatorRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::InitializeStrategy { data, .. } => {
                let row = initialize_strategy_row::InitializeStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::RemoveStrategy { data, .. } => {
                let row = remove_strategy_row::RemoveStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::RemoveStrategy2 { data, .. } => {
                let row = remove_strategy2_row::RemoveStrategy2Row::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::CollectDust { data, .. } => {
                let row = collect_dust_row::CollectDustRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::AddStrategy { data, .. } => {
                let row = add_strategy_row::AddStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::DepositStrategy { data, .. } => {
                let row = deposit_strategy_row::DepositStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::WithdrawStrategy { data, .. } => {
                let row = withdraw_strategy_row::WithdrawStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::Withdraw2 { data, .. } => {
                let row = withdraw2_row::Withdraw2Row::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::Deposit { data, .. } => {
                let row = deposit_row::DepositRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::Withdraw { data, .. } => {
                let row = withdraw_row::WithdrawRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::WithdrawDirectlyFromStrategy { data, .. } => {
                let row = withdraw_directly_from_strategy_row::WithdrawDirectlyFromStrategyRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
                row.insert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::CpiEvent { data, .. } => {
                let row = cpi_event_row::CpiEventRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.insert(pool).await?;
                Ok(())
            }
        }
    }
}

#[async_trait::async_trait]
impl carbon_core::postgres::operations::Upsert for MeteoraVaultInstructionWithMetadata {
    async fn upsert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
        let MeteoraVaultInstructionWithMetadata(decoded_instruction, metadata, raw_accounts) = self;
        match decoded_instruction {
            MeteoraVaultInstruction::Initialize { data, .. } => {
                let row = initialize_row::InitializeRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::EnableVault { data, .. } => {
                let row = enable_vault_row::EnableVaultRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::SetOperator { data, .. } => {
                let row = set_operator_row::SetOperatorRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::InitializeStrategy { data, .. } => {
                let row = initialize_strategy_row::InitializeStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::RemoveStrategy { data, .. } => {
                let row = remove_strategy_row::RemoveStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::RemoveStrategy2 { data, .. } => {
                let row = remove_strategy2_row::RemoveStrategy2Row::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::CollectDust { data, .. } => {
                let row = collect_dust_row::CollectDustRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::AddStrategy { data, .. } => {
                let row = add_strategy_row::AddStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::DepositStrategy { data, .. } => {
                let row = deposit_strategy_row::DepositStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::WithdrawStrategy { data, .. } => {
                let row = withdraw_strategy_row::WithdrawStrategyRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::Withdraw2 { data, .. } => {
                let row = withdraw2_row::Withdraw2Row::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::Deposit { data, .. } => {
                let row = deposit_row::DepositRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::Withdraw { data, .. } => {
                let row = withdraw_row::WithdrawRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::WithdrawDirectlyFromStrategy { data, .. } => {
                let row = withdraw_directly_from_strategy_row::WithdrawDirectlyFromStrategyRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
                row.upsert(pool).await?;
                Ok(())
            }
            MeteoraVaultInstruction::CpiEvent { data, .. } => {
                let row = cpi_event_row::CpiEventRow::from_parts(
                    data.clone(),
                    metadata.clone(),
                    raw_accounts.clone(),
                );
                row.upsert(pool).await?;
                Ok(())
            }
        }
    }
}