streak-api 0.1.7

API for interacting with the STREAK directional markets protocol on Solana
Documentation
//! Instruction discriminators + payload types.
//!
//! The on-chain program is a thin USDC custody + price-chain layer.
//! All game logic (bets, balances, pools, leaderboards) is off-chain.

use steel::*;

/// One-time setup: creates `Treasury` PDA + treasury USDC ATA and seeds the genesis BTC close
/// price from the Pyth push feed. `payer` must be `ADMIN_ADDRESS`.
///
/// **Accounts:** `payer`, `treasury`, `mint`, `treasury_ata`, `system_program`, `token_program`,
/// `ata_program`, `pyth_price_feed`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Initialize {}

/// User deposits USDC into the treasury. Emits `Deposited { user, amount }` so the server can
/// credit the user's off-chain balance.
///
/// **Accounts:** `user` (signer), `user_ata`, `treasury_ata`, `mint`, `token_program`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Deposit {
    pub amount: [u8; 8],
}

/// Advance the price chain: read `Treasury::last_close_*` as the open reference, read the Pyth
/// push feed as the close price, resolve UP/DOWN, emit `PeriodSettled`, and write the close price
/// back to `Treasury::last_close_*`.
///
/// **Authority**: `EXECUTOR_ADDRESS` (outcome is deterministic so could be permissionless).
///
/// **Accounts:** `authority` (signer), `treasury` (writable), `pyth_price_feed`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct AdminInstantSettlement {
    pub series_id: [u8; 2],
    pub _pad_ix: [u8; 6],
    pub period: [u8; 8],
}

/// Pay `amount` µUSDC from the treasury ATA to `recipient_ata`. Used for winner payouts, jackpot
/// distributions, and withdrawals. Only `EXECUTOR_ADDRESS` may sign.
///
/// **Accounts:** `executor` (signer), `treasury`, `treasury_ata`, `recipient_ata`, `mint`,
/// `token_program`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct AdminPayout {
    pub amount: [u8; 8],
    pub series_id: [u8; 2],
    pub _pad_ix: [u8; 6],
    pub period: [u8; 8],
}

use num_enum::TryFromPrimitive;

#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
pub enum StreakInstruction {
    Initialize = 0,
    Deposit = 1,
    AdminInstantSettlement = 2,
    AdminPayout = 3,
}

instruction!(StreakInstruction, Initialize);
instruction!(StreakInstruction, Deposit);
instruction!(StreakInstruction, AdminInstantSettlement);
instruction!(StreakInstruction, AdminPayout);