carbon-jupiter-dca-decoder 2.0.0

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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Dca")]
pub struct DcaGraphQL {
    pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
    pub user: Pubkey,
    pub input_mint: Pubkey,
    pub output_mint: Pubkey,
    pub idx: U64,
    pub next_cycle_at: I64,
    pub in_deposited: U64,
    pub in_withdrawn: U64,
    pub out_withdrawn: U64,
    pub in_used: U64,
    pub out_received: U64,
    pub in_amount_per_cycle: U64,
    pub cycle_frequency: I64,
    pub next_cycle_amount_left: U64,
    pub in_account: Pubkey,
    pub out_account: Pubkey,
    pub min_out_amount: U64,
    pub max_out_amount: U64,
    pub keeper_in_balance_before_borrow: U64,
    pub dca_out_balance_before_swap: U64,
    pub created_at: I64,
    pub bump: U8,
}

impl TryFrom<crate::accounts::postgres::DcaRow> for DcaGraphQL {
    type Error = carbon_core::error::Error;
    fn try_from(row: crate::accounts::postgres::DcaRow) -> Result<Self, Self::Error> {
        Ok(Self {
            account_metadata: row.account_metadata.into(),
            user: carbon_core::graphql::primitives::Pubkey(row.user.0),
            input_mint: carbon_core::graphql::primitives::Pubkey(row.input_mint.0),
            output_mint: carbon_core::graphql::primitives::Pubkey(row.output_mint.0),
            idx: carbon_core::graphql::primitives::U64(*row.idx),
            next_cycle_at: carbon_core::graphql::primitives::I64(row.next_cycle_at),
            in_deposited: carbon_core::graphql::primitives::U64(*row.in_deposited),
            in_withdrawn: carbon_core::graphql::primitives::U64(*row.in_withdrawn),
            out_withdrawn: carbon_core::graphql::primitives::U64(*row.out_withdrawn),
            in_used: carbon_core::graphql::primitives::U64(*row.in_used),
            out_received: carbon_core::graphql::primitives::U64(*row.out_received),
            in_amount_per_cycle: carbon_core::graphql::primitives::U64(*row.in_amount_per_cycle),
            cycle_frequency: carbon_core::graphql::primitives::I64(row.cycle_frequency),
            next_cycle_amount_left: carbon_core::graphql::primitives::U64(
                *row.next_cycle_amount_left,
            ),
            in_account: carbon_core::graphql::primitives::Pubkey(row.in_account.0),
            out_account: carbon_core::graphql::primitives::Pubkey(row.out_account.0),
            min_out_amount: carbon_core::graphql::primitives::U64(*row.min_out_amount),
            max_out_amount: carbon_core::graphql::primitives::U64(*row.max_out_amount),
            keeper_in_balance_before_borrow: carbon_core::graphql::primitives::U64(
                *row.keeper_in_balance_before_borrow,
            ),
            dca_out_balance_before_swap: carbon_core::graphql::primitives::U64(
                *row.dca_out_balance_before_swap,
            ),
            created_at: carbon_core::graphql::primitives::I64(row.created_at),
            bump: carbon_core::graphql::primitives::U8((*row.bump) as u8),
        })
    }
}