precolator-program 1.0.0

Core Rust library for the Precolator perpetual futures trading protocol on Solana — oracle management, position handling, risk engine, and liquidation system.
Documentation
// Error types and Result alias for Precolator program

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>;