Skip to main content

bucks_api/
event.rs

1use serde::{Deserialize, Serialize};
2use steel::*;
3
4/// Bucks protocol event types.
5pub enum BucksEvent {
6    Wrap = 0,
7    Unwrap = 1,
8    Claim = 2,
9    Rebalance = 3,
10    Checkpoint = 4,
11    ProtocolInit = 5,
12}
13
14/// Emitted when USDC is wrapped into stablecoin.
15#[repr(C)]
16#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
17pub struct WrapEvent {
18    /// The event discriminator.
19    pub disc: u64,
20
21    /// The user who wrapped.
22    pub user: Pubkey,
23
24    /// The stablecoin mint.
25    pub mint: Pubkey,
26
27    /// The protocol ID used for deposit.
28    pub protocol_id: u64,
29
30    /// The amount of USDC wrapped.
31    pub usdc_amount: u64,
32
33    /// The amount of stablecoin minted.
34    pub stable_amount: u64,
35
36    /// The shares credited.
37    pub shares_minted: u64,
38
39    /// The timestamp of the event.
40    pub ts: i64,
41}
42
43/// Emitted when stablecoin is unwrapped to USDC.
44#[repr(C)]
45#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
46pub struct UnwrapEvent {
47    /// The event discriminator.
48    pub disc: u64,
49
50    /// The user who unwrapped.
51    pub user: Pubkey,
52
53    /// The stablecoin mint.
54    pub mint: Pubkey,
55
56    /// The protocol ID used for withdrawal.
57    pub protocol_id: u64,
58
59    /// The amount of stablecoin burned.
60    pub stable_amount: u64,
61
62    /// The amount of USDC returned.
63    pub usdc_amount: u64,
64
65    /// The shares burned.
66    pub shares_burned: u64,
67
68    /// The timestamp of the event.
69    pub ts: i64,
70}
71
72/// Emitted when a creator claims yield.
73#[repr(C)]
74#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
75pub struct ClaimEvent {
76    /// The event discriminator.
77    pub disc: u64,
78
79    /// The creator who claimed.
80    pub creator: Pubkey,
81
82    /// The stablecoin mint.
83    pub mint: Pubkey,
84
85    /// The amount of USDC claimed.
86    pub usdc_amount: u64,
87
88    /// The platform fee deducted.
89    pub platform_fee: u64,
90
91    /// The timestamp of the event.
92    pub ts: i64,
93}
94
95/// Emitted when funds are rebalanced between protocols.
96#[repr(C)]
97#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
98pub struct RebalanceEvent {
99    /// The event discriminator.
100    pub disc: u64,
101
102    /// The source protocol ID.
103    pub from_protocol: u64,
104
105    /// The destination protocol ID.
106    pub to_protocol: u64,
107
108    /// The USDC amount moved.
109    pub usdc_amount: u64,
110
111    /// The timestamp of the event.
112    pub ts: i64,
113}
114
115/// Emitted when a protocol checkpoint is recorded.
116#[repr(C)]
117#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
118pub struct CheckpointEvent {
119    /// The event discriminator.
120    pub disc: u64,
121
122    /// The protocol ID checkpointed.
123    pub protocol_id: u64,
124
125    /// The new exchange rate (scaled by 1e9).
126    pub exchange_rate: u64,
127
128    /// The total USDC value in the protocol.
129    pub usdc_value: u64,
130
131    /// The timestamp of the event.
132    pub ts: i64,
133}
134
135/// Emitted when a new protocol is initialized.
136#[repr(C)]
137#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
138pub struct ProtocolInitEvent {
139    /// The event discriminator.
140    pub disc: u64,
141
142    /// The protocol ID initialized.
143    pub protocol_id: u64,
144
145    /// The protocol name (first 32 bytes).
146    pub name: [u8; 32],
147
148    /// The timestamp of the event.
149    pub ts: i64,
150}
151
152
153event!(WrapEvent);
154event!(UnwrapEvent);
155event!(ClaimEvent);
156event!(RebalanceEvent);
157event!(CheckpointEvent);
158event!(ProtocolInitEvent);