bucks_api/state/position.rs
1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use super::BucksAccount;
5
6/// StableProtocolPosition - Tracks a stable's position in a specific yield protocol.
7///
8/// This account provides explicit per-protocol tracking of deposits and receipt tokens,
9/// enabling accurate yield calculation without relying on global share ratios.
10///
11/// PDA seeds: [b"position", stable.key.as_ref(), &[protocol_id]]
12#[repr(C)]
13#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
14pub struct StableProtocolPosition {
15 /// The stable this position belongs to.
16 pub stable: Pubkey,
17
18 /// The protocol ID (PROTOCOL_KAMINO=0, PROTOCOL_PERENA=1).
19 pub protocol_id: u8,
20
21 /// Padding for alignment.
22 pub _padding: [u8; 7],
23
24 /// USDC deposited into this protocol via this stable.
25 /// Invariant: sum(all positions for stable).deposits == stable.total_deposits
26 pub deposits: u64,
27
28 /// Receipt tokens (cTokens for Kamino, USD* for Perena) attributed to this stable.
29 /// Invariant: sum(all positions for protocol).receipt_tokens == protocol.receipt_token_balance
30 pub receipt_tokens: u64,
31}
32
33account!(BucksAccount, StableProtocolPosition);