use {
carbon_core::graphql::primitives::{Pubkey, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "UserLpPosition")]
pub struct UserLpPositionGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub pool: Pubkey,
pub user: Pubkey,
pub lp_token_balance: U64,
pub reward_debt: U64,
pub pending_fees: U64,
pub bump: U8,
}
impl TryFrom<crate::accounts::postgres::UserLpPositionRow> for UserLpPositionGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::UserLpPositionRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
pool: carbon_core::graphql::primitives::Pubkey(row.pool.0),
user: carbon_core::graphql::primitives::Pubkey(row.user.0),
lp_token_balance: carbon_core::graphql::primitives::U64(*row.lp_token_balance),
reward_debt: carbon_core::graphql::primitives::U64(*row.reward_debt),
pending_fees: carbon_core::graphql::primitives::U64(*row.pending_fees),
bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
})
}
}