use thiserror::Error;
#[derive(Error, Debug)]
pub enum ProgramError {
#[error("Insufficient collateral")]
InsufficientCollateral,
#[error("Excessive leverage")]
ExcessiveLeverage,
#[error("Position not found")]
PositionNotFound,
#[error("Invalid oracle price")]
InvalidOraclePrice,
#[error("Market not found")]
MarketNotFound,
#[error("Unauthorized access")]
Unauthorized,
#[error("Oracle price stale")]
StalePriceData,
#[error("Position cannot be liquidated")]
CannotLiquidate,
#[error("Insufficient liquidity")]
InsufficientLiquidity,
#[error("Invalid amount")]
InvalidAmount,
#[error("Account already exists")]
AccountAlreadyExists,
#[error("Account not initialized")]
AccountNotInitialized,
#[error("Risk threshold exceeded")]
RiskThresholdExceeded,
#[error("Mathematical overflow")]
Overflow,
#[error("Invalid configuration")]
InvalidConfiguration,
}
pub type Result<T> = std::result::Result<T, ProgramError>;