#[cfg(liquidity_provider)]
use gmsol_programs::gmsol_liquidity_provider::accounts::GlobalState;
use crate::utils::Value;
use super::StringPubkey;
#[cfg(liquidity_provider)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SerdeLpGlobalState {
pub authority: StringPubkey,
pub pending_authority: StringPubkey,
pub apy_gradient: Vec<Value>,
pub min_stake_value: Value,
pub claim_enabled: bool,
pub pricing_staleness_seconds: u32,
pub bump: u8,
}
#[cfg(liquidity_provider)]
impl SerdeLpGlobalState {
pub fn from_global_state(global_state: &GlobalState) -> Self {
let apy_gradient = global_state
.apy_gradient
.iter()
.map(|&apy| Value::from_u128(apy))
.collect();
Self {
authority: global_state.authority.into(),
pending_authority: global_state.pending_authority.into(),
apy_gradient,
min_stake_value: Value::from_u128(global_state.min_stake_value),
claim_enabled: global_state.claim_enabled,
pricing_staleness_seconds: global_state.pricing_staleness_seconds,
bump: global_state.bump,
}
}
}