1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! Instruction discriminators + payload types (**Ore**: single `instruction.rs`).
use *;
/// One-time **`Initialize`**: creates **`Treasury`** PDA + treasury USDC ATA. Economics and routing pubkeys are [`crate::consts`] (**`FEE_COLLECTOR`** for team-fee SPL legs). **`payer`** must be [`ADMIN_ADDRESS`](crate::consts::ADMIN_ADDRESS).
///
/// **Accounts:** **`payer`**, **`treasury`**, **`mint`**, **`treasury_ata`**, **`system_program`**, **`token_program`**, **`ata_program`**.
/// Purchase tickets: user pays **`amount`** USDC (**micro base units**); team cut to fee collector; remainder splits into **`Treasury`** pools; **`Ledger`** credits **`unstaked_micros`** and **`tickets`**.
///
/// **`previous_*`** resolves **`series_id`** + **`period - 1`** (same **`series_id`**).
///
/// **Accounts:** **`user`**, **`treasury`**, **`ledger`**, **`mint`**, **`user_ata`**, **`treasury_ata`**, **`team_ata`**, **`system_program`**, **`token_program`**, **`ata_program`**, **`previous_market`**, **`previous_position`**.
/// Spend **`ticket_units`** from **`Ledger`** into **`Position`** / **`Market`** while **`STATUS_OPEN`** and **`now < close_ts`**:
///
/// - **Pre-open commit** (no open oracle yet **or** **`now < open_ts`**): debits tickets; records **[`Position::STATE_COMMITTED_PREOPEN`]**; bumps **`market.committed_{side}`** only (**`total_*`** unchanged).
/// - **Live window** (**open oracle** + **`open_ts ≤ now < close_ts`**): merges any **[`Position::STATE_COMMITTED_PREOPEN`]** into **`total_*`** first; then debits tickets and adds to **`total_*`** as **[`Position::STATE_PENDING`]** (same as legacy stake).
/// - **Activate-only:** **`ticket_units == 0`** allowed only in the live window on an existing **COMMITTED** position (merges into **`total_*`** / **PENDING** without debiting).
///
/// **`period`** in the ix must match **`market.period`** (**PDA derivation**).
///
/// **Accounts:** **`user`**, **`ledger`**, **`treasury`** (**readonly**), **`market`**, **`position`**, **`previous_market`**, **`previous_position`**, **`system_program`**.
/// Creates **`Market`** (**executor signer**) **or** records open Pyth snapshot (crank).
///
/// **`Create`**: allowed whenever the **`Market`** PDA is **still empty** (executor may calendar **`open_ts`** / **`close_ts`** ahead of **`now`**; live **`PlaceBet`** that writes **`total_*`** remains **`BettingClosed`** until the open oracle anchor exists and **`open_ts ≤ now`**).
///
/// **Accounts:** **`authority`**, **`market`**, **`treasury`** (**readonly**), **`system_program`**, **`pyth_price_feed`** (**readonly**).
/// **`EXECUTOR_KIND_DISTRIBUTE_MARKET_REWARD`**: **`pool`** and **`amount`** must be **0** (**`series_id`** must match **`market.series_id`**).
///
/// **`EXECUTOR_KIND_JACKPOT_PAY`**: SPL **`transfer_checked`**; **`series_id`** should be **`0`**.
///
/// **`EXECUTOR_KIND_MARKET_LINE_RELEASE`**: **`amount`** = **`period`** LE; **`series_id`** in payload.
///
/// **`EXECUTOR_KIND_MERGE_COMMITTED_POSITION`**: **`pool`** and **`amount`** must be **0**; **`series_id`** must match **`position.series_id`**; merges one **[`Position::STATE_COMMITTED_PREOPEN`]** into **`Market::total_*`**. Accounts: **`executor`**, **`treasury`** (**readonly**), **`market`**, **`position`**.
pub const EXECUTOR_KIND_DISTRIBUTE_MARKET_REWARD: u8 = 0;
pub const EXECUTOR_KIND_JACKPOT_PAY: u8 = 1;
pub const EXECUTOR_KIND_MARKET_LINE_RELEASE: u8 = 2;
pub const EXECUTOR_KIND_MERGE_COMMITTED_POSITION: u8 = 3;
use TryFromPrimitive;
instruction!;
instruction!;
instruction!;
instruction!;
instruction!;
instruction!;
instruction!;