streak_api/state/treasury.rs
1//! Protocol USDC custody (`treasury` PDA).
2//!
3//! The treasury serves two roles:
4//!
5//! 1. **USDC custodian** — the treasury ATA holds all deposited USDC. Deposits come in via
6//! `Deposit`; payouts go out via `AdminPayout` (executor-signed).
7//!
8//! 2. **Price chain** — `last_close_*` carries the Pyth close price from the most recently
9//! settled period. `AdminInstantSettlement` reads it as the open reference and writes the
10//! new close price back, forming a self-perpetuating chain. Zero until `Initialize` seeds it.
11
12use steel::*;
13
14use super::{treasury_pda, StreakAccount};
15
16#[repr(C)]
17#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
18pub struct Treasury {
19 /// Daily jackpot pool — credited on `Deposit`; debited via `AdminPayout`.
20 pub daily_jackpot: u64,
21 /// Weekly jackpot pool — credited on `Deposit`; debited via `AdminPayout`.
22 pub weekly_jackpot: u64,
23 /// Buyback reserve.
24 pub buyback: u64,
25 /// Close price from the most recently settled period — used as the open reference
26 /// for the next settlement. Zero until `Initialize` seeds it.
27 pub last_close_price: i64,
28 /// Pyth exponent matching `last_close_price`.
29 pub last_close_expo: i32,
30 pub _pad_close: [u8; 4],
31 /// `publish_time` from the Pyth feed at last settlement.
32 pub last_close_publish_time: i64,
33}
34
35impl Treasury {
36 pub fn pda() -> (Pubkey, u8) {
37 treasury_pda()
38 }
39}
40
41account!(StreakAccount, Treasury);