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