Skip to main content

airdrop_api/
event.rs

1use solana_program::pubkey::Pubkey;
2use steel::*;
3
4/// Event emitted when program config is initialized
5#[repr(C)]
6#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
7pub struct ConfigInitializedEvent {
8    pub admin: Pubkey,
9    pub mint_fee_lamports: u64,
10    pub allocation_fee_per_recipient_lamports: u64,
11    pub fee_account: Pubkey,
12    pub initialized_at: i64,
13}
14
15/// Event emitted when a mint is created
16#[repr(C)]
17#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
18pub struct MintCreatedEvent {
19    pub mint: Pubkey,
20    pub mint_authority: Pubkey,
21    pub admin: Pubkey,
22    /// Max supply minted (all tokens minted upfront, mint authority revoked)
23    pub max_supply: u64,
24    pub created_at: i64,
25}
26
27/// Event emitted when a campaign is created
28#[repr(C)]
29#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
30pub struct CampaignCreatedEvent {
31    pub campaign: Pubkey,
32    pub mint: Pubkey,
33    pub owner: Pubkey,
34    pub merkle_root: [u8; 32],
35    pub initial_supply: u64,
36    pub created_at: i64,
37}
38
39/// Event emitted when tokens are allocated (on-chain allocation accounts)
40#[repr(C)]
41#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
42pub struct TokensAllocatedEvent {
43    pub campaign: Pubkey,
44    pub recipient: Pubkey,
45    pub amount: u64,
46}
47
48/// Event emitted when tokens are claimed
49#[repr(C)]
50#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
51pub struct TokensClaimedEvent {
52    pub campaign: Pubkey,
53    pub recipient: Pubkey,
54    pub amount: u64,
55    pub method: u8,        // 0=allocation, 1=record, 2=merkle
56    pub _padding: [u8; 7], // Padding for alignment
57}
58
59/// Event emitted when config is updated
60#[repr(C)]
61#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
62pub struct ConfigUpdatedEvent {
63    pub admin: Pubkey,
64    pub mint_fee_lamports: u64,
65    pub allocation_fee_per_recipient_lamports: u64,
66    pub merkle_fee_per_recipient_lamports: u64,
67    pub direct_transfer_fee_per_recipient_lamports: u64,
68    pub updated_at: i64,
69}
70
71/// Event emitted when fees are withdrawn
72#[repr(C)]
73#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
74pub struct FeesWithdrawnEvent {
75    pub admin: Pubkey,
76    pub beneficiary: Pubkey,
77    pub amount: u64,
78    pub remaining_balance: u64,
79}
80
81/// Event emitted when tokens are minted to campaign treasury
82#[repr(C)]
83#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
84pub struct TokensMintedEvent {
85    pub campaign: Pubkey,
86    pub mint: Pubkey,
87    pub amount: u64,
88    pub new_supply: u64,
89    pub minted_at: i64,
90}
91
92/// Event emitted when tokens are replenished to campaign treasury
93#[repr(C)]
94#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
95pub struct TokensReplenishedEvent {
96    pub campaign: Pubkey,
97    pub mint: Pubkey,
98    pub amount: u64,
99    pub new_balance: u64,
100    pub replenished_at: i64,
101}
102
103/// Event emitted when tokens are directly transferred to recipients
104#[repr(C)]
105#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
106pub struct TokensDirectTransferredEvent {
107    pub campaign: Pubkey,
108    pub recipient_count: u8,
109    pub _padding1: [u8; 7], // Padding to align next u64
110    pub total_amount: u64,
111    pub transferred_at: i64,
112    pub _padding2: [u8; 8], // Padding for 8-byte alignment (total size must be multiple of 8)
113}
114
115event!(ConfigInitializedEvent);
116event!(MintCreatedEvent);
117event!(CampaignCreatedEvent);
118event!(TokensAllocatedEvent);
119event!(TokensClaimedEvent);
120event!(ConfigUpdatedEvent);
121event!(FeesWithdrawnEvent);
122event!(TokensMintedEvent);
123event!(TokensReplenishedEvent);
124event!(TokensDirectTransferredEvent);