streak-api 0.3.7

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`         — spendable credits in µUSDC (decremented by `PlaceBet`).
//! * `total_purchased` — lifetime µUSDC spent on tickets (never decreases).
//! * `last_bet_period` — period of the most recent `PlaceBet` (enforces one bet per round).
//!
//! 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,
    /// Available µUSDC credits — incremented by `BuyTicket`, decremented by `PlaceBet`.
    pub balance: u64,
    /// Cumulative µUSDC spent on tickets (never decreases).
    pub total_purchased: u64,
    /// Period of the last `PlaceBet`. 0 = never bet.
    /// Used to prevent double-betting in the same round.
    pub last_bet_period: u64,
}

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

account!(StreakAccount, User);