1use steel::*;
2use bytemuck;
3
4#[repr(u8)]
5#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
6pub enum OilInstruction {
7 Automate = 0,
9 Initialize = 1,
10 Checkpoint = 2,
11 ClaimSOL = 3,
12 ClaimOIL = 4,
13 Close = 5,
14 Deploy = 6,
15 Log = 8,
16 Reset = 9,
17 ReloadSOL = 21,
18 CreateReferral = 27,
19 ClaimReferral = 28,
20
21 SetBid = 29,
23 ClaimAuctionOIL = 31,
24 ClaimAuctionSOL = 32,
25 SyncAuctionState = 34,
26
27 Deposit = 10,
29 Withdraw = 11,
30 ClaimYield = 12,
31
32 Buyback = 13,
34 SetAdmin = 15,
35 SetFeeCollector = 16,
36 SetSwapProgram = 17,
37 SetVarAddress = 18,
38 NewVar = 19,
39 SetAdminFee = 20,
40 Migrate = 26,
41 SetAuction = 33,
42}
43
44#[repr(C)]
45#[derive(Clone, Copy, Debug, Pod, Zeroable)]
46pub struct Automate {
47 pub amount: [u8; 8],
48 pub deposit: [u8; 8],
49 pub fee: [u8; 8],
50 pub mask: [u8; 8],
51 pub strategy: u8,
52 pub reload: [u8; 8],
53 pub referrer: [u8; 32],
55 pub pooled: u8,
57}
58
59#[repr(C)]
60#[derive(Clone, Copy, Debug, Pod, Zeroable)]
61pub struct InitRound {}
62
63#[repr(C)]
64#[derive(Clone, Copy, Debug, Pod, Zeroable)]
65pub struct ClaimSOL {}
66
67#[repr(C)]
68#[derive(Clone, Copy, Debug, Pod, Zeroable)]
69pub struct ClaimOIL {}
70
71#[repr(C)]
72#[derive(Clone, Copy, Debug, Pod, Zeroable)]
73pub struct Deploy {
74 pub amount: [u8; 8],
75 pub squares: [u8; 4],
76 pub referrer: [u8; 32],
78 pub pooled: u8,
80}
81
82#[repr(C)]
83#[derive(Clone, Copy, Debug, Pod, Zeroable)]
84pub struct Log {}
85
86#[repr(C)]
87#[derive(Clone, Copy, Debug, Pod, Zeroable)]
88pub struct Reset {}
89
90#[repr(C)]
91#[derive(Clone, Copy, Debug, Pod, Zeroable)]
92pub struct Close {}
93
94#[repr(C)]
95#[derive(Clone, Copy, Debug, Pod, Zeroable)]
96pub struct Mine {
97 pub nonce: [u8; 8],
98}
99
100#[repr(C)]
101#[derive(Clone, Copy, Debug, Pod, Zeroable)]
102pub struct Swap {
103 pub amount: [u8; 8],
104 pub direction: u8,
105 pub precision: u8,
106 pub seed: [u8; 32],
107}
108
109#[repr(C)]
110#[derive(Clone, Copy, Debug, Pod, Zeroable)]
111pub struct Uncommit {
112 pub amount: [u8; 8],
113}
114
115#[repr(C)]
116#[derive(Clone, Copy, Debug, Pod, Zeroable)]
117pub struct SetAdmin {
118 pub admin: [u8; 32],
119}
120
121#[repr(C)]
122#[derive(Clone, Copy, Debug, Pod, Zeroable)]
123pub struct SetFeeCollector {
124 pub fee_collector: [u8; 32],
125}
126
127#[repr(C)]
128#[derive(Clone, Copy, Debug, Pod, Zeroable)]
129pub struct SetFeeRate {
130 pub fee_rate: [u8; 8],
131}
132
133#[repr(C)]
134#[derive(Clone, Copy, Debug, Pod, Zeroable)]
135pub struct Buyback {}
136
137#[repr(C)]
138#[derive(Clone, Copy, Debug, Pod, Zeroable)]
139pub struct ReloadSOL {}
140
141#[repr(C)]
142#[derive(Clone, Copy, Debug, Pod, Zeroable)]
143pub struct Deposit {
144 pub amount: [u8; 8],
145 pub lock_duration_days: [u8; 8], pub stake_id: [u8; 8], }
148
149#[repr(C)]
150#[derive(Clone, Copy, Debug, Pod, Zeroable)]
151pub struct Withdraw {
152 pub amount: [u8; 8],
153 pub stake_id: [u8; 8],
154}
155
156#[repr(C)]
157#[derive(Clone, Copy, Debug, Pod, Zeroable)]
158pub struct ClaimYield {
159 pub amount: [u8; 8],
160}
161
162#[repr(C)]
163#[derive(Clone, Copy, Debug, Pod, Zeroable)]
164pub struct Checkpoint {}
165
166#[repr(C)]
167#[derive(Clone, Copy, Debug, Pod, Zeroable)]
168pub struct NewVar {
169 pub id: [u8; 8],
170 pub commit: [u8; 32],
171 pub samples: [u8; 8],
172}
173
174#[repr(C)]
175#[derive(Clone, Copy, Debug, Pod, Zeroable)]
176pub struct SetAdminFee {
177 pub admin_fee: [u8; 8],
178}
179
180#[repr(C)]
181#[derive(Clone, Copy, Debug, Pod, Zeroable)]
182pub struct SetSwapProgram {}
183
184#[repr(C)]
185#[derive(Clone, Copy, Debug, Pod, Zeroable)]
186pub struct SetVarAddress {}
187
188#[repr(C)]
189#[derive(Clone, Copy, Debug, Pod, Zeroable)]
190pub struct Migrate {}
191
192#[repr(C)]
193#[derive(Clone, Copy, Debug, Pod, Zeroable)]
194pub struct CreateReferral {}
195
196#[repr(C)]
197#[derive(Clone, Copy, Debug, Pod, Zeroable)]
198pub struct ClaimReferral {}
199
200#[repr(C)]
201#[derive(Clone, Copy, Debug, Pod, Zeroable)]
202pub struct Initialize {
203 pub barrel_authority: [u8; 32],
204 pub fee_collector: [u8; 32],
205 pub swap_program: [u8; 32],
206 pub var_address: [u8; 32],
207 pub admin_fee: [u8; 8],
208 pub halving_period_seconds: [u8; 8],
210 pub base_mining_rates: [[u8; 8]; 4], pub auction_duration_seconds: [u8; 8],
212 pub starting_prices: [[u8; 8]; 4], }
214
215#[repr(C)]
216#[derive(Clone, Copy, Debug, Pod, Zeroable)]
217pub struct SetBid {
218 pub square_id: [u8; 8],
219}
220
221#[repr(C)]
222#[derive(Clone, Copy, Debug, Pod, Zeroable)]
223pub struct ClaimAuctionOIL {
224 pub well_mask: u8,
227}
228
229#[repr(C)]
230#[derive(Clone, Copy, Debug, Pod, Zeroable)]
231pub struct ClaimAuctionSOL {
232 pub _reserved: u8,
234}
235
236#[repr(C)]
237#[derive(Clone, Copy, Debug, Pod, Zeroable)]
238pub struct SetAuction {
239 pub halving_period_seconds: [u8; 8],
240 pub last_halving_time: [u8; 8],
241 pub base_mining_rates: [[u8; 8]; 4], pub auction_duration_seconds: [u8; 8],
243 pub starting_prices: [[u8; 8]; 4], pub well_id: [u8; 8], }
246
247#[repr(C)]
248#[derive(Clone, Copy, Debug, Pod, Zeroable)]
249pub struct SyncAuctionState {
250 pub well_id: [u8; 8],
252}
253
254#[repr(C)]
255#[derive(Clone, Copy, Debug, Pod, Zeroable)]
256pub struct JoinAuctionPool {
257 pub square_id: [u8; 8],
259 pub amount: [u8; 8],
261}
262
263impl JoinAuctionPool {
264 pub fn to_bytes(&self) -> Vec<u8> {
265 bytemuck::bytes_of(self).to_vec()
266 }
267}
268
269instruction!(OilInstruction, Automate);
270instruction!(OilInstruction, Initialize);
271instruction!(OilInstruction, Checkpoint);
272instruction!(OilInstruction, ClaimSOL);
273instruction!(OilInstruction, ClaimOIL);
274instruction!(OilInstruction, ReloadSOL);
275instruction!(OilInstruction, Deploy);
276instruction!(OilInstruction, Log);
277instruction!(OilInstruction, Buyback);
278instruction!(OilInstruction, Reset);
279instruction!(OilInstruction, Close);
280instruction!(OilInstruction, SetAdmin);
281instruction!(OilInstruction, SetFeeCollector);
282instruction!(OilInstruction, Deposit);
283instruction!(OilInstruction, Withdraw);
284instruction!(OilInstruction, ClaimYield);
285instruction!(OilInstruction, NewVar);
286instruction!(OilInstruction, SetAdminFee);
287instruction!(OilInstruction, SetSwapProgram);
288instruction!(OilInstruction, SetVarAddress);
289instruction!(OilInstruction, Migrate);
290instruction!(OilInstruction, CreateReferral);
291instruction!(OilInstruction, ClaimReferral);
292instruction!(OilInstruction, SetBid);
293instruction!(OilInstruction, ClaimAuctionOIL);
294instruction!(OilInstruction, ClaimAuctionSOL);
295instruction!(OilInstruction, SetAuction);
296instruction!(OilInstruction, SyncAuctionState);