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/// Route claimed DBC / DAMM v2 trading fees into the treasury and split them on-chain.
28///
29/// The executor bot claims pool creator/LP fees off-chain via the Meteora SDK, receiving USDC
30/// into its own ATA. This instruction then:
31/// 1. Transfers `amount` µUSDC from the executor's ATA into the treasury ATA (CPI).
32/// 2. Splits the amount according to `TICKET_*_BPS` and updates `Treasury` counters.
33/// 3. Forwards the team share (5%) from the treasury ATA to `FEE_COLLECTOR` (CPI).
34/// 4. Emits `FeesRouted`.
35///
36/// This keeps fee accounting on-chain without requiring knowledge of Meteora's internal CPI
37/// interfaces — the executor handles the protocol-specific claim, we handle the routing.
38///
39/// **Accounts:** `executor` (signer), `executor_ata`, `treasury`, `treasury_ata`,
40/// `fee_collector_ata`, `mint`, `token_program`.
41#[repr(C)]
42#[derive(Clone, Copy, Debug, Pod, Zeroable)]
43pub struct AdminRouteFees {
44 pub amount: [u8; 8],
45}
46
47/// Pay `amount` µUSDC from the treasury ATA to `recipient_ata`. Used for winner payouts, jackpot
48/// distributions, and withdrawals. Only `EXECUTOR_ADDRESS` may sign.
49///
50/// **Accounts:** `executor` (signer), `treasury`, `treasury_ata`, `recipient_ata`, `mint`,
51/// `token_program`.
52#[repr(C)]
53#[derive(Clone, Copy, Debug, Pod, Zeroable)]
54pub struct AdminPayout {
55 pub amount: [u8; 8],
56 pub series_id: [u8; 2],
57 pub _pad_ix: [u8; 6],
58 pub period: [u8; 8],
59}
60
61use num_enum::TryFromPrimitive;
62
63#[repr(u8)]
64#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
65pub enum StreakInstruction {
66 Initialize = 0,
67 Deposit = 1,
68 AdminRouteFees = 2,
69 AdminPayout = 3,
70}
71
72instruction!(StreakInstruction, Initialize);
73instruction!(StreakInstruction, Deposit);
74instruction!(StreakInstruction, AdminRouteFees);
75instruction!(StreakInstruction, AdminPayout);