streak-api 0.3.1

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 layer.
//! All game logic (bets, balances, pools, leaderboards, settlement) is off-chain.
//! Settlement outcome is derived off-chain via the Pyth Hermes REST API.

use steel::*;

/// One-time setup: creates `Treasury` PDA + treasury USDC ATA. `payer` must be `ADMIN_ADDRESS`.
///
/// **Accounts:** `payer`, `treasury`, `mint`, `treasury_ata`, `system_program`, `token_program`,
/// `ata_program`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Initialize {}

/// User deposits USDC into the treasury. Emits `Deposited { user, amount }` so the indexer 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],
}

/// Route claimed DBC / DAMM v2 trading fees into the treasury and split them on-chain.
///
/// The executor bot claims pool creator/LP fees off-chain via the Meteora SDK, receiving USDC
/// into its own ATA. This instruction then:
///   1. Transfers `amount` µUSDC from the executor's ATA into the treasury ATA (CPI).
///   2. Splits the amount according to `TICKET_*_BPS` and updates `Treasury` counters.
///   3. Forwards the team share (5%) from the treasury ATA to `FEE_COLLECTOR` (CPI).
///   4. Emits `FeesRouted`.
///
/// This keeps fee accounting on-chain without requiring knowledge of Meteora's internal CPI
/// interfaces — the executor handles the protocol-specific claim, we handle the routing.
///
/// **Accounts:** `executor` (signer), `executor_ata`, `treasury`, `treasury_ata`,
///               `fee_collector_ata`, `mint`, `token_program`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct AdminRouteFees {
    pub amount: [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,
    AdminRouteFees = 2,
    AdminPayout = 3,
}

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