carbon-boop-decoder 1.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "BondingCurve")]
pub struct BondingCurveGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub creator: Pubkey,
    pub mint: Pubkey,
    pub virtual_sol_reserves: U64,
    pub virtual_token_reserves: U64,
    pub graduation_target: U64,
    pub graduation_fee: U64,
    pub sol_reserves: U64,
    pub token_reserves: U64,
    pub damping_term: U8,
    pub swap_fee_basis_points: U8,
    pub token_for_stakers_basis_points: i32,
    pub status: BondingCurveStatusGraphQL,
}

impl TryFrom<crate::accounts::postgres::BondingCurveRow> for BondingCurveGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::BondingCurveRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            creator: carbon_core::graphql::primitives::Pubkey(row.creator.0),
            mint: carbon_core::graphql::primitives::Pubkey(row.mint.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),
            sol_reserves: carbon_core::graphql::primitives::U64(*row.sol_reserves),
            token_reserves: carbon_core::graphql::primitives::U64(*row.token_reserves),
            damping_term: carbon_core::graphql::primitives::U8((*row.damping_term) as u8),
            swap_fee_basis_points: carbon_core::graphql::primitives::U8(
                (*row.swap_fee_basis_points) as u8,
            ),
            token_for_stakers_basis_points: *row.token_for_stakers_basis_points,
            status: row.status.0.into(),
        })
    }
}