This commit is contained in:
Hardhat Chad
2024-06-29 00:59:55 +00:00
parent edc1439712
commit 462a7021e1
29 changed files with 245 additions and 194 deletions

22
Cargo.lock generated
View File

@@ -2591,26 +2591,38 @@ dependencies = [
]
[[package]]
name = "ore-program"
name = "ore-api"
version = "2.0.0"
dependencies = [
"array-const-fn-init",
"bs58 0.5.0",
"bs64",
"bytemuck",
"const-crypto",
"drillx",
"mpl-token-metadata",
"num_enum 0.7.2",
"rand 0.8.5",
"shank",
"solana-program",
"spl-associated-token-account",
"spl-token",
"static_assertions",
"thiserror",
]
[[package]]
name = "ore-program"
version = "2.0.0"
dependencies = [
"bs64",
"drillx",
"mpl-token-metadata",
"ore-api",
"rand 0.8.5",
"solana-program",
"solana-program-test",
"solana-sdk",
"spl-associated-token-account",
"spl-token",
"static_assertions",
"thiserror",
"tokio",
]

View File

@@ -1,41 +1,20 @@
[package]
name = "ore-program"
[workspace]
resolver = "2"
members = ["core/*"]
[workspace.package]
version = "2.0.0"
description = "Ore is a digital currency you can mine from anywhere, at home or on your phone."
edition = "2021"
license = "Apache-2.0"
homepage = "https://ore.supply"
documentation = "https://ore.supply"
repository = "https://github.com/hardhatchad/ore"
repository = "https://github.com/regolith-labs/ore"
readme = "./README.md"
keywords = ["solana", "crypto", "mining"]
[lib]
crate-type = ["cdylib", "lib"]
name = "ore"
[features]
no-entrypoint = []
default = []
[dependencies]
array-const-fn-init = "0.1.1"
bs58 = "0.5.0"
bytemuck = "1.14.3"
const-crypto = "0.1.0"
[workspace.dependencies]
drillx = { git = "https://github.com/regolith-labs/drillx", branch = "master", features = ["solana"] }
mpl-token-metadata = "4.1.2"
num_enum = "0.7.2"
shank = "0.3.0"
solana-program = "1.18"
spl-token = { version = "^4", features = ["no-entrypoint"] }
spl-associated-token-account = { version = "^2.2", features = [ "no-entrypoint" ] }
static_assertions = "1.1.0"
thiserror = "1.0.57"
[dev-dependencies]
bs64 = "0.1.2"
rand = "0.8.5"
solana-program-test = "^1.18"
solana-sdk = "^1.18"
tokio = { version = "1.35", features = ["full"] }

25
core/api/Cargo.toml Normal file
View File

@@ -0,0 +1,25 @@
[package]
name = "ore-api"
description = "API for interacting with the ORE program"
version.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
documentation.workspace = true
repository.workspace = true
keywords.workspace = true
[dependencies]
array-const-fn-init = "0.1.1"
bs58 = "0.5.0"
bytemuck = "1.14.3"
const-crypto = "0.1.0"
drillx.workspace = true
mpl-token-metadata.workspace = true
num_enum = "0.7.2"
shank = "0.3.0"
solana-program.workspace = true
spl-token.workspace = true
spl-associated-token-account.workspace = true
static_assertions = "1.1.0"
thiserror = "1.0.57"

View File

@@ -8,10 +8,7 @@ use solana_program::{
system_program, sysvar,
};
use crate::{
impl_instruction_from_bytes, impl_to_bytes, BUS, BUS_ADDRESSES, CONFIG, CONFIG_ADDRESS,
METADATA, MINT, MINT_ADDRESS, MINT_NOISE, MINT_V1_ADDRESS, PROOF, TREASURY, TREASURY_ADDRESS,
};
use crate::{consts::*, impl_instruction_from_bytes, impl_to_bytes};
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, ShankInstruction, TryFromPrimitive)]
@@ -185,8 +182,9 @@ impl_instruction_from_bytes!(ClaimArgs);
impl_instruction_from_bytes!(StakeArgs);
impl_instruction_from_bytes!(UpgradeArgs);
/// Builds a reset instruction.
pub fn reset(signer: Pubkey) -> Instruction {
/// Builds a claim instruction.
pub fn claim(signer: Pubkey, beneficiary: Pubkey, amount: u64) -> Instruction {
let proof = Pubkey::find_program_address(&[PROOF, signer.as_ref()], &crate::id()).0;
let treasury_tokens = spl_associated_token_account::get_associated_token_address(
&TREASURY_ADDRESS,
&MINT_ADDRESS,
@@ -195,39 +193,20 @@ pub fn reset(signer: Pubkey) -> Instruction {
program_id: crate::id(),
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(BUS_ADDRESSES[0], false),
AccountMeta::new(BUS_ADDRESSES[1], false),
AccountMeta::new(BUS_ADDRESSES[2], false),
AccountMeta::new(BUS_ADDRESSES[3], false),
AccountMeta::new(BUS_ADDRESSES[4], false),
AccountMeta::new(BUS_ADDRESSES[5], false),
AccountMeta::new(BUS_ADDRESSES[6], false),
AccountMeta::new(BUS_ADDRESSES[7], false),
AccountMeta::new(CONFIG_ADDRESS, false),
AccountMeta::new(beneficiary, false),
AccountMeta::new(MINT_ADDRESS, false),
AccountMeta::new(TREASURY_ADDRESS, false),
AccountMeta::new(proof, false),
AccountMeta::new_readonly(TREASURY_ADDRESS, false),
AccountMeta::new(treasury_tokens, false),
AccountMeta::new_readonly(spl_token::id(), false),
],
data: OreInstruction::Reset.to_vec(),
}
}
/// Builds an open instruction.
pub fn open(signer: Pubkey, miner: Pubkey) -> Instruction {
let proof_pda = Pubkey::find_program_address(&[PROOF, signer.as_ref()], &crate::id());
Instruction {
program_id: crate::id(),
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new_readonly(miner, false),
AccountMeta::new(proof_pda.0, false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
],
data: [
OreInstruction::Open.to_vec(),
OpenArgs { bump: proof_pda.1 }.to_bytes().to_vec(),
OreInstruction::Claim.to_vec(),
ClaimArgs {
amount: amount.to_le_bytes(),
}
.to_bytes()
.to_vec(),
]
.concat(),
}
@@ -273,9 +252,28 @@ pub fn mine(signer: Pubkey, bus: Pubkey, solution: Solution) -> Instruction {
}
}
/// Builds a claim instruction.
pub fn claim(signer: Pubkey, beneficiary: Pubkey, amount: u64) -> Instruction {
let proof = Pubkey::find_program_address(&[PROOF, signer.as_ref()], &crate::id()).0;
/// Builds an open instruction.
pub fn open(signer: Pubkey, miner: Pubkey) -> Instruction {
let proof_pda = Pubkey::find_program_address(&[PROOF, signer.as_ref()], &crate::id());
Instruction {
program_id: crate::id(),
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new_readonly(miner, false),
AccountMeta::new(proof_pda.0, false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
],
data: [
OreInstruction::Open.to_vec(),
OpenArgs { bump: proof_pda.1 }.to_bytes().to_vec(),
]
.concat(),
}
}
/// Builds a reset instruction.
pub fn reset(signer: Pubkey) -> Instruction {
let treasury_tokens = spl_associated_token_account::get_associated_token_address(
&TREASURY_ADDRESS,
&MINT_ADDRESS,
@@ -284,22 +282,21 @@ pub fn claim(signer: Pubkey, beneficiary: Pubkey, amount: u64) -> Instruction {
program_id: crate::id(),
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(beneficiary, false),
AccountMeta::new(BUS_ADDRESSES[0], false),
AccountMeta::new(BUS_ADDRESSES[1], false),
AccountMeta::new(BUS_ADDRESSES[2], false),
AccountMeta::new(BUS_ADDRESSES[3], false),
AccountMeta::new(BUS_ADDRESSES[4], false),
AccountMeta::new(BUS_ADDRESSES[5], false),
AccountMeta::new(BUS_ADDRESSES[6], false),
AccountMeta::new(BUS_ADDRESSES[7], false),
AccountMeta::new(CONFIG_ADDRESS, false),
AccountMeta::new(MINT_ADDRESS, false),
AccountMeta::new(proof, false),
AccountMeta::new_readonly(TREASURY_ADDRESS, false),
AccountMeta::new(TREASURY_ADDRESS, false),
AccountMeta::new(treasury_tokens, false),
AccountMeta::new_readonly(spl_token::id(), false),
],
data: [
OreInstruction::Claim.to_vec(),
ClaimArgs {
amount: amount.to_le_bytes(),
}
.to_bytes()
.to_vec(),
]
.concat(),
data: OreInstruction::Reset.to_vec(),
}
}

9
core/api/src/lib.rs Normal file
View File

@@ -0,0 +1,9 @@
pub mod consts;
pub mod error;
pub mod instruction;
pub mod state;
pub mod utils;
use solana_program::declare_id;
declare_id!("mineRHF5r6S7HyD9SppBfVMXMavDkJsxwGesEvxZr2A");

View File

@@ -7,7 +7,7 @@ use solana_program::{
/// Creates a new pda
#[inline(always)]
pub(crate) fn create_pda<'a, 'info>(
pub fn create_pda<'a, 'info>(
target_account: &'a AccountInfo<'info>,
owner: &Pubkey,
space: usize,
@@ -73,14 +73,6 @@ pub(crate) fn create_pda<'a, 'info>(
Ok(())
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct MineEvent {
pub difficulty: u64,
pub reward: u64,
pub timing: i64,
}
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum AccountDiscriminator {
@@ -152,3 +144,13 @@ macro_rules! impl_instruction_from_bytes {
}
};
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct MineEvent {
pub difficulty: u64,
pub reward: u64,
pub timing: i64,
}
impl_to_bytes!(MineEvent);

34
core/program/Cargo.toml Normal file
View File

@@ -0,0 +1,34 @@
[package]
name = "ore-program"
description = "ORE is a fair-launch, proof-of-work, digital currency everyone can mine"
version.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
documentation.workspace = true
repository.workspace = true
readme.workspace = true
keywords.workspace = true
[lib]
crate-type = ["cdylib", "lib"]
name = "ore"
[features]
no-entrypoint = []
default = []
[dependencies]
drillx.workspace = true
mpl-token-metadata.workspace = true
ore-api = { path = "../api" }
solana-program.workspace = true
spl-token.workspace = true
spl-associated-token-account.workspace = true
[dev-dependencies]
bs64 = "0.1.2"
rand = "0.8.5"
solana-program-test = "^1.18"
solana-sdk = "^1.18"
tokio = { version = "1.35", features = ["full"] }

View File

@@ -1,21 +1,13 @@
pub mod consts;
pub mod error;
pub mod instruction;
pub mod loaders;
mod loaders;
mod processor;
pub mod state;
pub mod utils;
pub use consts::*;
use instruction::*;
use ore_api::instruction::*;
use processor::*;
use solana_program::{
self, account_info::AccountInfo, declare_id, entrypoint::ProgramResult,
program_error::ProgramError, pubkey::Pubkey,
self, account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
pubkey::Pubkey,
};
declare_id!("oreFHcE6FvJTrsfaYca4mVeZn7J7T6oZS9FAvW9eg4q");
#[cfg(not(feature = "no-entrypoint"))]
solana_program::entrypoint!(process_instruction);
@@ -24,7 +16,7 @@ pub fn process_instruction(
accounts: &[AccountInfo],
data: &[u8],
) -> ProgramResult {
if program_id.ne(&crate::id()) {
if program_id.ne(&ore_api::id()) {
return Err(ProgramError::IncorrectProgramId);
}

View File

@@ -1,15 +1,14 @@
use ore_api::{
consts::*,
state::{Bus, Config, Proof, Treasury},
utils::{AccountDeserialize, Discriminator},
};
use solana_program::{
account_info::AccountInfo, program_error::ProgramError, program_pack::Pack, pubkey::Pubkey,
system_program, sysvar,
};
use spl_token::state::Mint;
use crate::{
state::{Bus, Config, Proof, Treasury},
utils::{AccountDeserialize, Discriminator},
BUS_ADDRESSES, CONFIG_ADDRESS, TREASURY_ADDRESS,
};
/// Errors if:
/// - Account is not a signer.
pub fn load_signer<'a, 'info>(info: &'a AccountInfo<'info>) -> Result<(), ProgramError> {
@@ -32,7 +31,7 @@ pub fn load_bus<'a, 'info>(
id: u64,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.owner.ne(&crate::id()) {
if info.owner.ne(&ore_api::id()) {
return Err(ProgramError::InvalidAccountOwner);
}
@@ -69,7 +68,7 @@ pub fn load_any_bus<'a, 'info>(
info: &'a AccountInfo<'info>,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.owner.ne(&crate::id()) {
if info.owner.ne(&ore_api::id()) {
return Err(ProgramError::InvalidAccountOwner);
}
@@ -102,7 +101,7 @@ pub fn load_config<'a, 'info>(
info: &'a AccountInfo<'info>,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.owner.ne(&crate::id()) {
if info.owner.ne(&ore_api::id()) {
return Err(ProgramError::InvalidAccountOwner);
}
@@ -136,7 +135,7 @@ pub fn load_proof<'a, 'info>(
authority: &Pubkey,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.owner.ne(&crate::id()) {
if info.owner.ne(&ore_api::id()) {
return Err(ProgramError::InvalidAccountOwner);
}
@@ -169,7 +168,7 @@ pub fn load_proof_with_miner<'a, 'info>(
miner: &Pubkey,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.owner.ne(&crate::id()) {
if info.owner.ne(&ore_api::id()) {
return Err(ProgramError::InvalidAccountOwner);
}
@@ -200,7 +199,7 @@ pub fn load_any_proof<'a, 'info>(
info: &'a AccountInfo<'info>,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.owner.ne(&crate::id()) {
if info.owner.ne(&ore_api::id()) {
return Err(ProgramError::InvalidAccountOwner);
}
@@ -229,7 +228,7 @@ pub fn load_treasury<'a, 'info>(
info: &'a AccountInfo<'info>,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.owner.ne(&crate::id()) {
if info.owner.ne(&ore_api::id()) {
return Err(ProgramError::InvalidAccountOwner);
}

View File

@@ -1,12 +1,12 @@
use ore_api::{
consts::*, error::OreError, instruction::ClaimArgs, state::Proof, utils::AccountDeserialize,
};
use solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
pubkey::Pubkey,
};
use crate::{
error::OreError, instruction::ClaimArgs, loaders::*, state::Proof, utils::AccountDeserialize,
MINT_ADDRESS, TREASURY, TREASURY_BUMP,
};
use crate::loaders::*;
/// Claim distributes Ore from the treasury to a miner. Its responsibilies include:
/// 1. Decrement the miner's claimable balance.

View File

@@ -1,9 +1,10 @@
use ore_api::{state::Proof, utils::AccountDeserialize};
use solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
pubkey::Pubkey, system_program,
};
use crate::{loaders::*, state::Proof, utils::AccountDeserialize};
use crate::loaders::*;
/// Close closes a proof account and returns the rent to the owner. Its responsibilities include:
/// 1. Realloc proof account size to 0.

View File

@@ -1,13 +1,13 @@
use ore_api::{
state::{Config, Proof},
utils::AccountDeserialize,
};
use solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
pubkey::Pubkey,
};
use crate::{
loaders::*,
state::{Config, Proof},
utils::AccountDeserialize,
};
use crate::loaders::*;
/// Crown marks an account as the top staker if their balance is greater than the last known top staker.
pub fn process_crown<'a, 'info>(

View File

@@ -1,5 +1,13 @@
use std::mem::size_of;
use ore_api::{
consts::*,
instruction::*,
state::{Bus, Config, Treasury},
utils::create_pda,
utils::AccountDeserialize,
utils::Discriminator,
};
use solana_program::{
account_info::AccountInfo,
entrypoint::ProgramResult,
@@ -10,16 +18,7 @@ use solana_program::{
};
use spl_token::state::Mint;
use crate::{
instruction::*,
loaders::*,
state::{Bus, Config, Treasury},
utils::create_pda,
utils::AccountDeserialize,
utils::Discriminator,
BUS, BUS_COUNT, CONFIG, INITIAL_ADMIN, INITIAL_BASE_REWARD_RATE, METADATA, METADATA_NAME,
METADATA_SYMBOL, METADATA_URI, MINT, MINT_ADDRESS, MINT_NOISE, TOKEN_DECIMALS, TREASURY,
};
use crate::loaders::*;
/// Initialize sets up the Ore program. Its responsibilities include:
/// 1. Initialize the 8 bus accounts.
@@ -54,15 +53,15 @@ pub fn process_initialize<'a, 'info>(
return Err(ProgramError::NotEnoughAccountKeys);
};
load_signer(signer)?;
load_uninitialized_pda(bus_0_info, &[BUS, &[0]], args.bus_0_bump, &crate::id())?;
load_uninitialized_pda(bus_1_info, &[BUS, &[1]], args.bus_1_bump, &crate::id())?;
load_uninitialized_pda(bus_2_info, &[BUS, &[2]], args.bus_2_bump, &crate::id())?;
load_uninitialized_pda(bus_3_info, &[BUS, &[3]], args.bus_3_bump, &crate::id())?;
load_uninitialized_pda(bus_4_info, &[BUS, &[4]], args.bus_4_bump, &crate::id())?;
load_uninitialized_pda(bus_5_info, &[BUS, &[5]], args.bus_5_bump, &crate::id())?;
load_uninitialized_pda(bus_6_info, &[BUS, &[6]], args.bus_6_bump, &crate::id())?;
load_uninitialized_pda(bus_7_info, &[BUS, &[7]], args.bus_7_bump, &crate::id())?;
load_uninitialized_pda(config_info, &[CONFIG], args.config_bump, &crate::id())?;
load_uninitialized_pda(bus_0_info, &[BUS, &[0]], args.bus_0_bump, &ore_api::id())?;
load_uninitialized_pda(bus_1_info, &[BUS, &[1]], args.bus_1_bump, &ore_api::id())?;
load_uninitialized_pda(bus_2_info, &[BUS, &[2]], args.bus_2_bump, &ore_api::id())?;
load_uninitialized_pda(bus_3_info, &[BUS, &[3]], args.bus_3_bump, &ore_api::id())?;
load_uninitialized_pda(bus_4_info, &[BUS, &[4]], args.bus_4_bump, &ore_api::id())?;
load_uninitialized_pda(bus_5_info, &[BUS, &[5]], args.bus_5_bump, &ore_api::id())?;
load_uninitialized_pda(bus_6_info, &[BUS, &[6]], args.bus_6_bump, &ore_api::id())?;
load_uninitialized_pda(bus_7_info, &[BUS, &[7]], args.bus_7_bump, &ore_api::id())?;
load_uninitialized_pda(config_info, &[CONFIG], args.config_bump, &ore_api::id())?;
load_uninitialized_pda(
metadata_info,
&[
@@ -77,9 +76,14 @@ pub fn process_initialize<'a, 'info>(
mint_info,
&[MINT, MINT_NOISE.as_slice()],
args.mint_bump,
&crate::id(),
&ore_api::id(),
)?;
load_uninitialized_pda(
treasury_info,
&[TREASURY],
args.treasury_bump,
&ore_api::id(),
)?;
load_uninitialized_pda(treasury_info, &[TREASURY], args.treasury_bump, &crate::id())?;
load_system_account(treasury_tokens_info, true)?;
load_program(system_program, system_program::id())?;
load_program(token_program, spl_token::id())?;
@@ -110,7 +114,7 @@ pub fn process_initialize<'a, 'info>(
for i in 0..BUS_COUNT {
create_pda(
bus_infos[i],
&crate::id(),
&ore_api::id(),
8 + size_of::<Bus>(),
&[BUS, &[i as u8], &[bus_bumps[i]]],
system_program,
@@ -126,7 +130,7 @@ pub fn process_initialize<'a, 'info>(
// Initialize config
create_pda(
config_info,
&crate::id(),
&ore_api::id(),
8 + size_of::<Config>(),
&[CONFIG, &[args.config_bump]],
system_program,
@@ -144,7 +148,7 @@ pub fn process_initialize<'a, 'info>(
// Initialize treasury
create_pda(
treasury_info,
&crate::id(),
&ore_api::id(),
8 + size_of::<Treasury>(),
&[TREASURY, &[args.treasury_bump]],
system_program,

View File

@@ -1,6 +1,13 @@
use std::mem::size_of;
use drillx::Solution;
use ore_api::{
consts::*,
error::OreError,
instruction::{MineArgs, OreInstruction},
state::{Bus, Config, Proof},
utils::{AccountDeserialize, MineEvent},
};
use solana_program::program::set_return_data;
#[allow(deprecated)]
use solana_program::{
@@ -18,14 +25,7 @@ use solana_program::{
sysvar::{self, instructions::load_current_index, Sysvar},
};
use crate::{
error::OreError,
instruction::{MineArgs, OreInstruction},
loaders::*,
state::{Bus, Config, Proof},
utils::{AccountDeserialize, MineEvent},
EPOCH_DURATION, MIN_DIFFICULTY, ONE_MINUTE, TOLERANCE,
};
use crate::loaders::*;
/// Mine is the primary workhorse instruction of the Ore program. Its responsibilities include:
/// 1. Calculate the hash from the provided nonce.
@@ -162,11 +162,14 @@ pub fn process_mine<'a, 'info>(
proof.total_rewards = proof.total_rewards.saturating_add(reward);
// Log the mined rewards
set_return_data(bytemuck::bytes_of(&MineEvent {
difficulty: difficulty as u64,
reward: reward_actual,
timing: t.saturating_sub(t_liveness),
}));
set_return_data(
MineEvent {
difficulty: difficulty as u64,
reward: reward_actual,
timing: t.saturating_sub(t_liveness),
}
.to_bytes(),
);
Ok(())
}
@@ -193,7 +196,7 @@ fn validate_transaction(msg: &[u8]) -> Result<bool, SanitizeError> {
c += num_accounts * 33;
// Only allow instructions to call ore and the compute budget program.
match read_pubkey(&mut c, msg)? {
crate::ID => {
ore_api::ID => {
c += 2;
if let Ok(ix) = OreInstruction::try_from(read_u8(&mut c, msg)?) {
if let OreInstruction::Mine = ix {

View File

@@ -1,5 +1,11 @@
use std::mem::size_of;
use ore_api::{
consts::*,
instruction::OpenArgs,
state::Proof,
utils::{create_pda, AccountDeserialize, Discriminator},
};
use solana_program::{
account_info::AccountInfo,
blake3::hashv,
@@ -12,14 +18,7 @@ use solana_program::{
sysvar::{self, Sysvar},
};
use crate::{
instruction::OpenArgs,
loaders::*,
state::Proof,
utils::AccountDeserialize,
utils::{create_pda, Discriminator},
PROOF,
};
use crate::loaders::*;
/// Register generates a new hash chain for a prospective miner. Its responsibilities include:
/// 1. Initialize a new proof account.
@@ -48,7 +47,7 @@ pub fn process_open<'a, 'info>(
proof_info,
&[PROOF, signer.key.as_ref()],
args.bump,
&crate::id(),
&ore_api::id(),
)?;
load_program(system_program, system_program::id())?;
load_sysvar(slot_hashes_info, sysvar::slot_hashes::id())?;
@@ -56,7 +55,7 @@ pub fn process_open<'a, 'info>(
// Initialize proof
create_pda(
proof_info,
&crate::id(),
&ore_api::id(),
8 + size_of::<Proof>(),
&[PROOF, signer.key.as_ref(), &[args.bump]],
system_program,

View File

@@ -1,19 +1,17 @@
use ore_api::{
consts::*,
error::OreError,
state::{Bus, Config},
utils::AccountDeserialize,
};
use solana_program::{
account_info::AccountInfo, clock::Clock, entrypoint::ProgramResult,
program_error::ProgramError, program_pack::Pack, pubkey::Pubkey, sysvar::Sysvar,
};
use spl_token::state::Mint;
use crate::{
error::OreError,
loaders::{
load_bus, load_config, load_mint, load_program, load_signer, load_token_account,
load_treasury,
},
state::{Bus, Config},
utils::AccountDeserialize,
BUS_COUNT, BUS_EPOCH_REWARDS, EPOCH_DURATION, MAX_EPOCH_REWARDS, MAX_SUPPLY, MINT_ADDRESS,
SMOOTHING_FACTOR, TARGET_EPOCH_REWARDS, TREASURY, TREASURY_BUMP,
use crate::loaders::{
load_bus, load_config, load_mint, load_program, load_signer, load_token_account, load_treasury,
};
/// Reset sets up the Ore program for the next epoch. Its responsibilities include:

View File

@@ -1,12 +1,10 @@
use ore_api::{consts::*, instruction::StakeArgs, state::Proof, utils::AccountDeserialize};
use solana_program::{
account_info::AccountInfo, clock::Clock, entrypoint::ProgramResult,
program_error::ProgramError, pubkey::Pubkey, sysvar::Sysvar,
};
use crate::{
instruction::StakeArgs, loaders::*, state::Proof, utils::AccountDeserialize, MINT_ADDRESS,
TREASURY_ADDRESS,
};
use crate::loaders::*;
/// Stake deposits Ore into a miner's proof account to earn multiplier. Its responsibilies include:
/// 1. Transfer tokens from the miner to the treasury account.

View File

@@ -1,9 +1,10 @@
use ore_api::{state::Proof, utils::AccountDeserialize};
use solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
pubkey::Pubkey,
};
use crate::{loaders::*, state::Proof, utils::AccountDeserialize};
use crate::loaders::*;
/// Update changes the miner authority on a proof account.
pub fn process_update<'a, 'info>(

View File

@@ -1,13 +1,11 @@
use ore_api::{consts::*, error::OreError, instruction::StakeArgs};
use solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
program_pack::Pack, pubkey::Pubkey,
};
use spl_token::state::Mint;
use crate::{
error::OreError, instruction::StakeArgs, loaders::*, MAX_SUPPLY, MINT_ADDRESS, MINT_V1_ADDRESS,
TREASURY, TREASURY_BUMP,
};
use crate::loaders::*;
/// Upgrade allows a user to migrate a v1 token to a v2 token one-for-one. Its responsibilies include:
/// 1. Burns the v1 tokens.

0
stake/api/Cargo.toml Normal file
View File

0
stake/program/Cargo.toml Normal file
View File