mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
sniper fee duration
This commit is contained in:
@@ -17,6 +17,7 @@ pub enum OreInstruction {
|
||||
SetAdmin = 8,
|
||||
SetFeeCollector = 9,
|
||||
SetFeeRate = 10,
|
||||
SetSniperFeeDuration = 11,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@@ -95,6 +96,12 @@ pub struct SetFeeRate {
|
||||
pub fee_rate: [u8; 8],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
pub struct SetSniperFeeDuration {
|
||||
pub sniper_fee_duration: [u8; 8],
|
||||
}
|
||||
|
||||
instruction!(OreInstruction, Claim);
|
||||
instruction!(OreInstruction, Open);
|
||||
instruction!(OreInstruction, Close);
|
||||
@@ -106,3 +113,4 @@ instruction!(OreInstruction, Swap);
|
||||
instruction!(OreInstruction, SetAdmin);
|
||||
instruction!(OreInstruction, SetFeeCollector);
|
||||
instruction!(OreInstruction, SetFeeRate);
|
||||
instruction!(OreInstruction, SetSniperFeeDuration);
|
||||
|
||||
@@ -8,6 +8,7 @@ mod reset;
|
||||
mod set_admin;
|
||||
mod set_fee_collector;
|
||||
mod set_fee_rate;
|
||||
mod set_sniper_fee_duration;
|
||||
mod swap;
|
||||
|
||||
use claim::*;
|
||||
@@ -20,6 +21,7 @@ use reset::*;
|
||||
use set_admin::*;
|
||||
use set_fee_collector::*;
|
||||
use set_fee_rate::*;
|
||||
use set_sniper_fee_duration::*;
|
||||
use swap::*;
|
||||
|
||||
use ore_api::instruction::*;
|
||||
@@ -47,6 +49,7 @@ pub fn process_instruction(
|
||||
OreInstruction::SetAdmin => process_set_admin(accounts, data)?,
|
||||
OreInstruction::SetFeeCollector => process_set_fee_collector(accounts, data)?,
|
||||
OreInstruction::SetFeeRate => process_set_fee_rate(accounts, data)?,
|
||||
OreInstruction::SetSniperFeeDuration => process_set_sniper_fee_duration(accounts, data)?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
24
program/src/set_sniper_fee_duration.rs
Normal file
24
program/src/set_sniper_fee_duration.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use ore_api::prelude::*;
|
||||
use steel::*;
|
||||
|
||||
/// Sets the sniper fee duration.
|
||||
pub fn process_set_sniper_fee_duration(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
// Parse data.
|
||||
let args = SetSniperFeeDuration::try_from_bytes(data)?;
|
||||
let new_sniper_fee_duration = u64::from_le_bytes(args.sniper_fee_duration);
|
||||
|
||||
// Load accounts.
|
||||
let [signer_info, config_info, system_program] = accounts else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
signer_info.is_signer()?;
|
||||
let config = config_info
|
||||
.as_account_mut::<Config>(&ore_api::ID)?
|
||||
.assert_mut(|c| c.admin == *signer_info.key)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
|
||||
// Set fee rate.
|
||||
config.sniper_fee_duration = new_sniper_fee_duration;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user