Deprecate legacy staking (#99)

* add post balance to MineEvent log

* log input hash

* deprecate legacy staking

* update error message

* remove stake from readme

* err msg

* err msg

* update logs and comments

* consolidate logs

* last hash at

* bump version

* deprecate legacy staking

* update error message

* remove stake from readme

* err msg

* err msg

* bump version

---------

Co-authored-by: tonton-sol <19677766+tonton-sol@users.noreply.github.com>
Co-authored-by: alex <aabinaei@gmail.com>
This commit is contained in:
Hardhat Chad
2024-10-24 13:41:03 -05:00
committed by GitHub
parent 22b974bf7b
commit d59b3a2f4d
10 changed files with 12 additions and 67 deletions

View File

@@ -1,44 +1,6 @@
use ore_api::prelude::*;
use steel::*;
/// Stake deposits ORE into a proof account to earn multiplier.
pub fn process_stake(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
// Parse args.
let args = Stake::try_from_bytes(data)?;
let amount = u64::from_le_bytes(args.amount);
// Load accounts.
let [signer_info, proof_info, sender_info, treasury_tokens_info, token_program] = accounts
else {
return Err(ProgramError::NotEnoughAccountKeys);
};
signer_info.is_signer()?;
let proof = proof_info
.to_account_mut::<Proof>(&ore_api::ID)?
.check_mut(|p| p.authority == *signer_info.key)?;
sender_info
.is_writable()?
.to_token_account()?
.check(|t| t.owner == *signer_info.key)?
.check(|t| t.mint == MINT_ADDRESS)?;
treasury_tokens_info.is_writable()?.is_treasury_tokens()?;
token_program.is_program(&spl_token::ID)?;
// Update the proof balance.
proof.balance = proof.balance.checked_add(amount).unwrap();
// Update deposit timestamp.
let clock = Clock::get()?;
proof.last_stake_at = clock.unix_timestamp;
// Transfer tokens from signer to treasury.
transfer(
signer_info,
sender_info,
treasury_tokens_info,
token_program,
amount,
)?;
Ok(())
pub fn process_stake(_accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
panic!("This instruction has been deprecated. Please stake with the boost program instead.");
}