mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
event
This commit is contained in:
@@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
use steel::*;
|
||||
pub enum OreEvent {
|
||||
Reset = 0,
|
||||
Bury = 1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@@ -44,4 +45,24 @@ pub struct ResetEvent {
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
|
||||
pub struct BuryEvent {
|
||||
/// The event discriminator.
|
||||
pub disc: u64,
|
||||
|
||||
/// The amount of ORE buried.
|
||||
pub ore_amount: u64,
|
||||
|
||||
/// The amount of SOL swapped.
|
||||
pub sol_amount: u64,
|
||||
|
||||
/// The new circulating supply of ORE.
|
||||
pub new_circulating_supply: u64,
|
||||
|
||||
/// The timestamp of the event.
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
event!(ResetEvent);
|
||||
event!(BuryEvent);
|
||||
|
||||
@@ -209,6 +209,7 @@ const PROTOCOL_TOKEN_FEE: Pubkey = pubkey!("6kzYo2LMo2q2bkLAD8ienoG5NC1MkNXNTfm8
|
||||
// let [pool, user_source_token, user_destination_token, a_vault, b_vault, a_token_vault, b_token_vault, a_vault_lp_mint, b_vault_lp_mint, a_vault_lp, b_vault_lp, protocol_token_fee, user_key, vault_program, token_program] =
|
||||
|
||||
pub fn bury(signer: Pubkey, min_amount_out: u64) -> Instruction {
|
||||
let board_address = board_pda().0;
|
||||
let config_address = config_pda().0;
|
||||
let mint_address = MINT_ADDRESS;
|
||||
let treasury_address = TREASURY_ADDRESS;
|
||||
@@ -221,6 +222,7 @@ pub fn bury(signer: Pubkey, min_amount_out: u64) -> Instruction {
|
||||
accounts: vec![
|
||||
// Ore accounts
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(board_address, false),
|
||||
AccountMeta::new_readonly(config_address, false),
|
||||
AccountMeta::new(mint_address, false),
|
||||
AccountMeta::new(treasury_address, false),
|
||||
@@ -228,6 +230,7 @@ pub fn bury(signer: Pubkey, min_amount_out: u64) -> Instruction {
|
||||
AccountMeta::new(treasury_sol_address, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(crate::ID, false),
|
||||
AccountMeta::new_readonly(meteora_pools_sdk::programs::AMM_ID, false),
|
||||
// Meteora accounts
|
||||
AccountMeta::new(POOL_ADDRESS, false),
|
||||
|
||||
@@ -12,13 +12,14 @@ pub fn process_bury(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
let min_amount_out = u64::from_le_bytes(args.min_amount_out);
|
||||
|
||||
// Load accounts.
|
||||
let (ore_accounts, meteora_accounts) = accounts.split_at(9);
|
||||
let [signer_info, config_info, mint_info, treasury_info, treasury_ore_info, treasury_sol_info, system_program, token_program, meteora_program] =
|
||||
let (ore_accounts, meteora_accounts) = accounts.split_at(11);
|
||||
let [signer_info, board_info, config_info, mint_info, treasury_info, treasury_ore_info, treasury_sol_info, system_program, token_program, ore_program, meteora_program] =
|
||||
ore_accounts
|
||||
else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
signer_info.is_signer()?;
|
||||
board_info.as_account_mut::<Board>(&ore_api::ID)?;
|
||||
config_info
|
||||
.as_account::<Config>(&ore_api::ID)?
|
||||
.assert(|c| c.admin == *signer_info.key)?;
|
||||
@@ -29,6 +30,7 @@ pub fn process_bury(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
treasury_sol_info.as_associated_token_account(treasury_info.key, &SOL_MINT)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
token_program.is_program(&spl_token::ID)?;
|
||||
ore_program.is_program(&ore_api::ID)?;
|
||||
meteora_program.is_program(&meteora_pools_sdk::programs::AMM_ID)?;
|
||||
|
||||
// Load meteora accounts.
|
||||
@@ -107,5 +109,19 @@ pub fn process_bury(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
.as_str(),
|
||||
);
|
||||
|
||||
// Emit event.
|
||||
let mint = mint_info.as_mint()?;
|
||||
program_log(
|
||||
&[board_info.clone(), ore_program.clone()],
|
||||
BuryEvent {
|
||||
disc: 1,
|
||||
ore_amount: burn_amount,
|
||||
sol_amount: pre_swap_sol_balance,
|
||||
new_circulating_supply: mint.supply(),
|
||||
ts: Clock::get()?.unix_timestamp,
|
||||
}
|
||||
.to_bytes(),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user