Skip to main content

streak_api/state/
user.rs

1//! Per-user account — one PDA per wallet.
2//!
3//! Created by the first `BuyTicket` call.
4//!
5//! * `balance`         — spendable credits (debited on `PlaceBet`).
6//! * `total_purchased` — lifetime USDC spent on tickets (never decreases).
7//!
8//! PDA seeds: `[USER_TICKET, user_pubkey]`
9
10use steel::*;
11
12use super::{user_pda, StreakAccount};
13
14#[repr(C)]
15#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
16pub struct User {
17    /// Wallet that owns this account.
18    pub user: Pubkey,
19    /// Available µUSDC credits — incremented by `BuyTicket`, decremented by `PlaceBet`.
20    pub balance: u64,
21    /// Cumulative µUSDC spent on tickets (never decreases).
22    pub total_purchased: u64,
23}
24
25impl User {
26    pub fn pda(user: &Pubkey) -> (Pubkey, u8) {
27        user_pda(user)
28    }
29}
30
31account!(StreakAccount, User);