carbon-marginfi-v2-decoder 1.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Lending")]
pub struct LendingGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub mint: Pubkey,
    pub f_token_mint: Pubkey,
    pub lending_id: i32,
    pub decimals: U8,
    pub rewards_rate_model: Pubkey,
    pub liquidity_exchange_price: U64,
    pub token_exchange_price: U64,
    pub last_update_timestamp: U64,
    pub token_reserves_liquidity: Pubkey,
    pub supply_position_on_liquidity: Pubkey,
    pub bump: U8,
}

impl TryFrom<crate::accounts::postgres::LendingRow> for LendingGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::LendingRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            mint: carbon_core::graphql::primitives::Pubkey(row.mint.0),
            f_token_mint: carbon_core::graphql::primitives::Pubkey(row.f_token_mint.0),
            lending_id: *row.lending_id,
            decimals: carbon_core::graphql::primitives::U8((*row.decimals) as u8),
            rewards_rate_model: carbon_core::graphql::primitives::Pubkey(row.rewards_rate_model.0),
            liquidity_exchange_price: carbon_core::graphql::primitives::U64(
                *row.liquidity_exchange_price,
            ),
            token_exchange_price: carbon_core::graphql::primitives::U64(*row.token_exchange_price),
            last_update_timestamp: carbon_core::graphql::primitives::U64(
                *row.last_update_timestamp,
            ),
            token_reserves_liquidity: carbon_core::graphql::primitives::Pubkey(
                row.token_reserves_liquidity.0,
            ),
            supply_position_on_liquidity: carbon_core::graphql::primitives::Pubkey(
                row.supply_position_on_liquidity.0,
            ),
            bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
        })
    }
}