use {
crate::types::graphql::UserFeesGraphQL,
carbon_core::graphql::primitives::{Pubkey, I64, U32, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "UserStats")]
pub struct UserStatsGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub authority: Pubkey,
pub referrer: Pubkey,
pub fees: UserFeesGraphQL,
pub next_epoch_ts: I64,
pub maker_volume30d: U64,
pub taker_volume30d: U64,
pub filler_volume30d: U64,
pub last_maker_volume30d_ts: I64,
pub last_taker_volume30d_ts: I64,
pub last_filler_volume30d_ts: I64,
pub if_staked_quote_asset_amount: U64,
pub number_of_sub_accounts: i32,
pub number_of_sub_accounts_created: i32,
pub referrer_status: U8,
pub disable_update_perp_bid_ask_twap: U8,
pub paused_operations: U8,
pub fuel_overflow_status: U8,
pub fuel_insurance: U32,
pub fuel_deposits: U32,
pub fuel_borrows: U32,
pub fuel_positions: U32,
pub fuel_taker: U32,
pub fuel_maker: U32,
pub if_staked_gov_token_amount: U64,
pub last_fuel_if_bonus_update_ts: U32,
pub padding: Vec<U8>,
}
impl TryFrom<crate::accounts::postgres::UserStatsRow> for UserStatsGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::UserStatsRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
authority: carbon_core::graphql::primitives::Pubkey(row.authority.0),
referrer: carbon_core::graphql::primitives::Pubkey(row.referrer.0),
fees: row.fees.0.into(),
next_epoch_ts: carbon_core::graphql::primitives::I64(row.next_epoch_ts),
maker_volume30d: carbon_core::graphql::primitives::U64(*row.maker_volume30d),
taker_volume30d: carbon_core::graphql::primitives::U64(*row.taker_volume30d),
filler_volume30d: carbon_core::graphql::primitives::U64(*row.filler_volume30d),
last_maker_volume30d_ts: carbon_core::graphql::primitives::I64(
row.last_maker_volume30d_ts,
),
last_taker_volume30d_ts: carbon_core::graphql::primitives::I64(
row.last_taker_volume30d_ts,
),
last_filler_volume30d_ts: carbon_core::graphql::primitives::I64(
row.last_filler_volume30d_ts,
),
if_staked_quote_asset_amount: carbon_core::graphql::primitives::U64(
*row.if_staked_quote_asset_amount,
),
number_of_sub_accounts: *row.number_of_sub_accounts,
number_of_sub_accounts_created: *row.number_of_sub_accounts_created,
referrer_status: carbon_core::graphql::primitives::U8((*row.referrer_status) as u8),
disable_update_perp_bid_ask_twap: carbon_core::graphql::primitives::U8(
(*row.disable_update_perp_bid_ask_twap) as u8,
),
paused_operations: carbon_core::graphql::primitives::U8((*row.paused_operations) as u8),
fuel_overflow_status: carbon_core::graphql::primitives::U8(
(*row.fuel_overflow_status) as u8,
),
fuel_insurance: carbon_core::graphql::primitives::U32((*row.fuel_insurance) as u32),
fuel_deposits: carbon_core::graphql::primitives::U32((*row.fuel_deposits) as u32),
fuel_borrows: carbon_core::graphql::primitives::U32((*row.fuel_borrows) as u32),
fuel_positions: carbon_core::graphql::primitives::U32((*row.fuel_positions) as u32),
fuel_taker: carbon_core::graphql::primitives::U32((*row.fuel_taker) as u32),
fuel_maker: carbon_core::graphql::primitives::U32((*row.fuel_maker) as u32),
if_staked_gov_token_amount: carbon_core::graphql::primitives::U64(
*row.if_staked_gov_token_amount,
),
last_fuel_if_bonus_update_ts: carbon_core::graphql::primitives::U32(
(*row.last_fuel_if_bonus_update_ts) as u32,
),
padding: row
.padding
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
})
}
}