#[cfg(liquidity_provider)]
use gmsol_programs::gmsol_liquidity_provider::accounts::LpTokenController;
use crate::utils::Value;
use super::StringPubkey;
#[cfg(liquidity_provider)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SerdeLpController {
pub controller_index: u64,
pub controller_address: StringPubkey,
pub global_state: StringPubkey,
pub lp_token_mint: StringPubkey,
pub total_positions: u64,
pub is_enabled: bool,
pub disabled_at: i64,
pub disabled_cum_inv_cost: Value,
}
#[cfg(liquidity_provider)]
impl SerdeLpController {
pub fn from_controller(
controller: &LpTokenController,
controller_address: &solana_sdk::pubkey::Pubkey,
) -> Self {
Self {
controller_index: controller.controller_index,
controller_address: (*controller_address).into(),
global_state: controller.global_state.into(),
lp_token_mint: controller.lp_token_mint.into(),
total_positions: controller.total_positions,
is_enabled: controller.is_enabled,
disabled_at: controller.disabled_at,
disabled_cum_inv_cost: Value::from_u128(controller.disabled_cum_inv_cost),
}
}
}