streak-api 0.1.3

API for interacting with the STREAK directional markets protocol on Solana
//! Per-player **`unstaked_micros`** / **`tickets`** plus [**`Market`**](crate::state::Market) win streak (`ledger` PDA).
//! Win streak is consecutive wins on **the same** **`series_id`** with **`period`** stepping by **`+1`**.

use steel::*;

use super::{ledger_pda, StreakAccount};

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Ledger {
    pub authority: Pubkey,
    /// Whole tickets credited on **`BuyTickets`**: post–team remainder divided by [`TICKET_MICROS`](crate::consts::TICKET_MICROS) (integer division).
    pub tickets: u64,
    /// Post–team-cut USDC (base units) credited on **`BuyTickets`** and debited when spending tickets on **`PlaceBet`**.
    pub unstaked_micros: u64,
    /// Consecutive winning periods on **`last_win_series_id`** after **`ExecutorTreasury`** (**`distribute`**); ledger-side hint for off-chain leaderboard.
    pub win_streak: u64,
    /// Last **`Market::period`** the user claimed as winner; `0` = none.
    pub last_win_period: u64,
    /// **`series_id`** for **`last_win_period`** (streak concurrency key).
    pub last_win_series_id: u16,
    pub _pad_ledger: [u8; 6],
}

impl Ledger {
    pub fn pda(authority: Pubkey) -> (Pubkey, u8) {
        ledger_pda(authority)
    }
}

account!(StreakAccount, Ledger);