Skip to main content

sendfun_sdk/dex/generated/events/
pool_create_event.rs

1#![allow(
2	clippy::all,
3	clippy::pedantic,
4	clippy::nursery,
5	clippy::expect_used,
6	clippy::unwrap_used,
7	clippy::indexing_slicing,
8	clippy::allow_attributes,
9	clippy::allow_attributes_without_reason,
10	clippy::mem_forget,
11	unfulfilled_lint_expectations,
12	unexpected_cfgs,
13	unused_imports
14)]
15
16//! This code was AUTOGENERATED using the codama library.
17//! Please DO NOT EDIT THIS FILE, instead use visitors
18//! to add features, then rerun codama to update it.
19//!
20//! <https://github.com/codama-idl/codama>
21//!
22
23use crate::dex::generated::events::ANCHOR_EVENT_CPI_DISCRIMINATOR;
24use borsh::BorshDeserialize;
25use borsh::BorshSerialize;
26use solana_address::Address;
27
28#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
29#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
30#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
31pub struct PoolCreateEvent {
32	#[cfg_attr(
33		feature = "serde",
34		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
35	)]
36	pub pool: Address,
37	#[cfg_attr(
38		feature = "serde",
39		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
40	)]
41	pub base_mint: Address,
42	pub base_decimals: u8,
43	#[cfg_attr(
44		feature = "serde",
45		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
46	)]
47	pub quote_mint: Address,
48	pub quote_decimals: u8,
49	#[cfg_attr(
50		feature = "serde",
51		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
52	)]
53	pub coin_creator: Address,
54	#[cfg_attr(
55		feature = "serde",
56		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
57	)]
58	pub creator_fee_config: Address,
59	#[cfg_attr(
60		feature = "serde",
61		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
62	)]
63	pub platform_config: Address,
64	#[cfg_attr(
65		feature = "serde",
66		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
67	)]
68	pub base_vault: Address,
69	#[cfg_attr(
70		feature = "serde",
71		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
72	)]
73	pub quote_vault: Address,
74	#[cfg_attr(
75		feature = "serde",
76		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
77	)]
78	pub lp_mint: Address,
79	#[cfg_attr(
80		feature = "serde",
81		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
82	)]
83	pub lp_minted: u64,
84	#[cfg_attr(
85		feature = "serde",
86		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
87	)]
88	pub base_reserves: u64,
89	#[cfg_attr(
90		feature = "serde",
91		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
92	)]
93	pub quote_reserves: u64,
94	#[cfg_attr(
95		feature = "serde",
96		serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
97	)]
98	pub timestamp: i64,
99}
100
101pub const POOL_CREATE_EVENT_DISCRIMINATOR: [u8; 8] =
102	[151, 215, 226, 9, 118, 161, 115, 174];
103
104impl PoolCreateEvent {
105	/// Anchor discriminators are derived from names alone, so identical bytes recur across
106	/// programs and the bytes alone cannot tell this event from a foreign one.
107	#[inline(always)]
108	pub fn matches(program_id: &solana_address::Address, data: &[u8]) -> bool {
109		program_id == &crate::dex::generated::SEND_DEX_ID
110			&& data.get(..ANCHOR_EVENT_CPI_DISCRIMINATOR.len())
111				== Some(&ANCHOR_EVENT_CPI_DISCRIMINATOR[..])
112			&& data.get(8..16) == Some(&POOL_CREATE_EVENT_DISCRIMINATOR[..])
113	}
114
115	/// `None` when [`Self::matches`] is false; `Some(Err(_))` when it matches but the body fails
116	/// to deserialize. Use [`Option::transpose`] to propagate the failure with `?`.
117	#[inline(always)]
118	pub fn try_parse(
119		program_id: &solana_address::Address,
120		data: &[u8],
121	) -> Option<Result<Self, std::io::Error>> {
122		if !Self::matches(program_id, data) {
123			return None;
124		}
125		// ANCHOR_EVENT_CPI_DISCRIMINATOR (8) + POOL_CREATE_EVENT_DISCRIMINATOR (8)
126		let mut data = &data[16..];
127		Some(Self::deserialize(&mut data))
128	}
129}