This commit is contained in:
Hardhat Chad
2025-06-25 14:33:58 -05:00
parent 11d5442dd2
commit d03acda291
6 changed files with 134 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ use steel::*;
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
pub enum OreInstruction {
// User
Open = 0,
Close = 1,
Commit = 2,
@@ -11,6 +12,11 @@ pub enum OreInstruction {
Swap = 5,
Uncommit = 6,
Withdraw = 7,
// Admin
SetAdmin = 10,
SetFeeCollector = 9,
SetFeeRate = 8,
}
#[repr(C)]
@@ -64,6 +70,24 @@ pub struct Withdraw {
pub amount: [u8; 8],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct SetAdmin {
pub admin: [u8; 32],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct SetFeeCollector {
pub fee_collector: [u8; 32],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct SetFeeRate {
pub fee_rate: [u8; 8],
}
instruction!(OreInstruction, Open);
instruction!(OreInstruction, Close);
instruction!(OreInstruction, Commit);
@@ -72,3 +96,6 @@ instruction!(OreInstruction, Mine);
instruction!(OreInstruction, Swap);
instruction!(OreInstruction, Uncommit);
instruction!(OreInstruction, Withdraw);
instruction!(OreInstruction, SetAdmin);
instruction!(OreInstruction, SetFeeCollector);
instruction!(OreInstruction, SetFeeRate);

View File

@@ -4,11 +4,13 @@ use crate::state::config_pda;
use super::OreAccount;
// TODO Config stuff
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Config {}
pub struct Config {
pub admin: Pubkey,
pub fee_collector: Pubkey,
pub fee_rate: u64,
}
impl Config {
pub fn pda() -> (Pubkey, u8) {