Skip to main content

pyra_types/
pyra.rs

1use serde::{Deserialize, Serialize};
2use solana_pubkey::Pubkey;
3
4/// Pyra vault account stored in Redis by the indexer.
5///
6/// Contains spend limit configuration and the vault owner.
7#[derive(Serialize, Deserialize, Clone, Debug, Default)]
8pub struct Vault {
9    /// Owner public key as raw bytes.
10    #[serde(default)]
11    pub owner: Vec<u8>,
12
13    #[serde(default)]
14    pub bump: u8,
15
16    #[serde(default)]
17    pub spend_limit_per_transaction: u64,
18
19    #[serde(default)]
20    pub spend_limit_per_timeframe: u64,
21
22    #[serde(default)]
23    pub remaining_spend_limit_per_timeframe: u64,
24
25    #[serde(default)]
26    pub next_timeframe_reset_timestamp: u64,
27
28    #[serde(default)]
29    pub timeframe_in_seconds: u64,
30}
31
32/// Time lock used by withdraw and spend-limit order accounts.
33#[derive(Serialize, Deserialize, Clone, Debug)]
34pub struct TimeLock {
35    pub owner: Pubkey,
36    pub payer: Pubkey,
37    pub release_slot: u64,
38}
39
40/// Pending withdraw order account stored in Redis.
41#[derive(Serialize, Deserialize, Clone, Debug)]
42pub struct WithdrawOrderAccount {
43    pub time_lock: TimeLock,
44    pub amount_base_units: u64,
45    pub drift_market_index: u16,
46    pub reduce_only: bool,
47    pub destination: Pubkey,
48}
49
50/// Pending spend-limits order account stored in Redis.
51#[derive(Serialize, Deserialize, Clone, Debug)]
52pub struct SpendLimitsOrderAccount {
53    pub time_lock: TimeLock,
54    pub spend_limit_per_transaction: u64,
55    pub spend_limit_per_timeframe: u64,
56    pub timeframe_in_seconds: u64,
57    pub next_timeframe_reset_timestamp: u64,
58}