From 2f3634b2a154cd3807f5d595ad06d3192efba383 Mon Sep 17 00:00:00 2001 From: Estereg Date: Wed, 17 Dec 2025 22:53:52 -0300 Subject: [PATCH] refactor(bonk): Simplify account structs - Remove unnecessary Default implementations - Add BigArray support for large arrays - Translate comments to English - Improve code readability and maintainability - Ensure proper Borsh deserialization without Default values --- src/streaming/event_parser/protocols/bonk/events.rs | 12 ++++++------ src/streaming/event_parser/protocols/bonk/types.rs | 12 +++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/streaming/event_parser/protocols/bonk/events.rs b/src/streaming/event_parser/protocols/bonk/events.rs index 8172a59..e6eb81d 100755 --- a/src/streaming/event_parser/protocols/bonk/events.rs +++ b/src/streaming/event_parser/protocols/bonk/events.rs @@ -227,8 +227,8 @@ pub struct BonkMigrateToCpswapEvent { pub remaining_accounts: Vec, } -/// 池状态 -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +/// Pool state account event +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct BonkPoolStateAccountEvent { pub metadata: EventMetadata, pub pubkey: Pubkey, @@ -239,8 +239,8 @@ pub struct BonkPoolStateAccountEvent { pub pool_state: PoolState, } -/// 全局配置 -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +/// Global config account event +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct BonkGlobalConfigAccountEvent { pub metadata: EventMetadata, pub pubkey: Pubkey, @@ -251,8 +251,8 @@ pub struct BonkGlobalConfigAccountEvent { pub global_config: GlobalConfig, } -/// 平台配置 -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +/// Platform config account event +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct BonkPlatformConfigAccountEvent { pub metadata: EventMetadata, pub pubkey: Pubkey, diff --git a/src/streaming/event_parser/protocols/bonk/types.rs b/src/streaming/event_parser/protocols/bonk/types.rs index f74b9f3..f69d1cc 100755 --- a/src/streaming/event_parser/protocols/bonk/types.rs +++ b/src/streaming/event_parser/protocols/bonk/types.rs @@ -94,7 +94,7 @@ pub struct VestingSchedule { pub allocated_share_amount: u64, } -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)] pub struct PoolState { pub epoch: u64, pub auth_bump: u8, @@ -122,6 +122,7 @@ pub struct PoolState { pub creator: Pubkey, pub token_program_flag: u8, pub amm_creator_fee_on: AmmFeeOn, + #[serde(with = "serde_big_array::BigArray")] pub padding: [u8; 62], } @@ -220,16 +221,17 @@ pub struct BondingCurveParam { pub unlock_period: u64, } -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)] pub struct PlatformCurveParam { pub epoch: u64, pub index: u8, pub global_config: Pubkey, pub bonding_curve_param: BondingCurveParam, + #[serde(with = "serde_big_array::BigArray")] pub padding: [u64; 50], } -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)] pub struct PlatformConfig { pub epoch: u64, pub platform_fee_wallet: Pubkey, @@ -238,12 +240,16 @@ pub struct PlatformConfig { pub creator_scale: u64, pub burn_scale: u64, pub fee_rate: u64, + #[serde(with = "serde_big_array::BigArray")] pub name: [u8; 64], + #[serde(with = "serde_big_array::BigArray")] pub web: [u8; 256], + #[serde(with = "serde_big_array::BigArray")] pub img: [u8; 256], pub cpswap_config: Pubkey, pub creator_fee_rate: u64, pub transfer_fee_extension_auth: Pubkey, + #[serde(with = "serde_big_array::BigArray")] pub padding: [u8; 180], pub curve_params: Vec, }