use {
crate::types::graphql::{PanicStateGraphQL, WrappedI80F48GraphQL},
carbon_core::graphql::primitives::{Pubkey, U32, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "FeeState")]
pub struct FeeStateGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub key: Pubkey,
pub global_fee_admin: Pubkey,
pub global_fee_wallet: Pubkey,
pub placeholder0: U64,
pub bank_init_flat_sol_fee: U32,
pub bump_seed: U8,
pub padding0: Vec<U8>,
pub liquidation_max_fee: WrappedI80F48GraphQL,
pub program_fee_fixed: WrappedI80F48GraphQL,
pub program_fee_rate: WrappedI80F48GraphQL,
pub panic_state: PanicStateGraphQL,
pub placeholder1: U64,
pub liquidation_flat_sol_fee: U32,
pub order_init_flat_sol_fee: U32,
pub order_execution_max_fee: WrappedI80F48GraphQL,
pub reserved1: Vec<U8>,
}
impl TryFrom<crate::accounts::postgres::FeeStateRow> for FeeStateGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::FeeStateRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
key: carbon_core::graphql::primitives::Pubkey(row.key.0),
global_fee_admin: carbon_core::graphql::primitives::Pubkey(row.global_fee_admin.0),
global_fee_wallet: carbon_core::graphql::primitives::Pubkey(row.global_fee_wallet.0),
placeholder0: carbon_core::graphql::primitives::U64(*row.placeholder0),
bank_init_flat_sol_fee: carbon_core::graphql::primitives::U32(
(*row.bank_init_flat_sol_fee) as u32,
),
bump_seed: carbon_core::graphql::primitives::U8((*row.bump_seed) as u8),
padding0: row
.padding0
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
liquidation_max_fee: row.liquidation_max_fee.0.into(),
program_fee_fixed: row.program_fee_fixed.0.into(),
program_fee_rate: row.program_fee_rate.0.into(),
panic_state: row.panic_state.0.into(),
placeholder1: carbon_core::graphql::primitives::U64(*row.placeholder1),
liquidation_flat_sol_fee: carbon_core::graphql::primitives::U32(
(*row.liquidation_flat_sol_fee) as u32,
),
order_init_flat_sol_fee: carbon_core::graphql::primitives::U32(
(*row.order_init_flat_sol_fee) as u32,
),
order_execution_max_fee: row.order_execution_max_fee.0.into(),
reserved1: row
.reserved1
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
})
}
}