carbon-boop-decoder 2.0.0

Boop program decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    carbon_core::graphql::primitives::{Pubkey, U64, U8},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Config")]
pub struct ConfigGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub is_paused: bool,
    pub authority: Pubkey,
    pub pending_authority: Pubkey,
    pub operators: Vec<Pubkey>,
    pub protocol_fee_recipient: Pubkey,
    pub token_distributor: Pubkey,
    pub virtual_sol_reserves: U64,
    pub virtual_token_reserves: U64,
    pub graduation_target: U64,
    pub graduation_fee: U64,
    pub damping_term: U8,
    pub token_for_stakers_basis_points: i32,
    pub swap_fee_basis_points: U8,
    pub token_amount_for_raydium_liquidity: U64,
    pub max_graduation_price_deviation_basis_points: i32,
    pub max_swap_amount_for_pool_price_correction_basis_points: i32,
}

impl TryFrom<crate::accounts::postgres::ConfigRow> for ConfigGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::ConfigRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            is_paused: row.is_paused,
            authority: carbon_core::graphql::primitives::Pubkey(row.authority.0),
            pending_authority: carbon_core::graphql::primitives::Pubkey(row.pending_authority.0),
            operators: row
                .operators
                .into_iter()
                .map(|item| carbon_core::graphql::primitives::Pubkey(item.0))
                .collect(),
            protocol_fee_recipient: carbon_core::graphql::primitives::Pubkey(
                row.protocol_fee_recipient.0,
            ),
            token_distributor: carbon_core::graphql::primitives::Pubkey(row.token_distributor.0),
            virtual_sol_reserves: carbon_core::graphql::primitives::U64(*row.virtual_sol_reserves),
            virtual_token_reserves: carbon_core::graphql::primitives::U64(
                *row.virtual_token_reserves,
            ),
            graduation_target: carbon_core::graphql::primitives::U64(*row.graduation_target),
            graduation_fee: carbon_core::graphql::primitives::U64(*row.graduation_fee),
            damping_term: carbon_core::graphql::primitives::U8((*row.damping_term) as u8),
            token_for_stakers_basis_points: *row.token_for_stakers_basis_points,
            swap_fee_basis_points: carbon_core::graphql::primitives::U8(
                (*row.swap_fee_basis_points) as u8,
            ),
            token_amount_for_raydium_liquidity: carbon_core::graphql::primitives::U64(
                *row.token_amount_for_raydium_liquidity,
            ),
            max_graduation_price_deviation_basis_points: *row
                .max_graduation_price_deviation_basis_points,
            max_swap_amount_for_pool_price_correction_basis_points: *row
                .max_swap_amount_for_pool_price_correction_basis_points,
        })
    }
}