amm/state.rs
1//! Pool account state
2
3use crate::curve::curve_type::CurveType;
4use crate::curve::fees::PoolFees;
5use anchor_lang::prelude::*;
6use std::fmt::Debug;
7
8#[derive(AnchorSerialize, AnchorDeserialize, Default, Debug, Clone, Copy)]
9/// Padding for future pool fields
10pub struct Padding {
11 /// Padding 0
12 pub padding_0: [u8; 15], // 15
13 /// Padding 1
14 pub padding: [u128; 29], // 464
15}
16
17/// Pool type
18#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Debug, PartialEq)]
19pub enum PoolType {
20 /// Permissioned
21 Permissioned,
22 /// Permissionless
23 Permissionless,
24}
25impl Default for PoolType {
26 fn default() -> Self {
27 PoolType::Permissioned
28 }
29}
30
31#[account]
32#[derive(Default, Debug)]
33/// State of pool account
34pub struct Pool {
35 /// LP token mint of the pool
36 pub lp_mint: Pubkey, //32
37 /// Token A mint of the pool. Eg: USDT
38 pub token_a_mint: Pubkey, //32
39 /// Token B mint of the pool. Eg: USDC
40 pub token_b_mint: Pubkey, //32
41 /// Vault account for token A. Token A of the pool will be deposit / withdraw from this vault account.
42 pub a_vault: Pubkey, //32
43 /// Vault account for token B. Token B of the pool will be deposit / withdraw from this vault account.
44 pub b_vault: Pubkey, //32
45 /// LP token account of vault A. Used to receive/burn the vault LP upon deposit/withdraw from the vault.
46 pub a_vault_lp: Pubkey, //32
47 /// LP token account of vault B. Used to receive/burn the vault LP upon deposit/withdraw from the vault.
48 pub b_vault_lp: Pubkey, //32
49 /// "A" vault lp bump. Used to create signer seeds.
50 pub a_vault_lp_bump: u8, //1
51 /// Flag to determine whether the pool is enabled, or disabled.
52 pub enabled: bool, //1
53 /// Admin fee token account for token A. Used to receive trading fee.
54 pub admin_token_a_fee: Pubkey, //32
55 /// Admin fee token account for token B. Used to receive trading fee.
56 pub admin_token_b_fee: Pubkey, //32
57 /// Owner of the pool.
58 pub admin: Pubkey, //32
59 /// Store the fee charges setting.
60 pub fees: PoolFees, //48
61 /// Pool type
62 pub pool_type: PoolType,
63 /// Stake pubkey of SPL stake pool
64 pub stake: Pubkey,
65 /// Padding for future pool field
66 pub padding: Padding, // 512 Refer: curve_type.rs for the test
67 /// The type of the swap curve supported by the pool.
68 // Leaving curve_type as last field give us the flexibility to add specific curve information / new curve type
69 pub curve_type: CurveType, //9
70}