dloom_flow/amm/state/
position.rs

1// FILE: programs/dloom_flow/src/state/amm_position.rs
2
3use anchor_lang::prelude::*;
4
5/// The user's choice for how their LP fees should be handled.
6#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, PartialEq, Eq, Debug)]
7pub enum FeePreference {
8    /// Fees must be claimed manually via the `claim_lp_fees` instruction.
9    ManualClaim,
10    /// Fees can be reinvested into the pool via the `reinvest_lp_fees` instruction.
11    AutoCompound,
12}
13
14impl Default for FeePreference {
15    fn default() -> Self {
16        FeePreference::ManualClaim
17    }
18}
19
20/// Represents a user's liquidity position in a specific AMM pool.
21#[account]
22#[derive(Default, Debug)]
23pub struct AmmPosition {
24    /// The AMM pool this position belongs to.
25    pub pool: Pubkey,
26    /// The owner of this position.
27    pub owner: Pubkey,
28    /// The number of LP tokens this position represents.
29    pub lp_token_amount: u64,
30    /// Snapshot of the pool's fee growth per LP token for token A.
31    pub fee_growth_snapshot_a: u128,
32    /// Snapshot of the pool's fee growth per LP token for token B.
33    pub fee_growth_snapshot_b: u128,
34    // --- NEW FIELD ---
35    /// The user's chosen strategy for handling accrued fees.
36    pub fee_preference: FeePreference,
37}