streak-api 0.3.8

API for interacting with the STREAK directional markets protocol on Solana
Documentation
//! On-chain events (`sol_log_data` via Steel `event!` / `.log()`).
//!
//! ## Event contract
//!
//! | Event | Trigger | Observer |
//! |---|---|---|
//! | `TicketPurchased` | `BuyTicket` ix | Indexer records ticket; bot uses for payout calculation |
//! | `FeesRouted` | `AdminRouteFees` ix | Off-chain ledger updates protocol revenue |
//! | `Paid` | `AdminPayout` ix | Bot confirms payout in DB |
//! | `Initialized` | `Initialize` ix | One-time setup confirmation |

use steel::*;

/// Emitted by `Initialize`.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Initialized {
    pub admin: Pubkey,
}

/// Emitted by `BuyTicket`.
///
/// Indexer reads this event to credit the user's spendable balance in `user_balances`.
/// Buying tickets is separate from placing a bet; the bet is placed off-chain by the server.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct TicketPurchased {
    /// Wallet that purchased the credits.
    pub user: Pubkey,
    /// µUSDC spent (gross, before split).
    pub amount: u64,
}

/// Emitted by `AdminRouteFees`.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct FeesRouted {
    pub amount: u64,
    pub daily_share: u64,
    pub weekly_share: u64,
    pub buyback_share: u64,
    pub team_share: u64,
}

/// Emitted by `AdminPayout`.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Paid {
    pub recipient: Pubkey,
    pub amount: u64,
    pub series_id: u16,
    pub _pad: [u8; 6],
    pub period: u64,
}

/// Emitted by `PlaceBet`.
///
/// Cost is always `TICKET_PRICE_MICROS` (1 USDC) — no amount field needed.
/// Indexer reads this to insert into `bets` and update `markets` pool totals.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct BetPlaced {
    /// Wallet that placed the bet.
    pub user: Pubkey,
    /// 5-min period: `floor(unix_ts / 300)`.
    pub period: u64,
    /// 0 = UP, 1 = DOWN.
    pub side: u8,
    pub _pad: [u8; 7],
}

event!(Initialized);
event!(TicketPurchased);
event!(BetPlaced);
event!(FeesRouted);
event!(Paid);