pyra-types 0.4.2

Shared account types for Pyra services — Drift positions, spot markets, vaults, and Redis cache wrappers
Documentation
use serde::{Deserialize, Serialize};
use solana_pubkey::Pubkey;

/// Pyra vault account stored in Redis by the indexer.
///
/// Contains spend limit configuration and the vault owner.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Vault {
    pub owner: Vec<u8>,
    pub bump: u8,
    pub spend_limit_per_transaction: u64,
    pub spend_limit_per_timeframe: u64,
    pub remaining_spend_limit_per_timeframe: u64,
    pub next_timeframe_reset_timestamp: u64,
    pub timeframe_in_seconds: u64,
}

/// Time lock used by withdraw and spend-limit order accounts.
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all(serialize = "camelCase", deserialize = "snake_case"))]
pub struct TimeLock {
    pub owner: Pubkey,
    pub payer: Pubkey,
    pub release_slot: u64,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[repr(u8)]
pub enum ProtocolId {
    Drift = 0,
    Kamino = 1,
}

/// Pending withdraw order account stored in Redis.
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all(serialize = "camelCase", deserialize = "snake_case"))]
pub struct WithdrawOrderAccount {
    pub time_lock: TimeLock,
    pub protocol_id: ProtocolId,
    pub asset_id: u16,
    pub amount_base_units: u64,
    pub reduce_only: bool,
    pub destination: Pubkey,
}

/// Pending spend-limits order account stored in Redis.
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all(serialize = "camelCase", deserialize = "snake_case"))]
pub struct SpendLimitsOrderAccount {
    pub time_lock: TimeLock,
    pub spend_limit_per_transaction: u64,
    pub spend_limit_per_timeframe: u64,
    pub timeframe_in_seconds: u64,
    pub next_timeframe_reset_timestamp: u64,
}

/// SPL token account data for a deposit address, serialised to Redis by the indexer.
///
/// Matches the indexer's `TokenAccount` struct — only the fields we need.
/// Extra fields in the Redis payload are silently ignored by serde.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct DepositAddressSplAccount {
    pub mint: Pubkey,
    pub owner: Pubkey,
    pub amount: u64,
}

/// Native SOL account data for a deposit address, serialised to Redis by the indexer.
///
/// Matches the indexer's `DepositSolBalance` struct.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct DepositAddressSolAccount {
    pub lamports: u64,
}