event disc

This commit is contained in:
Hardhat Chad
2025-06-18 08:02:27 -07:00
parent e5f5cd6537
commit fbcbd865b4
12 changed files with 47 additions and 4 deletions

View File

@@ -2,9 +2,22 @@ use steel::*;
use crate::state::{RewardConfig, SwapDirection};
pub enum OreEvent {
Swap = 0,
Reward = 1,
Open = 2,
Commit = 3,
Deposit = 4,
Withdraw = 5,
Uncommit = 6,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct SwapEvent {
/// The event discriminator.
pub disc: u64,
/// The authority of the swap.
pub authority: Pubkey,
@@ -48,6 +61,9 @@ impl SwapEvent {
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct RewardEvent {
/// The event discriminator.
pub disc: u64,
/// The amount of ORE distributed as a reward.
pub amount: u64,
@@ -75,6 +91,9 @@ pub enum RewardsType {
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct OpenEvent {
/// The event discriminator.
pub disc: u64,
/// The signer of the open transaction.
pub signer: Pubkey,
@@ -119,6 +138,9 @@ pub struct CloseEvent {
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct CommitEvent {
/// The event discriminator.
pub disc: u64,
/// The authority of the commit transaction.
pub authority: Pubkey,
@@ -138,6 +160,9 @@ pub struct CommitEvent {
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct UncommitEvent {
/// The event discriminator.
pub disc: u64,
/// The authority of the commit transaction.
pub authority: Pubkey,
@@ -157,6 +182,9 @@ pub struct UncommitEvent {
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct DepositEvent {
/// The event discriminator.
pub disc: u64,
/// The authority of the commit transaction.
pub authority: Pubkey,
@@ -176,6 +204,9 @@ pub struct DepositEvent {
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct WithdrawEvent {
/// The event discriminator.
pub disc: u64,
/// The authority of the commit transaction.
pub authority: Pubkey,

View File

@@ -1,6 +1,6 @@
use steel::Pubkey;
use crate::error::OreError;
use crate::{error::OreError, event::OreEvent};
use super::{Market, SwapDirection, TokenType, VirtualLimitOrder};
use crate::event::SwapEvent;
@@ -54,6 +54,7 @@ impl Market {
// Produce swap result.
let base_out = base_via_ask + base_via_curve;
let swap_event = SwapEvent {
disc: OreEvent::Swap as u64,
authority: Pubkey::default(),
block_id: 0,
direction: SwapDirection::Buy as u64,

View File

@@ -1,6 +1,6 @@
use steel::Pubkey;
use crate::error::OreError;
use crate::{error::OreError, event::OreEvent};
use super::{Market, SwapDirection, TokenType, VirtualLimitOrder};
use crate::event::SwapEvent;
@@ -59,6 +59,7 @@ impl Market {
// Produce swap result.
let swap_event = SwapEvent {
disc: OreEvent::Swap as u64,
authority: Pubkey::default(),
block_id: 0,
direction: SwapDirection::Buy as u64,

View File

@@ -1,6 +1,6 @@
use steel::Pubkey;
use crate::error::OreError;
use crate::{error::OreError, event::OreEvent};
use super::{Market, SwapDirection, TokenType, VirtualLimitOrder};
use crate::event::SwapEvent;
@@ -63,6 +63,7 @@ impl Market {
// Produce swap result.
let quote_out = quote_via_bid + quote_via_curve;
let swap_event = SwapEvent {
disc: OreEvent::Swap as u64,
authority: Pubkey::default(),
block_id: 0,
direction: SwapDirection::Sell as u64,

View File

@@ -1,6 +1,6 @@
use steel::Pubkey;
use crate::error::OreError;
use crate::{error::OreError, event::OreEvent};
use super::{Market, SwapDirection, TokenType, VirtualLimitOrder};
use crate::event::SwapEvent;
@@ -61,6 +61,7 @@ impl Market {
// Produce swap result.
let swap_event = SwapEvent {
disc: OreEvent::Swap as u64,
authority: Pubkey::default(),
block_id: 0,
direction: SwapDirection::Sell as u64,

View File

@@ -72,6 +72,7 @@ pub fn process_close(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
// Emit event.
RewardEvent {
disc: OreEvent::Reward as u64,
amount: block.reward.lode_reward,
authority: block.reward.lode_authority,
block_id: block.id,

View File

@@ -96,6 +96,7 @@ pub fn process_commit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
// Emit event.
CommitEvent {
disc: OreEvent::Commit as u64,
authority: *signer_info.key,
block_id: block.id,
amount,

View File

@@ -65,6 +65,7 @@ pub fn process_deposit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResu
// Emit event.
DepositEvent {
disc: OreEvent::Deposit as u64,
authority: *signer_info.key,
block_id: block.id,
amount,

View File

@@ -133,6 +133,7 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
// Emit event.
RewardEvent {
disc: OreEvent::Reward as u64,
amount: motherlode_amount,
authority: miner.authority,
block_id: block.id,
@@ -161,6 +162,7 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
// Emit event.
RewardEvent {
disc: OreEvent::Reward as u64,
amount: nugget_reward,
authority: miner.authority,
block_id: block.id,

View File

@@ -225,6 +225,7 @@ pub fn process_open(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
// Emit event.
OpenEvent {
disc: OreEvent::Open as u64,
id,
start_slot,
signer: *signer_info.key,

View File

@@ -61,6 +61,7 @@ pub fn process_uncommit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
// Emit event.
UncommitEvent {
disc: OreEvent::Uncommit as u64,
authority: *signer_info.key,
block_id: block.id,
commitment: permit.amount,

View File

@@ -55,6 +55,7 @@ pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
// Emit event.
WithdrawEvent {
disc: OreEvent::Withdraw as u64,
authority: *signer_info.key,
block_id: stake.block_id,
amount,