2023-02-15 08:08:55 -08:00
|
|
|
use chrono::{DateTime, Utc};
|
|
|
|
use fixed::types::I80F48;
|
|
|
|
use mango::state::PerpMarket;
|
|
|
|
use serde::Serialize;
|
|
|
|
use solana_program::{pubkey::Pubkey, slot_history::Slot};
|
2023-07-07 00:26:04 -07:00
|
|
|
use solana_sdk::{commitment_config::CommitmentLevel, signature::Signature};
|
2023-03-15 08:13:25 -07:00
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize)]
|
|
|
|
pub enum KeeperInstruction {
|
|
|
|
ConsumeEvents,
|
|
|
|
CachePrice,
|
|
|
|
UpdateRootBanks,
|
|
|
|
CacheRootBanks,
|
|
|
|
UpdatePerpCache,
|
|
|
|
UpdateAndCacheQuoteRootBank,
|
|
|
|
UpdateFunding,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Display for KeeperInstruction {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
match self {
|
|
|
|
KeeperInstruction::ConsumeEvents => write!(f, "ConsumeEvents"),
|
|
|
|
KeeperInstruction::CachePrice => write!(f, "CachePrice"),
|
|
|
|
KeeperInstruction::UpdateRootBanks => write!(f, "UpdateRootBanks"),
|
|
|
|
KeeperInstruction::CacheRootBanks => write!(f, "CacheRootBanks"),
|
|
|
|
KeeperInstruction::UpdatePerpCache => write!(f, "UpdatePerpCache"),
|
|
|
|
KeeperInstruction::UpdateAndCacheQuoteRootBank => {
|
|
|
|
write!(f, "UpdateAndCacheQuoteRootBank")
|
|
|
|
}
|
|
|
|
KeeperInstruction::UpdateFunding => write!(f, "UpdateFunding"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-15 08:08:55 -08:00
|
|
|
|
|
|
|
#[derive(Clone, Serialize)]
|
|
|
|
pub struct TransactionSendRecord {
|
|
|
|
pub signature: Signature,
|
|
|
|
pub sent_at: DateTime<Utc>,
|
|
|
|
pub sent_slot: Slot,
|
2023-03-15 08:13:25 -07:00
|
|
|
pub market_maker: Option<Pubkey>,
|
|
|
|
pub market: Option<Pubkey>,
|
|
|
|
pub keeper_instruction: Option<KeeperInstruction>,
|
2023-02-21 02:04:02 -08:00
|
|
|
pub priority_fees: u64,
|
2023-02-15 08:08:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Serialize)]
|
|
|
|
pub struct TransactionConfirmRecord {
|
|
|
|
pub signature: String,
|
|
|
|
pub sent_slot: Slot,
|
|
|
|
pub sent_at: String,
|
2023-03-14 05:39:19 -07:00
|
|
|
pub confirmed_slot: Option<Slot>,
|
|
|
|
pub confirmed_at: Option<String>,
|
2023-02-15 08:08:55 -08:00
|
|
|
pub successful: bool,
|
2023-03-14 05:39:19 -07:00
|
|
|
pub slot_leader: Option<String>,
|
|
|
|
pub error: Option<String>,
|
2023-03-15 08:13:25 -07:00
|
|
|
pub market_maker: Option<String>,
|
|
|
|
pub market: Option<String>,
|
2023-03-14 05:39:19 -07:00
|
|
|
pub block_hash: Option<String>,
|
|
|
|
pub slot_processed: Option<Slot>,
|
2023-03-15 08:13:25 -07:00
|
|
|
pub keeper_instruction: Option<KeeperInstruction>,
|
2023-02-15 08:08:55 -08:00
|
|
|
pub timed_out: bool,
|
2023-02-21 02:04:02 -08:00
|
|
|
pub priority_fees: u64,
|
2023-02-15 08:08:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct PerpMarketCache {
|
|
|
|
pub order_base_lots: i64,
|
|
|
|
pub price: I80F48,
|
|
|
|
pub price_quote_lots: i64,
|
|
|
|
pub mango_program_pk: Pubkey,
|
|
|
|
pub mango_group_pk: Pubkey,
|
|
|
|
pub mango_cache_pk: Pubkey,
|
|
|
|
pub perp_market_pk: Pubkey,
|
|
|
|
pub perp_market: PerpMarket,
|
2023-02-23 05:41:12 -08:00
|
|
|
pub price_oracle: Pubkey,
|
2023-02-21 00:49:20 -08:00
|
|
|
pub root_bank: Pubkey,
|
|
|
|
pub node_banks: Vec<Pubkey>,
|
2023-02-23 07:24:26 -08:00
|
|
|
pub bids: Pubkey,
|
|
|
|
pub asks: Pubkey,
|
2023-02-15 08:08:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct _TransactionInfo {
|
|
|
|
pub signature: Signature,
|
|
|
|
pub transaction_send_time: DateTime<Utc>,
|
|
|
|
pub send_slot: Slot,
|
|
|
|
pub confirmation_retries: u32,
|
|
|
|
pub error: String,
|
|
|
|
pub confirmation_blockhash: Pubkey,
|
|
|
|
pub leader_confirming_transaction: Pubkey,
|
|
|
|
pub timeout: bool,
|
|
|
|
pub market_maker: Pubkey,
|
|
|
|
pub market: Pubkey,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Serialize)]
|
|
|
|
pub struct BlockData {
|
|
|
|
pub block_hash: String,
|
|
|
|
pub block_slot: Slot,
|
|
|
|
pub block_leader: String,
|
|
|
|
pub total_transactions: u64,
|
2023-06-29 04:49:19 -07:00
|
|
|
pub number_of_mango_simulation_txs: u64,
|
2023-02-15 08:08:55 -08:00
|
|
|
pub block_time: u64,
|
|
|
|
pub cu_consumed: u64,
|
2023-06-29 04:49:19 -07:00
|
|
|
pub cu_consumed_by_mango_simulations: u64,
|
|
|
|
pub commitment: CommitmentLevel,
|
2023-02-15 08:08:55 -08:00
|
|
|
}
|