use {
crate::types::graphql::{AmmCreatorFeeOnGraphQL, VestingScheduleGraphQL},
carbon_core::graphql::primitives::{Pubkey, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "PoolState")]
pub struct PoolStateGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub epoch: U64,
pub auth_bump: U8,
pub status: U8,
pub base_decimals: U8,
pub quote_decimals: U8,
pub migrate_type: U8,
pub supply: U64,
pub total_base_sell: U64,
pub virtual_base: U64,
pub virtual_quote: U64,
pub real_base: U64,
pub real_quote: U64,
pub total_quote_fund_raising: U64,
pub quote_protocol_fee: U64,
pub platform_fee: U64,
pub migrate_fee: U64,
pub vesting_schedule: VestingScheduleGraphQL,
pub global_config: Pubkey,
pub platform_config: Pubkey,
pub base_mint: Pubkey,
pub quote_mint: Pubkey,
pub base_vault: Pubkey,
pub quote_vault: Pubkey,
pub creator: Pubkey,
pub token_program_flag: U8,
pub amm_creator_fee_on: AmmCreatorFeeOnGraphQL,
pub platform_vesting_share: U64,
pub padding: Vec<U8>,
}
impl TryFrom<crate::accounts::postgres::PoolStateRow> for PoolStateGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::PoolStateRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
epoch: carbon_core::graphql::primitives::U64(*row.epoch),
auth_bump: carbon_core::graphql::primitives::U8((*row.auth_bump) as u8),
status: carbon_core::graphql::primitives::U8((*row.status) as u8),
base_decimals: carbon_core::graphql::primitives::U8((*row.base_decimals) as u8),
quote_decimals: carbon_core::graphql::primitives::U8((*row.quote_decimals) as u8),
migrate_type: carbon_core::graphql::primitives::U8((*row.migrate_type) as u8),
supply: carbon_core::graphql::primitives::U64(*row.supply),
total_base_sell: carbon_core::graphql::primitives::U64(*row.total_base_sell),
virtual_base: carbon_core::graphql::primitives::U64(*row.virtual_base),
virtual_quote: carbon_core::graphql::primitives::U64(*row.virtual_quote),
real_base: carbon_core::graphql::primitives::U64(*row.real_base),
real_quote: carbon_core::graphql::primitives::U64(*row.real_quote),
total_quote_fund_raising: carbon_core::graphql::primitives::U64(
*row.total_quote_fund_raising,
),
quote_protocol_fee: carbon_core::graphql::primitives::U64(*row.quote_protocol_fee),
platform_fee: carbon_core::graphql::primitives::U64(*row.platform_fee),
migrate_fee: carbon_core::graphql::primitives::U64(*row.migrate_fee),
vesting_schedule: row.vesting_schedule.0.into(),
global_config: carbon_core::graphql::primitives::Pubkey(row.global_config.0),
platform_config: carbon_core::graphql::primitives::Pubkey(row.platform_config.0),
base_mint: carbon_core::graphql::primitives::Pubkey(row.base_mint.0),
quote_mint: carbon_core::graphql::primitives::Pubkey(row.quote_mint.0),
base_vault: carbon_core::graphql::primitives::Pubkey(row.base_vault.0),
quote_vault: carbon_core::graphql::primitives::Pubkey(row.quote_vault.0),
creator: carbon_core::graphql::primitives::Pubkey(row.creator.0),
token_program_flag: carbon_core::graphql::primitives::U8(
(*row.token_program_flag) as u8,
),
amm_creator_fee_on: row.amm_creator_fee_on.0.into(),
platform_vesting_share: carbon_core::graphql::primitives::U64(
*row.platform_vesting_share,
),
padding: row
.padding
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
})
}
}