//! Margin weight, balance, and price calculations for spot positions.
//!
//! Protocol-specific logic lives in submodules (`drift`, `kamino`); shared
//! math and error types are at the crate root.

pub mod common;
pub mod drift;
pub mod error;
pub mod kamino;
pub mod math;
pub mod spend_limits;

// ─── Re-exports for backwards compatibility ─────────────────────

pub use drift::balance::{
    calculate_value_usdc_base_units, compute_token_balance, get_token_balance,
};
pub use common::{calculate_spend_limit_cents, usdc_base_units_to_cents, USDC_BASE_UNITS_PER_CENT};
pub use drift::capacity::{calculate_capacity, CapacityResult, PositionInfo};
pub use drift::limits::{calculate_position_limits, MarginState, PositionData, PositionLimits};
pub use drift::weights::{
    calculate_asset_weight, calculate_liability_weight, calculate_scaled_initial_asset_weight,
    calculate_size_discount_asset_weight, calculate_size_premium_liability_weight,
    get_strict_price, to_amm_precision, AMM_RESERVE_PRECISION, SPOT_IMF_PRECISION,
    SPOT_WEIGHT_PRECISION,
};
pub use error::{MathError, MathResult};
pub use kamino::balance::{get_kamino_borrow_balance, get_kamino_deposit_balance};
pub use kamino::capacity::{
    calculate_kamino_capacity, KaminoCapacityResult, KaminoPositionInfo, KaminoPositionType,
};
pub use kamino::limits::{
    calculate_kamino_position_limits, KaminoMarginState, KaminoPositionLimits,
};
pub use kamino::weights::{get_kamino_asset_weight, get_kamino_liability_weight, get_kamino_price};
pub use math::CheckedDivCeil;
pub use spend_limits::get_remaining_timeframe_limit;
