carbon-orca-whirlpool-decoder 1.0.0

Orca Whirlpool Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::{AdaptiveFeeConstantsGraphQL, AdaptiveFeeVariablesGraphQL},
    carbon_core::graphql::primitives::{Pubkey, U64, U8},
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Oracle")]
pub struct OracleGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub whirlpool: Pubkey,
    pub trade_enable_timestamp: U64,
    pub adaptive_fee_constants: AdaptiveFeeConstantsGraphQL,
    pub adaptive_fee_variables: AdaptiveFeeVariablesGraphQL,
    pub reserved: Vec<U8>,
}

impl TryFrom<crate::accounts::postgres::OracleRow> for OracleGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::OracleRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            whirlpool: carbon_core::graphql::primitives::Pubkey(row.whirlpool.0),
            trade_enable_timestamp: carbon_core::graphql::primitives::U64(
                *row.trade_enable_timestamp,
            ),
            adaptive_fee_constants: row.adaptive_fee_constants.0.into(),
            adaptive_fee_variables: row.adaptive_fee_variables.0.into(),
            reserved: row
                .reserved
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
        })
    }
}