mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
release
This commit is contained in:
@@ -90,7 +90,7 @@ impl Round {
|
|||||||
let r3 = u16::from_le_bytes(rng[4..6].try_into().unwrap());
|
let r3 = u16::from_le_bytes(rng[4..6].try_into().unwrap());
|
||||||
let r4 = u16::from_le_bytes(rng[6..8].try_into().unwrap());
|
let r4 = u16::from_le_bytes(rng[6..8].try_into().unwrap());
|
||||||
let r = r1 ^ r2 ^ r3 ^ r4;
|
let r = r1 ^ r2 ^ r3 ^ r4;
|
||||||
r % 4 == 0
|
r % 3 == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn did_hit_motherlode(&self, rng: u64) -> bool {
|
pub fn did_hit_motherlode(&self, rng: u64) -> bool {
|
||||||
|
|||||||
@@ -737,7 +737,7 @@ async fn get_miners_participating(
|
|||||||
rpc: &RpcClient,
|
rpc: &RpcClient,
|
||||||
round_id: u64,
|
round_id: u64,
|
||||||
) -> Result<Vec<(Pubkey, Miner)>, anyhow::Error> {
|
) -> Result<Vec<(Pubkey, Miner)>, anyhow::Error> {
|
||||||
let filter = RpcFilterType::Memcmp(Memcmp::new_base58_encoded(472, &round_id.to_le_bytes()));
|
let filter = RpcFilterType::Memcmp(Memcmp::new_base58_encoded(512, &round_id.to_le_bytes()));
|
||||||
let miners = get_program_accounts::<Miner>(rpc, ore_api::ID, vec![filter]).await?;
|
let miners = get_program_accounts::<Miner>(rpc, ore_api::ID, vec![filter]).await?;
|
||||||
Ok(miners)
|
Ok(miners)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ pub fn process_checkpoint(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
|
|||||||
rewards_sol = miner.deployed.iter().sum::<u64>();
|
rewards_sol = miner.deployed.iter().sum::<u64>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checkpoint rewards.
|
||||||
|
miner.update_rewards(treasury);
|
||||||
|
|
||||||
// Checkpoint miner.
|
// Checkpoint miner.
|
||||||
miner.checkpoint_id = round.id;
|
miner.checkpoint_id = round.id;
|
||||||
miner.rewards_ore += rewards_ore;
|
miner.rewards_ore += rewards_ore;
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
|
|||||||
.has_seeds(&[AUTOMATION, &authority_info.key.to_bytes()], &ore_api::ID)?;
|
.has_seeds(&[AUTOMATION, &authority_info.key.to_bytes()], &ore_api::ID)?;
|
||||||
let board = board_info
|
let board = board_info
|
||||||
.as_account_mut::<Board>(&ore_api::ID)?
|
.as_account_mut::<Board>(&ore_api::ID)?
|
||||||
.assert_mut(|b| clock.slot >= b.start_slot && clock.slot < b.end_slot)?
|
.assert_mut(|b| clock.slot >= b.start_slot && clock.slot < b.end_slot)?;
|
||||||
.assert_mut(|b| b.round_id < 15115)?;
|
|
||||||
let round = round_info
|
let round = round_info
|
||||||
.as_account_mut::<Round>(&ore_api::ID)?
|
.as_account_mut::<Round>(&ore_api::ID)?
|
||||||
.assert_mut(|r| r.id == board.round_id)?;
|
.assert_mut(|r| r.id == board.round_id)?;
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ use solana_program::log::sol_log;
|
|||||||
use spl_token::amount_to_ui_amount;
|
use spl_token::amount_to_ui_amount;
|
||||||
use steel::*;
|
use steel::*;
|
||||||
|
|
||||||
use crate::AUTHORIZED_ACCOUNTS;
|
|
||||||
|
|
||||||
/// Deposits ORE into the staking contract.
|
/// Deposits ORE into the staking contract.
|
||||||
pub fn process_deposit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
pub fn process_deposit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||||
// Parse data.
|
// Parse data.
|
||||||
@@ -30,11 +28,6 @@ pub fn process_deposit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResu
|
|||||||
system_program.is_program(&system_program::ID)?;
|
system_program.is_program(&system_program::ID)?;
|
||||||
token_program.is_program(&spl_token::ID)?;
|
token_program.is_program(&spl_token::ID)?;
|
||||||
|
|
||||||
// Check whitelist
|
|
||||||
if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) {
|
|
||||||
return Err(trace("Not authorized", OreError::NotAuthorized.into()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open stake account.
|
// Open stake account.
|
||||||
let stake = if stake_info.data_is_empty() {
|
let stake = if stake_info.data_is_empty() {
|
||||||
create_program_account::<Stake>(
|
create_program_account::<Stake>(
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ mod close;
|
|||||||
mod deploy;
|
mod deploy;
|
||||||
mod deposit;
|
mod deposit;
|
||||||
mod log;
|
mod log;
|
||||||
mod migrate_miner;
|
// mod migrate_miner;
|
||||||
mod migrate_treasury;
|
// mod migrate_treasury;
|
||||||
mod reset;
|
mod reset;
|
||||||
mod set_admin;
|
mod set_admin;
|
||||||
mod set_fee_collector;
|
mod set_fee_collector;
|
||||||
@@ -31,8 +31,8 @@ use close::*;
|
|||||||
use deploy::*;
|
use deploy::*;
|
||||||
use deposit::*;
|
use deposit::*;
|
||||||
use log::*;
|
use log::*;
|
||||||
use migrate_miner::*;
|
// use migrate_miner::*;
|
||||||
use migrate_treasury::*;
|
// use migrate_treasury::*;
|
||||||
use reset::*;
|
use reset::*;
|
||||||
use set_admin::*;
|
use set_admin::*;
|
||||||
use set_fee_collector::*;
|
use set_fee_collector::*;
|
||||||
@@ -63,9 +63,9 @@ pub fn process_instruction(
|
|||||||
OreInstruction::Reset => process_reset(accounts, data)?,
|
OreInstruction::Reset => process_reset(accounts, data)?,
|
||||||
|
|
||||||
// Staker
|
// Staker
|
||||||
// OreInstruction::Deposit => process_deposit(accounts, data)?,
|
OreInstruction::Deposit => process_deposit(accounts, data)?,
|
||||||
// OreInstruction::Withdraw => process_withdraw(accounts, data)?,
|
OreInstruction::Withdraw => process_withdraw(accounts, data)?,
|
||||||
// OreInstruction::ClaimYield => process_claim_yield(accounts, data)?,
|
OreInstruction::ClaimYield => process_claim_yield(accounts, data)?,
|
||||||
|
|
||||||
// Admin
|
// Admin
|
||||||
OreInstruction::Bury => process_bury(accounts, data)?,
|
OreInstruction::Bury => process_bury(accounts, data)?,
|
||||||
@@ -75,8 +75,6 @@ pub fn process_instruction(
|
|||||||
|
|
||||||
// Seeker
|
// Seeker
|
||||||
OreInstruction::ClaimSeeker => process_claim_seeker(accounts, data)?,
|
OreInstruction::ClaimSeeker => process_claim_seeker(accounts, data)?,
|
||||||
OreInstruction::MigrateTreasury => process_migrate_treasury(accounts, data)?,
|
|
||||||
OreInstruction::MigrateMiner => process_migrate_miner(accounts, data)?,
|
|
||||||
_ => return Err(ProgramError::InvalidInstructionData),
|
_ => return Err(ProgramError::InvalidInstructionData),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ pub fn process_migrate_treasury(accounts: &[AccountInfo<'_>], data: &[u8]) -> Pr
|
|||||||
treasury.total_staked = total_staked;
|
treasury.total_staked = total_staked;
|
||||||
treasury.total_unclaimed = total_unclaimed;
|
treasury.total_unclaimed = total_unclaimed;
|
||||||
treasury.miner_rewards_factor = miner_rewards_factor;
|
treasury.miner_rewards_factor = miner_rewards_factor;
|
||||||
|
treasury.total_refined = 0;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use solana_program::pubkey;
|
use solana_program::pubkey;
|
||||||
use steel::*;
|
use steel::*;
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
pub const AUTHORIZED_ACCOUNTS: [Pubkey; 1] = [
|
pub const AUTHORIZED_ACCOUNTS: [Pubkey; 1] = [
|
||||||
pubkey!("pqspJ298ryBjazPAr95J9sULCVpZe3HbZTWkbC1zrkS"),
|
pubkey!("pqspJ298ryBjazPAr95J9sULCVpZe3HbZTWkbC1zrkS"),
|
||||||
// pubkey!("By5JFFueXCqeqLk5MzR8ZSwFxASz3SKWX2TVfT1LTFbX"),
|
// pubkey!("By5JFFueXCqeqLk5MzR8ZSwFxASz3SKWX2TVfT1LTFbX"),
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ use solana_program::log::sol_log;
|
|||||||
use spl_token::amount_to_ui_amount;
|
use spl_token::amount_to_ui_amount;
|
||||||
use steel::*;
|
use steel::*;
|
||||||
|
|
||||||
use crate::AUTHORIZED_ACCOUNTS;
|
|
||||||
|
|
||||||
/// Withdraws ORE from the staking contract.
|
/// Withdraws ORE from the staking contract.
|
||||||
pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||||
// Parse data.
|
// Parse data.
|
||||||
@@ -34,11 +32,6 @@ pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
|||||||
token_program.is_program(&spl_token::ID)?;
|
token_program.is_program(&spl_token::ID)?;
|
||||||
associated_token_program.is_program(&spl_associated_token_account::ID)?;
|
associated_token_program.is_program(&spl_associated_token_account::ID)?;
|
||||||
|
|
||||||
// Check whitelist
|
|
||||||
if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) {
|
|
||||||
return Err(trace("Not authorized", OreError::NotAuthorized.into()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open recipient token account.
|
// Open recipient token account.
|
||||||
if recipient_info.data_is_empty() {
|
if recipient_info.data_is_empty() {
|
||||||
create_associated_token_account(
|
create_associated_token_account(
|
||||||
|
|||||||
Reference in New Issue
Block a user