carbon-drift-v2-decoder 2.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "PrelaunchOracle")]
pub struct PrelaunchOracleGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub price: I64,
    pub max_price: I64,
    pub confidence: U64,
    pub last_update_slot: U64,
    pub amm_last_update_slot: U64,
    pub perp_market_index: i32,
    pub padding: Vec<U8>,
}

impl TryFrom<crate::accounts::postgres::PrelaunchOracleRow> for PrelaunchOracleGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::PrelaunchOracleRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            price: carbon_core::graphql::primitives::I64(row.price),
            max_price: carbon_core::graphql::primitives::I64(row.max_price),
            confidence: carbon_core::graphql::primitives::U64(*row.confidence),
            last_update_slot: carbon_core::graphql::primitives::U64(*row.last_update_slot),
            amm_last_update_slot: carbon_core::graphql::primitives::U64(*row.amm_last_update_slot),
            perp_market_index: *row.perp_market_index,
            padding: row
                .padding
                .into_iter()
                .map(carbon_core::graphql::primitives::U8)
                .collect(),
        })
    }
}