carbon-sharky-decoder 2.0.0

Sharky Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    carbon_core::graphql::primitives::{Pubkey, U32, U64, U8},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "TokenLendingOrderBook")]
pub struct TokenLendingOrderBookGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub fee_authority: Pubkey,
    pub loan_mint: Pubkey,
    pub collateral_mint: Pubkey,
    pub collateral_token_program: Pubkey,
    pub duration: U64,
    pub min_liquidity: U64,
    pub max_liquidity: U64,
    pub apr: U32,
    pub fee_permillicentage: i32,
    pub collateral_decimals: U8,
    pub version: U8,
    pub bump: U8,
    pub padding: Vec<U8>,
}

impl TryFrom<crate::accounts::postgres::TokenLendingOrderBookRow> for TokenLendingOrderBookGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(
        row: crate::accounts::postgres::TokenLendingOrderBookRow,
    ) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            fee_authority: carbon_core::graphql::primitives::Pubkey(row.fee_authority.0),
            loan_mint: carbon_core::graphql::primitives::Pubkey(row.loan_mint.0),
            collateral_mint: carbon_core::graphql::primitives::Pubkey(row.collateral_mint.0),
            collateral_token_program: carbon_core::graphql::primitives::Pubkey(
                row.collateral_token_program.0,
            ),
            duration: carbon_core::graphql::primitives::U64(*row.duration),
            min_liquidity: carbon_core::graphql::primitives::U64(*row.min_liquidity),
            max_liquidity: carbon_core::graphql::primitives::U64(*row.max_liquidity),
            apr: carbon_core::graphql::primitives::U32((*row.apr) as u32),
            fee_permillicentage: *row.fee_permillicentage,
            collateral_decimals: carbon_core::graphql::primitives::U8(
                (*row.collateral_decimals) as u8,
            ),
            version: carbon_core::graphql::primitives::U8((*row.version) as u8),
            bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
            padding: row
                .padding
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
        })
    }
}