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,