ore_boost_api/
instruction.rs

1use steel::*;
2
3#[repr(u8)]
4#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
5#[rustfmt::skip]
6pub enum BoostInstruction {
7    // User
8    Claim = 0,
9    Close = 1,
10    Deposit = 2,
11    Open = 3,
12    Rotate = 4,
13    Withdraw = 5,
14    
15    // Admin
16    Activate = 100,
17    Deactivate = 101,
18    Initialize = 102,
19    New = 103,
20    UpdateAdmin = 104,
21    UpdateBoost = 105,
22
23    // Migration
24    Migrate = 200,
25}
26
27impl BoostInstruction {
28    pub fn to_vec(&self) -> Vec<u8> {
29        vec![*self as u8]
30    }
31}
32
33#[repr(C)]
34#[derive(Clone, Copy, Debug, Pod, Zeroable)]
35pub struct Activate {}
36
37#[repr(C)]
38#[derive(Clone, Copy, Debug, Pod, Zeroable)]
39pub struct Claim {
40    pub amount: [u8; 8],
41}
42
43#[repr(C)]
44#[derive(Clone, Copy, Debug, Pod, Zeroable)]
45pub struct Close {}
46
47#[repr(C)]
48#[derive(Clone, Copy, Debug, Pod, Zeroable)]
49pub struct Deactivate {}
50
51#[repr(C)]
52#[derive(Clone, Copy, Debug, Pod, Zeroable)]
53pub struct Deposit {
54    pub amount: [u8; 8],
55}
56
57#[repr(C)]
58#[derive(Clone, Copy, Debug, Pod, Zeroable)]
59pub struct Initialize {}
60
61#[repr(C)]
62#[derive(Clone, Copy, Debug, Pod, Zeroable)]
63pub struct New {
64    pub expires_at: [u8; 8],
65    pub multiplier: [u8; 8],
66}
67
68#[repr(C)]
69#[derive(Clone, Copy, Debug, Pod, Zeroable)]
70pub struct Open {}
71
72#[repr(C)]
73#[derive(Clone, Copy, Debug, Pod, Zeroable)]
74pub struct Rotate {}
75
76#[repr(C)]
77#[derive(Clone, Copy, Debug, Pod, Zeroable)]
78pub struct UpdateAdmin {
79    pub new_admin: Pubkey,
80}
81
82#[repr(C)]
83#[derive(Clone, Copy, Debug, Pod, Zeroable)]
84pub struct UpdateBoost {
85    pub expires_at: [u8; 8],
86    pub multiplier: [u8; 8],
87}
88
89#[repr(C)]
90#[derive(Clone, Copy, Debug, Pod, Zeroable)]
91pub struct Withdraw {
92    pub amount: [u8; 8],
93}
94
95#[repr(C)]
96#[derive(Clone, Copy, Debug, Pod, Zeroable)]
97pub struct Migrate {}
98
99instruction!(BoostInstruction, Activate);
100instruction!(BoostInstruction, Claim);
101instruction!(BoostInstruction, Close);
102instruction!(BoostInstruction, Deactivate);
103instruction!(BoostInstruction, Deposit);
104instruction!(BoostInstruction, Initialize);
105instruction!(BoostInstruction, New);
106instruction!(BoostInstruction, Open);
107instruction!(BoostInstruction, Rotate);
108instruction!(BoostInstruction, UpdateAdmin);
109instruction!(BoostInstruction, UpdateBoost);
110instruction!(BoostInstruction, Withdraw);
111instruction!(BoostInstruction, Migrate);