This commit is contained in:
Hardhat Chad
2025-09-20 11:49:03 -07:00
parent 5d7c31d324
commit 44c87aa89c
11 changed files with 79 additions and 79 deletions

View File

@@ -3,17 +3,11 @@ use steel::*;
#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, IntoPrimitive)]
#[repr(u32)]
pub enum OreError {
#[error("Placeholder error")]
Dummy = 0,
#[error("Amount too small")]
AmountTooSmall = 0,
#[error("Insufficient vault reserves")]
InsufficientVaultReserves = 1,
#[error("Invariant violation")]
InvariantViolation = 2,
#[error("Insufficient liquidity")]
InsufficientLiquidity = 3,
#[error("Not authorized")]
NotAuthorized = 1,
}
error!(OreError);

View File

@@ -7,9 +7,9 @@ pub enum OreInstruction {
Boost = 0,
ClaimSOL = 1,
ClaimORE = 2,
Initialize = 3,
Log = 4,
Prospect = 5,
Deploy = 3,
Initialize = 4,
Log = 5,
Redeem = 6,
Reset = 7,
@@ -37,6 +37,13 @@ pub struct ClaimORE {
pub amount: [u8; 8],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Deploy {
pub amount: [u8; 8],
pub square_id: [u8; 8],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Initialize {}
@@ -55,12 +62,6 @@ pub struct Redeem {
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Reset {}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Prospect {
pub amount: [u8; 8],
pub square_id: [u8; 8],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Mine {
@@ -119,9 +120,9 @@ pub struct ClaimSeeker {}
instruction!(OreInstruction, Boost);
instruction!(OreInstruction, ClaimSOL);
instruction!(OreInstruction, ClaimORE);
instruction!(OreInstruction, Deploy);
instruction!(OreInstruction, Initialize);
instruction!(OreInstruction, Log);
instruction!(OreInstruction, Prospect);
instruction!(OreInstruction, Redeem);
instruction!(OreInstruction, Reset);
instruction!(OreInstruction, SetAdmin);

View File

@@ -111,6 +111,32 @@ pub fn claim_ore(signer: Pubkey, amount: u64) -> Instruction {
}
}
// let [signer_info, board_info, config_info, fee_collector_info, miner_info, sender_info, square_info, system_program] =
pub fn deploy(signer: Pubkey, fee_collector: Pubkey, amount: u64, square_id: u64) -> Instruction {
let board_address = board_pda().0;
let config_address = config_pda().0;
let miner_address = miner_pda(signer).0;
let square_address = square_pda().0;
Instruction {
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(board_address, false),
AccountMeta::new(config_address, false),
AccountMeta::new(fee_collector, false),
AccountMeta::new(miner_address, false),
AccountMeta::new(square_address, false),
AccountMeta::new_readonly(system_program::ID, false),
],
data: Deploy {
amount: amount.to_le_bytes(),
square_id: square_id.to_le_bytes(),
}
.to_bytes(),
}
}
pub fn redeem(signer: Pubkey, amount: u64) -> Instruction {
let mint_address = MINT_ADDRESS;
let sender_address = get_associated_token_address(&signer, &MINT_ADDRESS);
@@ -166,32 +192,6 @@ pub fn reset(signer: Pubkey, miners: Vec<Pubkey>) -> Instruction {
}
}
// let [signer_info, board_info, config_info, fee_collector_info, miner_info, sender_info, square_info, system_program] =
pub fn prospect(signer: Pubkey, fee_collector: Pubkey, amount: u64, square_id: u64) -> Instruction {
let board_address = board_pda().0;
let config_address = config_pda().0;
let miner_address = miner_pda(signer).0;
let square_address = square_pda().0;
Instruction {
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(board_address, false),
AccountMeta::new(config_address, false),
AccountMeta::new(fee_collector, false),
AccountMeta::new(miner_address, false),
AccountMeta::new(square_address, false),
AccountMeta::new_readonly(system_program::ID, false),
],
data: Prospect {
amount: amount.to_le_bytes(),
square_id: square_id.to_le_bytes(),
}
.to_bytes(),
}
}
pub fn set_admin(signer: Pubkey, admin: Pubkey) -> Instruction {
let config_address = config_pda().0;
Instruction {

View File

@@ -13,8 +13,8 @@ pub struct Config {
// The last boost timestamp.
pub last_boost: i64,
// The minimum amount of SOL that can be prospect.
pub min_prospect_amount: u64,
// The minimum amount of SOL that can be deploy.
pub min_deploy_amount: u64,
// The address that receives fees.
pub fee_collector: Pubkey,