Skip to main content

streak_api/
event.rs

1//! On-chain events (`sol_log_data` via Steel `event!` / `.log()`).
2//!
3//! ## Event contract
4//!
5//! | Event | Trigger | Observer |
6//! |---|---|---|
7//! | `Deposited` | `Deposit` ix | Indexer credits user's off-chain USDC balance |
8//! | `Paid` | `AdminPayout` ix | Bot confirms payout in DB |
9//! | `Initialized` | `Initialize` ix | One-time setup confirmation |
10//!
11//! Settlement outcome (UP/DOWN) is derived off-chain by the bot via Pyth Hermes.
12
13use steel::*;
14
15/// Emitted by `Initialize`.
16#[repr(C)]
17#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
18pub struct Initialized {
19    pub admin: Pubkey,
20}
21
22/// Emitted by `Deposit`. Indexer credits `user`'s off-chain balance by `amount` µUSDC.
23#[repr(C)]
24#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
25pub struct Deposited {
26    pub user: Pubkey,
27    pub amount: u64,
28}
29
30/// Emitted by `AdminRouteFees`. Records DBC / DAMM v2 fee routing into the treasury.
31#[repr(C)]
32#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
33pub struct FeesRouted {
34    /// Total µUSDC received from the pool fee claim.
35    pub amount: u64,
36    /// µUSDC added to `Treasury.daily_jackpot`.
37    pub daily_share: u64,
38    /// µUSDC added to `Treasury.weekly_jackpot`.
39    pub weekly_share: u64,
40    /// µUSDC added to `Treasury.buyback`.
41    pub buyback_share: u64,
42    /// µUSDC forwarded to `FEE_COLLECTOR` (team & ops).
43    pub team_share: u64,
44}
45
46/// Emitted by `AdminPayout`. Bot confirms the payout was delivered.
47#[repr(C)]
48#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
49pub struct Paid {
50    pub recipient: Pubkey,
51    pub amount: u64,
52    pub series_id: u16,
53    pub _pad: [u8; 6],
54    pub period: u64,
55}
56
57event!(Initialized);
58event!(Deposited);
59event!(FeesRouted);
60event!(Paid);