mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
stake
This commit is contained in:
@@ -3,8 +3,6 @@ use solana_program::log::sol_log;
|
||||
use spl_token::amount_to_ui_amount;
|
||||
use steel::*;
|
||||
|
||||
use crate::AUTHORIZED_ACCOUNTS;
|
||||
|
||||
/// Claims yield from the staking contract.
|
||||
pub fn process_claim_yield(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
// Parse data.
|
||||
@@ -34,11 +32,6 @@ pub fn process_claim_yield(accounts: &[AccountInfo<'_>], data: &[u8]) -> Program
|
||||
token_program.is_program(&spl_token::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.
|
||||
if recipient_info.data_is_empty() {
|
||||
create_associated_token_account(
|
||||
|
||||
@@ -61,6 +61,9 @@ pub fn process_deposit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResu
|
||||
.assert_mut(|s| s.authority == *signer_info.key)?
|
||||
};
|
||||
|
||||
// Only allow deposits from seekers.
|
||||
assert!(stake.is_seeker == 1, "Only seekers can deposit stake");
|
||||
|
||||
// Deposit into stake account.
|
||||
let amount = stake.deposit(amount, &clock, treasury, &sender);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ mod deploy;
|
||||
mod deposit;
|
||||
mod initialize;
|
||||
mod log;
|
||||
mod migrate_miner;
|
||||
mod reset;
|
||||
mod set_admin;
|
||||
mod set_fee_collector;
|
||||
@@ -28,7 +27,6 @@ use deploy::*;
|
||||
use deposit::*;
|
||||
use initialize::*;
|
||||
use log::*;
|
||||
use migrate_miner::*;
|
||||
use reset::*;
|
||||
use set_admin::*;
|
||||
use set_fee_collector::*;
|
||||
@@ -70,7 +68,6 @@ pub fn process_instruction(
|
||||
|
||||
// Seeker
|
||||
OreInstruction::ClaimSeeker => process_claim_seeker(accounts, data)?,
|
||||
OreInstruction::MigrateMiner => process_migrate_miner(accounts, data)?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
use ore_api::prelude::*;
|
||||
use steel::*;
|
||||
|
||||
/// Sets the admin.
|
||||
pub fn process_migrate_miner(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
|
||||
// Load accounts.
|
||||
let [signer_info, config_info, miner_info, system_program] = accounts else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
signer_info.is_signer()?;
|
||||
let miner = miner_info.as_account_mut::<Miner>(&ore_api::ID)?;
|
||||
let config = config_info
|
||||
.as_account_mut::<Config>(&ore_api::ID)?
|
||||
.assert_mut_err(
|
||||
|c| c.admin == *signer_info.key,
|
||||
OreError::NotAuthorized.into(),
|
||||
)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
|
||||
// Set seeker activation flag.
|
||||
config.is_seeker_activation_enabled = 0;
|
||||
|
||||
// No op
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
use solana_program::pubkey;
|
||||
use steel::*;
|
||||
|
||||
pub const AUTHORIZED_ACCOUNTS: [Pubkey; 1] =
|
||||
[pubkey!("pqspJ298ryBjazPAr95J9sULCVpZe3HbZTWkbC1zrkS")];
|
||||
pub const AUTHORIZED_ACCOUNTS: [Pubkey; 3] = [
|
||||
pubkey!("pqspJ298ryBjazPAr95J9sULCVpZe3HbZTWkbC1zrkS"),
|
||||
pubkey!("By5JFFueXCqeqLk5MzR8ZSwFxASz3SKWX2TVfT1LTFbX"),
|
||||
pubkey!("5Nb2ibzu4bWrwis2vNVD4mJprt6KTchzW6wgbVWM2PkY"),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user