use {
carbon_core::graphql::primitives::{Pubkey, U64},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "BondingCurve")]
pub struct BondingCurveGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub virtual_token_reserves: U64,
pub virtual_sol_reserves: U64,
pub real_token_reserves: U64,
pub real_sol_reserves: U64,
pub token_total_supply: U64,
pub complete: bool,
pub creator: Pubkey,
pub is_mayhem_mode: bool,
pub is_cashback_coin: bool,
}
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(),
virtual_token_reserves: carbon_core::graphql::primitives::U64(
*row.virtual_token_reserves,
),
virtual_sol_reserves: carbon_core::graphql::primitives::U64(*row.virtual_sol_reserves),
real_token_reserves: carbon_core::graphql::primitives::U64(*row.real_token_reserves),
real_sol_reserves: carbon_core::graphql::primitives::U64(*row.real_sol_reserves),
token_total_supply: carbon_core::graphql::primitives::U64(*row.token_total_supply),
complete: row.complete,
creator: carbon_core::graphql::primitives::Pubkey(row.creator.0),
is_mayhem_mode: row.is_mayhem_mode,
is_cashback_coin: row.is_cashback_coin,
})
}
}