This commit is contained in:
Hardhat Chad
2025-06-14 16:07:23 -07:00
parent b24883d8ff
commit 9d4c69c8f6
5 changed files with 120 additions and 0 deletions

View File

@@ -97,6 +97,86 @@ pub struct OpenEvent {
pub ts: i64,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct CommitEvent {
/// The authority of the commit transaction.
pub authority: Pubkey,
/// The id of the block.
pub block_id: u64,
/// The amount of hashpower committed.
pub amount: u64,
/// The total amount of hashpower this user has committed.
pub commitment: u64,
/// The timestamp of the event.
pub ts: i64,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct UncommitEvent {
/// The authority of the commit transaction.
pub authority: Pubkey,
/// The id of the block.
pub block_id: u64,
/// The amount of hashpower committed.
pub amount: u64,
/// The total amount of hashpower this user has committed.
pub commitment: u64,
/// The timestamp of the event.
pub ts: i64,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct DepositEvent {
/// The authority of the commit transaction.
pub authority: Pubkey,
/// The id of the block.
pub block_id: u64,
/// The amount of ORE collateral deposited.
pub amount: u64,
/// The total amount of ORE this user has deposited as collateral.
pub capacity: u64,
/// The timestamp of the event.
pub ts: i64,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct WithdrawEvent {
/// The authority of the commit transaction.
pub authority: Pubkey,
/// The id of the block.
pub block_id: u64,
/// The amount of ORE collateral withdrawn.
pub amount: u64,
/// The total amount of ORE this user has deposited as collateral.
pub capacity: u64,
/// The timestamp of the event.
pub ts: i64,
}
event!(SwapEvent);
event!(RewardEvent);
event!(OpenEvent);
event!(CommitEvent);
event!(DepositEvent);
event!(WithdrawEvent);
event!(UncommitEvent);

View File

@@ -94,5 +94,15 @@ pub fn process_commit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
// Update block.
permit.amount += amount;
// Emit event.
CommitEvent {
authority: *signer_info.key,
block_id: block.id,
amount,
commitment: permit.amount,
ts: clock.unix_timestamp,
}
.log_return();
Ok(())
}

View File

@@ -63,5 +63,15 @@ pub fn process_deposit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResu
amount,
)?;
// Emit event.
DepositEvent {
authority: *signer_info.key,
block_id: block.id,
amount,
capacity: stake.capacity,
ts: clock.unix_timestamp,
}
.log_return();
Ok(())
}

View File

@@ -59,5 +59,15 @@ pub fn process_uncommit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
permit_info.close(signer_info)?;
}
// Emit event.
UncommitEvent {
authority: *signer_info.key,
block_id: block.id,
commitment: permit.amount,
amount,
ts: clock.unix_timestamp,
}
.log_return();
Ok(())
}

View File

@@ -53,5 +53,15 @@ pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
stake_info.close(signer_info)?;
}
// Emit event.
WithdrawEvent {
authority: *signer_info.key,
block_id: stake.block_id,
amount,
capacity: stake.capacity,
ts: clock.unix_timestamp,
}
.log_return();
Ok(())
}