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
//! 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`** lanes; **`Ledger`** credits **`unstaked_micros`** and **`tickets`**.
///
/// **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`** during **`[open_ts, close_ts)`** after **`InitMarket`** has recorded the open oracle snapshot (**create** within the anchor window **or** a follow-up **`InitMarket`** with identical args once the **`market`** PDA exists).
/// **`period`** must equal **`Treasury::next_market_period`** (**only the active line** accepts stakes).
///
/// **Accounts:** **`user`**, **`ledger`**, **`treasury`** (**readonly**), **`market`**, **`position`**, **`previous_market`**, **`previous_position`**, **`system_program`**.
/// Creates **`Market`** (**executor signer**) **or**, if the **`market`** PDA already exists and the ix matches on-chain **`Market`** fields (**`period`**, **`open_ts`**, **`close_ts`**, **`pyth_price_feed`**, **`rules_hash`**) while **`open_*`** is unfrozen, records the open Pyth snapshot (**executor-signed crank**, **matching** ix args).
///
/// **`Create`**: **`OPEN_TS`** / **`CLOSE_TS`**, **`PYTH_PRICE_FEED`** (non-zero), **`RULES_HASH`**. **`period`** must equal **`Treasury::next_market_period`** (**prior period must have settled** — sequential listings).
/// Immediately after **`create`**, if **`Clock`** is **`∈ [open_ts, min(open_ts + MARKET_OPEN_ANCHOR_GRACE_SECS, close_ts))`**, the snapshot is taken in the **same ix**; earlier **`Clock`** skips anchoring (**send same ix again later** inside the anchor window — still discriminator **`InitMarket`** — with **matching** **`open_ts`**, **`close_ts`**, **`pyth_price_feed`**, **`rules_hash`**).
///
/// **Accounts:** **`authority`** (writable signer — [`EXECUTOR_ADDRESS`](crate::consts::EXECUTOR_ADDRESS) on **create** and **crank open**), **`market`**, **`treasury`** (**readonly**), **`system_program`**, **`pyth_price_feed`** (**readonly**, must equal stored feed on **`market`**).
/// Executor instant settle after **`close_ts`** vs fresh Pyth (requires anchored open snapshot). **`authority`** must be [`EXECUTOR_ADDRESS`](crate::consts::EXECUTOR_ADDRESS).
///
/// **Accounts:** **`authority`** (**writable signer**), **`treasury`**, **`market`**, **`pyth_price_feed`**.
/// Payload for CPI + treasury route (see [`StreakInstruction::ClaimPositionFee`]).
/// **`EXECUTOR_KIND_DISTRIBUTE_MARKET_REWARD`**: **`pool`** and **`amount`** must be **0** (winner payout + ledger streak).
///
/// **`EXECUTOR_KIND_LANE_PAY`**: SPL **`transfer_checked`** from treasury ATA; **`amount`** & **`pool`** (**daily / weekly** jackpot lane).
///
/// **`EXECUTOR_KIND_MARKET_LINE_RELEASE`**: after **`AdminInstantSettlement`** when **`winning_total > 0`**, executor finishes **`DISTRIBUTE_MARKET_REWARD`** for that period, then advances **`Treasury::next_market_period`** so **`InitMarket` create** may open the next listing (**`pool = 0`**, **`amount = period`** LE). **Accounts:** **`executor`**, **`treasury`**, **`market`**.
pub const EXECUTOR_KIND_DISTRIBUTE_MARKET_REWARD: u8 = 0;
pub const EXECUTOR_KIND_LANE_PAY: u8 = 1;
/// Bump **`Treasury::next_market_period`** after market **`period`** is settled and **`DISTRIBUTE`** batch is done (executor-trusted).
pub const EXECUTOR_KIND_MARKET_LINE_RELEASE: u8 = 2;
use TryFromPrimitive;
instruction!;
instruction!;
instruction!;
instruction!;
instruction!;
instruction!;
instruction!;