Skip to main content

streak_api/
instruction.rs

1//! Instruction discriminators + payload types.
2//!
3//! The on-chain program is a thin USDC custody layer.
4//! All game logic (bets, balances, pools, leaderboards, settlement) is off-chain.
5//! Settlement outcome is derived off-chain via the Pyth Hermes REST API.
6
7use steel::*;
8
9/// One-time setup: creates `Treasury` PDA + treasury USDC ATA. `payer` must be `ADMIN_ADDRESS`.
10///
11/// **Accounts:** `payer`, `treasury`, `mint`, `treasury_ata`, `system_program`, `token_program`,
12/// `ata_program`.
13#[repr(C)]
14#[derive(Clone, Copy, Debug, Pod, Zeroable)]
15pub struct Initialize {}
16
17/// User deposits USDC into the treasury. Emits `Deposited { user, amount }` so the indexer can
18/// credit the user's off-chain balance.
19///
20/// **Accounts:** `user` (signer), `user_ata`, `treasury_ata`, `mint`, `token_program`.
21#[repr(C)]
22#[derive(Clone, Copy, Debug, Pod, Zeroable)]
23pub struct Deposit {
24    pub amount: [u8; 8],
25}
26
27/// Pay `amount` µUSDC from the treasury ATA to `recipient_ata`. Used for winner payouts, jackpot
28/// distributions, and withdrawals. Only `EXECUTOR_ADDRESS` may sign.
29///
30/// **Accounts:** `executor` (signer), `treasury`, `treasury_ata`, `recipient_ata`, `mint`,
31/// `token_program`.
32#[repr(C)]
33#[derive(Clone, Copy, Debug, Pod, Zeroable)]
34pub struct AdminPayout {
35    pub amount: [u8; 8],
36    pub series_id: [u8; 2],
37    pub _pad_ix: [u8; 6],
38    pub period: [u8; 8],
39}
40
41use num_enum::TryFromPrimitive;
42
43#[repr(u8)]
44#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
45pub enum StreakInstruction {
46    Initialize = 0,
47    Deposit = 1,
48    AdminPayout = 3,
49}
50
51instruction!(StreakInstruction, Initialize);
52instruction!(StreakInstruction, Deposit);
53instruction!(StreakInstruction, AdminPayout);