streak-api 0.3.15

API for interacting with the STREAK directional markets protocol on Solana
Documentation
//! Per-user account — one PDA per wallet.
//!
//! Created on first `BuyTicket` call.
//!
//! * `balance`         — on-chain ticket credits in µUSDC (from `BuyTicket`).
//! * `total_purchased` — lifetime µUSDC spent on tickets (never decreases).
//! * `last_bet_period` — legacy field (unused; bets are server-authoritative).
//!
//! PDA seeds: `[USER_TICKET, user_pubkey]`

use steel::*;

use super::{user_pda, StreakAccount};

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct User {
    /// Wallet that owns this account.
    pub user: Pubkey,
    /// On-chain ticket credits from `BuyTicket` (mirrored to DB by indexer).
    pub balance: u64,
    /// Cumulative µUSDC spent on tickets (never decreases).
    pub total_purchased: u64,
    /// Legacy — retained for account layout compatibility.
    pub last_bet_period: u64,
}

impl User {
    pub fn pda(user: &Pubkey) -> (Pubkey, u8) {
        user_pda(user)
    }
}

account!(StreakAccount, User);