Skip to main content

oil_api/
event.rs

1use serde::{Deserialize, Serialize};
2use steel::*;
3
4pub enum OilEvent {
5    Reset = 0,
6    Barrel = 1,
7    Deploy = 2,
8    Liq = 3,
9    Bid = 4,
10    JoinPool = 5,
11    ClaimAuctionOIL = 6,
12    ClaimAuctionSOL = 7,
13    ClaimRefineryRewards = 8,
14}
15
16#[repr(C)]
17#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
18pub struct ResetEvent {
19    /// The event discriminator.
20    pub disc: u64,
21
22    /// The block that was opened for trading.
23    pub round_id: u64,
24
25    /// The start slot of the next block.
26    pub start_slot: u64,
27
28    /// The end slot of the next block.
29    pub end_slot: u64,
30
31    /// The winning square of the round.
32    pub winning_square: u64,
33
34    /// The top miner of the round.
35    pub top_miner: Pubkey,
36
37    /// The number of miners on the winning square.
38    pub num_winners: u64,
39
40    /// The total amount of SOL prospected in the round.
41    pub total_deployed: u64,
42
43    /// The total amount of SOL put in the OIL vault.
44    pub total_vaulted: u64,
45
46    /// The total amount of SOL won by miners for the round.
47    pub total_winnings: u64,
48
49    /// The total amount of OIL minted for the round.
50    pub total_minted: u64,
51
52    /// The timestamp of the event.
53    pub ts: i64,
54
55    /// The amount of SOL in the gusher.
56    pub gusher_sol: u64,
57}
58
59#[repr(C)]
60#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
61pub struct BarrelEvent {
62    /// The event discriminator.
63    pub disc: u64,
64
65    /// The amount of OIL barreled.
66    pub oil_barreled: u64,
67
68    /// The amount of OIL shared with stakers.
69    pub oil_shared: u64,
70
71    /// The amount of SOL swapped.
72    pub sol_amount: u64,
73
74    /// The new circulating supply of OIL.
75    pub new_circulating_supply: u64,
76
77    /// The timestamp of the event.
78    pub ts: i64,
79}
80
81#[repr(C)]
82#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
83pub struct DeployEvent {
84    /// The event discriminator.
85    pub disc: u64,
86
87    /// The authority of the deployer.
88    pub authority: Pubkey,
89
90    /// The amount of SOL deployed per square.
91    pub amount: u64,
92
93    /// The mask of the squares deployed to.
94    pub mask: u64,
95
96    /// The round id.
97    pub round_id: u64,
98
99    /// The signer of the deployer.
100    pub signer: Pubkey,
101
102    /// The strategy used by the autominer (u64::MAX if manual).
103    pub strategy: u64,
104
105    /// The total number of squares deployed to.
106    pub total_squares: u64,
107
108    /// The timestamp of the event.
109    pub ts: i64,
110}
111
112#[repr(C)]
113#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
114pub struct LiqEvent {
115    /// The event discriminator.
116    pub disc: u64,
117
118    /// The amount of SOL sent to the liq manager.
119    pub sol_amount: u64,
120
121    /// The recipient of the SOL.
122    pub recipient: Pubkey,
123
124    /// The timestamp of the event.
125    pub ts: i64,
126}
127
128#[repr(C)]
129#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
130pub struct BidEvent {
131    /// The event discriminator.
132    pub disc: u64,
133    
134    /// The authority of the bidder.
135    pub authority: Pubkey,
136    
137    /// The square ID (well) that was bid on (0-3).
138    pub square_id: u64,
139    
140    /// The bid amount in lamports.
141    pub bid_amount: u64,
142    
143    /// The current price at time of bid (in lamports).
144    pub current_price: u64,
145    
146    /// The previous owner (Pubkey::default() if no previous owner).
147    pub previous_owner: Pubkey,
148    
149    /// The accumulated OIL transferred to previous owner (0 if no previous owner).
150    pub accumulated_oil_transferred: u64,
151    
152    /// The new starting price for next auction (in lamports).
153    pub new_start_price: u64,
154    
155    /// The timestamp of the event.
156    pub ts: u64,
157}
158
159#[repr(C)]
160#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
161pub struct JoinAuctionPoolEvent {
162    /// The event discriminator.
163    pub disc: u64,
164    
165    /// The authority of the contributor.
166    pub authority: Pubkey,
167    
168    /// The square ID (well) for this pool contribution (0-3).
169    pub square_id: u64,
170    
171    /// The contribution amount in lamports.
172    pub contribution: u64,
173    
174    /// The total pool amount after this contribution (in lamports).
175    pub pool_total: u64,
176    
177    /// The current price at time of contribution (in lamports).
178    pub current_price: u64,
179    
180    /// The timestamp of the event.
181    pub ts: u64,
182    
183    /// Whether the pool won the well (auto-bid triggered).
184    /// 0 = false, 1 = true (using u64 for Pod compatibility and alignment)
185    pub pool_won: u64,
186}
187
188#[repr(C)]
189#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
190pub struct ClaimAuctionOILEvent {
191    /// The event discriminator.
192    pub disc: u64,
193    
194    /// The authority of the claimant.
195    pub authority: Pubkey,
196    
197    /// The total OIL claimed (after refining fees).
198    pub oil_claimed: u64,
199    
200    /// The refining fee charged (10%).
201    pub refining_fee: u64,
202    
203    /// The timestamp of the event.
204    pub ts: u64,
205}
206
207#[repr(C)]
208#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
209pub struct ClaimAuctionSOLEvent {
210    /// The event discriminator.
211    pub disc: u64,
212    
213    /// The authority of the claimant.
214    pub authority: Pubkey,
215    
216    /// The total SOL claimed (rewards + refunds).
217    pub sol_claimed: u64,
218    
219    /// The SOL from auction rewards (being outbid).
220    pub rewards_sol: u64,
221    
222    /// The SOL from pool refunds.
223    pub refunds_sol: u64,
224    
225    /// The timestamp of the event.
226    pub ts: u64,
227}
228
229#[repr(C)]
230#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
231pub struct ClaimRefineryRewardsEvent {
232    /// The event discriminator.
233    pub disc: u64,
234    /// The authority (plot owner) that claimed.
235    pub authority: Pubkey,
236    /// OIL claimed (atomic units).
237    pub oil_claimed: u64,
238    /// Claim fee paid in lamports (35% of claim value).
239    pub fee_lamports: u64,
240    /// Portion to fee collector (15%).
241    pub fee_collector_lamports: u64,
242    /// Portion to staking rewards (15%).
243    pub staking_lamports: u64,
244    /// Portion to treasury balance for buybacks (5%).
245    pub buyback_lamports: u64,
246    /// The timestamp of the event.
247    pub ts: i64,
248}
249
250event!(ResetEvent);
251event!(BarrelEvent);
252event!(DeployEvent);
253event!(LiqEvent);
254event!(BidEvent);
255event!(JoinAuctionPoolEvent);
256event!(ClaimAuctionOILEvent);
257event!(ClaimAuctionSOLEvent);
258event!(ClaimRefineryRewardsEvent);