use {
carbon_core::graphql::primitives::{Pubkey, U128, U64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "UserSupplyPosition")]
pub struct UserSupplyPositionGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub protocol: Pubkey,
pub mint: Pubkey,
pub with_interest: U8,
pub amount: U64,
pub withdrawal_limit: U128,
pub last_update: U64,
pub expand_pct: i32,
pub expand_duration: U64,
pub base_withdrawal_limit: U64,
pub status: U8,
}
impl TryFrom<crate::accounts::postgres::UserSupplyPositionRow> for UserSupplyPositionGraphQL {
type Error = carbon_core::error::Error;
fn try_from(
row: crate::accounts::postgres::UserSupplyPositionRow,
) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
protocol: carbon_core::graphql::primitives::Pubkey(row.protocol.0),
mint: carbon_core::graphql::primitives::Pubkey(row.mint.0),
with_interest: carbon_core::graphql::primitives::U8((*row.with_interest) as u8),
amount: carbon_core::graphql::primitives::U64(*row.amount),
withdrawal_limit: carbon_core::graphql::primitives::U128(*row.withdrawal_limit),
last_update: carbon_core::graphql::primitives::U64(*row.last_update),
expand_pct: *row.expand_pct,
expand_duration: carbon_core::graphql::primitives::U64(*row.expand_duration),
base_withdrawal_limit: carbon_core::graphql::primitives::U64(
*row.base_withdrawal_limit,
),
status: carbon_core::graphql::primitives::U8((*row.status) as u8),
})
}
}