firelaunch_io_firelaunch_client/generated/accounts/
curve.rs

1//! This code was AUTOGENERATED using the kinobi library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun kinobi to update it.
4//!
5//! <https://github.com/kinobi-so/kinobi>
6//!
7
8use crate::generated::types::FirelaunchCurveType;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11use solana_program::pubkey::Pubkey;
12
13#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
14#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15pub struct Curve {
16    pub discriminator: [u8; 8],
17    /// The bump used in generating the program derived address for this account.
18    pub bump: u8,
19    /// The public key of the token mint associated with this curve.
20    #[cfg_attr(
21        feature = "serde",
22        serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
23    )]
24    pub mint: Pubkey,
25    /// The public key of the curve's pool account.
26    #[cfg_attr(
27        feature = "serde",
28        serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
29    )]
30    pub curve_pool: Pubkey,
31    /// The public key of the curve's native pool account.
32    #[cfg_attr(
33        feature = "serde",
34        serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
35    )]
36    pub curve_native_pool: Pubkey,
37    /// The type of bonding curve and its parameters.
38    pub curve_type: FirelaunchCurveType,
39}
40
41impl Curve {
42    #[inline(always)]
43    pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
44        let mut data = data;
45        Self::deserialize(&mut data)
46    }
47}
48
49impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Curve {
50    type Error = std::io::Error;
51
52    fn try_from(
53        account_info: &solana_program::account_info::AccountInfo<'a>,
54    ) -> Result<Self, Self::Error> {
55        let mut data: &[u8] = &(*account_info.data).borrow();
56        Self::deserialize(&mut data)
57    }
58}
59
60#[cfg(feature = "anchor")]
61impl anchor_lang::AccountDeserialize for Curve {
62    fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
63        Ok(Self::deserialize(buf)?)
64    }
65}
66
67#[cfg(feature = "anchor")]
68impl anchor_lang::AccountSerialize for Curve {}
69
70#[cfg(feature = "anchor")]
71impl anchor_lang::Owner for Curve {
72    fn owner() -> Pubkey {
73        crate::FIRELAUNCH_ID
74    }
75}
76
77#[cfg(feature = "anchor-idl-build")]
78impl anchor_lang::IdlBuild for Curve {}
79
80#[cfg(feature = "anchor-idl-build")]
81impl anchor_lang::Discriminator for Curve {
82    const DISCRIMINATOR: [u8; 8] = [0; 8];
83}