mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
close event
This commit is contained in:
@@ -38,3 +38,5 @@ For line coverage, use llvm-cov:
|
||||
```
|
||||
cargo llvm-cov
|
||||
```
|
||||
|
||||
Congrats on the child. That's great news.
|
||||
|
||||
@@ -97,6 +97,25 @@ pub struct OpenEvent {
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
|
||||
pub struct CloseEvent {
|
||||
/// The authority of the close transaction.
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The id of the block.
|
||||
pub id: u64,
|
||||
|
||||
/// The amount of base (hashpower) liquidity burned.
|
||||
pub burned_base: u64,
|
||||
|
||||
/// The amount of quote (ORE) liquidity burned.
|
||||
pub burned_quote: u64,
|
||||
|
||||
/// The timestamp of the event.
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
|
||||
pub struct CommitEvent {
|
||||
@@ -180,3 +199,4 @@ event!(CommitEvent);
|
||||
event!(DepositEvent);
|
||||
event!(WithdrawEvent);
|
||||
event!(UncommitEvent);
|
||||
event!(CloseEvent);
|
||||
|
||||
@@ -82,22 +82,24 @@ pub fn process_close(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
|
||||
}
|
||||
|
||||
// Burn base liquidity.
|
||||
let base_burned = vault_base.amount();
|
||||
burn_signed(
|
||||
vault_base_info,
|
||||
mint_base_info,
|
||||
market_info,
|
||||
token_program,
|
||||
vault_base.amount(),
|
||||
base_burned,
|
||||
&[MARKET, &market.id.to_le_bytes()],
|
||||
)?;
|
||||
|
||||
// Burn quote liquidity.
|
||||
let quote_burned = vault_quote.amount();
|
||||
burn_signed(
|
||||
vault_quote_info,
|
||||
mint_quote_info,
|
||||
market_info,
|
||||
token_program,
|
||||
vault_quote.amount(),
|
||||
quote_burned,
|
||||
&[MARKET, &market.id.to_le_bytes()],
|
||||
)?;
|
||||
|
||||
@@ -107,5 +109,15 @@ pub fn process_close(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
|
||||
// Close market.
|
||||
market_info.close(signer_info)?;
|
||||
|
||||
// Emit event.
|
||||
CloseEvent {
|
||||
authority: *signer_info.key,
|
||||
id: block.id,
|
||||
burned_base: base_burned,
|
||||
burned_quote: quote_burned,
|
||||
ts: clock.unix_timestamp,
|
||||
}
|
||||
.log_return();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user