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)]
8pub struct Vault {
9    pub owner: Vec<u8>,
10    pub bump: u8,
11    pub spend_limit_per_transaction: u64,
12    pub spend_limit_per_timeframe: u64,
13    pub remaining_spend_limit_per_timeframe: u64,
14    pub next_timeframe_reset_timestamp: u64,
15    pub timeframe_in_seconds: u64,
16}
17
18/// Time lock used by withdraw and spend-limit order accounts.
19#[derive(Serialize, Deserialize, Clone, Debug)]
20#[serde(rename_all(serialize = "camelCase", deserialize = "snake_case"))]
21pub struct TimeLock {
22    pub owner: Pubkey,
23    pub payer: Pubkey,
24    pub release_slot: u64,
25}
26
27#[derive(Serialize, Deserialize, Clone, Debug)]
28#[repr(u8)]
29pub enum ProtocolId {
30    Drift = 0,
31    Kamino = 1,
32}
33
34/// Pending withdraw order account stored in Redis.
35#[derive(Serialize, Deserialize, Clone, Debug)]
36#[serde(rename_all(serialize = "camelCase", deserialize = "snake_case"))]
37pub struct WithdrawOrderAccount {
38    pub time_lock: TimeLock,
39    pub protocol_id: ProtocolId,
40    pub asset_id: u16,
41    pub amount_base_units: u64,
42    pub reduce_only: bool,
43    pub destination: Pubkey,
44}
45
46/// Pending spend-limits order account stored in Redis.
47#[derive(Serialize, Deserialize, Clone, Debug)]
48#[serde(rename_all(serialize = "camelCase", deserialize = "snake_case"))]
49pub struct SpendLimitsOrderAccount {
50    pub time_lock: TimeLock,
51    pub spend_limit_per_transaction: u64,
52    pub spend_limit_per_timeframe: u64,
53    pub timeframe_in_seconds: u64,
54    pub next_timeframe_reset_timestamp: u64,
55}
56
57/// SPL token account data for a deposit address, serialised to Redis by the indexer.
58///
59/// Matches the indexer's `TokenAccount` struct — only the fields we need.
60/// Extra fields in the Redis payload are silently ignored by serde.
61#[derive(Serialize, Deserialize, Clone, Debug)]
62pub struct DepositAddressSplAccount {
63    pub mint: Pubkey,
64    pub owner: Pubkey,
65    pub amount: u64,
66}
67
68/// Native SOL account data for a deposit address, serialised to Redis by the indexer.
69///
70/// Matches the indexer's `DepositSolBalance` struct.
71#[derive(Serialize, Deserialize, Clone, Debug)]
72pub struct DepositAddressSolAccount {
73    pub lamports: u64,
74}