|
| 1 | +use anchor_lang::prelude::*; |
| 2 | + |
| 3 | +#[derive(AnchorSerialize, AnchorDeserialize)] |
| 4 | +pub struct CommonFields { |
| 5 | + pub slot: u64, |
| 6 | + pub unix_timestamp: i64, |
| 7 | + pub liquidation_seq_num: u64, |
| 8 | +} |
| 9 | + |
| 10 | +impl CommonFields { |
| 11 | + pub fn new(clock: &Clock, liquidation_seq_num: u64) -> Self { |
| 12 | + Self { |
| 13 | + slot: clock.slot, |
| 14 | + unix_timestamp: clock.unix_timestamp, |
| 15 | + liquidation_seq_num, |
| 16 | + } |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +#[event] |
| 21 | +pub struct LiquidationCreatedEvent { |
| 22 | + pub common: CommonFields, |
| 23 | + pub liquidation: Pubkey, |
| 24 | + pub create_key: Pubkey, |
| 25 | + pub record_authority: Pubkey, |
| 26 | + pub liquidation_authority: Pubkey, |
| 27 | + pub base_mint: Pubkey, |
| 28 | + pub quote_mint: Pubkey, |
| 29 | + pub duration_seconds: u32, |
| 30 | + pub pda_bump: u8, |
| 31 | +} |
| 32 | + |
| 33 | +#[event] |
| 34 | +pub struct LiquidationActivatedEvent { |
| 35 | + pub common: CommonFields, |
| 36 | + pub liquidation: Pubkey, |
| 37 | + pub total_quote_funded: u64, |
| 38 | + pub started_at: i64, |
| 39 | +} |
| 40 | + |
| 41 | +#[event] |
| 42 | +pub struct RefundRecordSetEvent { |
| 43 | + pub common: CommonFields, |
| 44 | + pub liquidation: Pubkey, |
| 45 | + pub refund_record: Pubkey, |
| 46 | + pub recipient: Pubkey, |
| 47 | + pub base_assigned: u64, |
| 48 | + pub quote_refundable: u64, |
| 49 | + pub liquidation_total_base_assigned: u64, |
| 50 | + pub liquidation_total_quote_refundable: u64, |
| 51 | + pub pda_bump: u8, |
| 52 | +} |
| 53 | + |
| 54 | +#[event] |
| 55 | +pub struct RefundEvent { |
| 56 | + pub common: CommonFields, |
| 57 | + pub liquidation: Pubkey, |
| 58 | + pub refund_record: Pubkey, |
| 59 | + pub recipient: Pubkey, |
| 60 | + pub base_burned: u64, |
| 61 | + pub quote_refunded: u64, |
| 62 | + pub post_record_base_burned: u64, |
| 63 | + pub post_record_quote_refunded: u64, |
| 64 | + pub post_liquidation_total_base_burned: u64, |
| 65 | + pub post_liquidation_total_quote_refunded: u64, |
| 66 | +} |
| 67 | + |
| 68 | +#[event] |
| 69 | +pub struct WithdrawRemainingQuoteEvent { |
| 70 | + pub common: CommonFields, |
| 71 | + pub liquidation: Pubkey, |
| 72 | + pub liquidation_authority: Pubkey, |
| 73 | + pub amount: u64, |
| 74 | +} |
0 commit comments