From 60aad1ea70fa08041916e6a11f1518a4623f7f88 Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Fri, 18 Jul 2025 12:19:35 -0700 Subject: [PATCH] log event --- api/src/event.rs | 24 ++++++++++++++++++++++++ program/src/reset.rs | 14 ++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/api/src/event.rs b/api/src/event.rs index 983e356..fa1e894 100644 --- a/api/src/event.rs +++ b/api/src/event.rs @@ -3,9 +3,32 @@ use steel::*; use crate::state::SwapDirection; pub enum OreEvent { + Reset = 0, Swap = 1, } +#[repr(C)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)] +pub struct ResetEvent { + /// The event discriminator. + pub disc: u64, + + /// The authority of the swap. + pub authority: Pubkey, + + /// The block that was opened for trading. + pub block_id: u64, + + /// The start slot of the next block. + pub start_slot: u64, + + /// The end slot of the next block. + pub end_slot: u64, + + /// The timestamp of the event. + pub ts: i64, +} + #[repr(C)] #[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)] pub struct SwapEvent { @@ -58,4 +81,5 @@ impl SwapEvent { } } +event!(ResetEvent); event!(SwapEvent); diff --git a/program/src/reset.rs b/program/src/reset.rs index ab002b2..104b253 100644 --- a/program/src/reset.rs +++ b/program/src/reset.rs @@ -97,6 +97,20 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul block_next.start_slot = clock.slot; block_next.end_slot = clock.slot + config.block_duration; + // Emit event. + program_log( + &[market_info.clone(), ore_program.clone()], + &ResetEvent { + disc: 0, + authority: *signer_info.key, + block_id: block_next.id, + start_slot: block_next.start_slot, + end_slot: block_next.end_slot, + ts: clock.unix_timestamp, + } + .to_bytes(), + )?; + Ok(()) }