dloom_flow/dlmm/state/
pool.rs

1// FILE: programs/dloom_flow/src/state/dlmm_pool.rs
2
3use anchor_lang::prelude::*;
4
5/// Distinguishes between official and community-created pools.
6#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, PartialEq, Eq, Debug)]
7pub enum PoolType {
8    Official,
9    Community,
10}
11
12impl Default for PoolType {
13    fn default() -> Self {
14        PoolType::Official
15    }
16}
17
18/// State for a Discretized Liquidity Market Maker (DLMM) pool.
19#[account]
20#[derive(Default, Debug)]
21pub struct DlmmPool {
22    /// The PDA bump.
23    pub bump: u8,
24    /// The protocol authority that created this pool. For community pools, this is the creator.
25    pub authority: Pubkey,
26    /// Distinguishes the type of the pool (Official or Community).
27    pub pool_type: PoolType,
28
29    // --- Mint and Vault Keys ---
30    pub token_a_mint: Pubkey,
31    pub token_b_mint: Pubkey,
32    pub token_a_vault: Pubkey,
33    pub token_b_vault: Pubkey,
34
35    // --- Core DLMM Parameters ---
36    pub active_bin_id: i32,
37    pub bin_step: u16,
38
39    // --- Fee Parameters ---
40    pub fee_rate: u16,
41    pub protocol_fee_share: u16,
42    pub referrer_fee_share: u16,
43    pub protocol_fee_vault_a: Pubkey,
44    pub protocol_fee_vault_b: Pubkey,
45
46    // --- Dynamic Fee Fields ---
47    /// Accumulator for market volatility, based on bins crossed during swaps.
48    pub volatility_accumulator: u64,
49    /// The timestamp of the last dynamic fee update.
50    pub last_fee_update_timestamp: i64,
51
52    // --- State Tracking ---
53    pub reserves_a: u64,
54    pub reserves_b: u64,
55}