Skip to main content

bucks_api/state/
stable.rs

1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use super::BucksAccount;
5
6/// Stable - Per-stablecoin state tracking.
7/// Each stablecoin created has its own Stable account.
8///
9/// Invariant: total_deposits == sum(all StableProtocolPosition.deposits for this stable)
10/// Invariant: total_deposits == stablecoin_mint.supply (1:1 peg)
11#[repr(C)]
12#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
13pub struct Stable {
14    /// The creator address (authority).
15    pub authority: Pubkey,
16
17    /// The address of the token metadata.
18    pub metadata: Pubkey,
19
20    /// The stablecoin mint address.
21    pub mint: Pubkey,
22
23    /// The total amount of USDC deposited via this stablecoin.
24    /// This is a cached sum of all StableProtocolPosition.deposits for this stable.
25    pub total_deposits: u64,
26
27    /// The amount of yield claimed over the lifetime of this stablecoin.
28    pub lifetime_yield_claimed: u64,
29
30    /// The timestamp this coin was created.
31    pub created_at: i64,
32}
33
34account!(BucksAccount, Stable);