wp-solana-pool-traits 0.1.1

Traits and utilities for Solana liquidity pool operations: PoolViewer, PoolInfuser, PositionViewer
Documentation
//! Shared error types for pool protocol SDKs.
//!
//! Protocol-specific error enums can nest [`PoolError`] via `#[from]` to
//! inherit these common variants while adding their own.

use thiserror::Error;

/// Protocol-agnostic errors shared by all pool SDKs.
#[derive(Error, Debug)]
pub enum PoolError {
    /// A math operation failed (overflow, division by zero, etc.).
    #[error("math error: {0}")]
    Math(String),

    /// The pool's on-chain state is invalid or inconsistent.
    #[error("invalid pool state: {0}")]
    InvalidPoolState(String),

    /// The position data is invalid or does not exist.
    #[error("invalid position: {0}")]
    InvalidPosition(String),

    /// Not enough liquidity for the requested operation.
    #[error("insufficient liquidity: {0}")]
    InsufficientLiquidity(String),

    /// The price is outside the acceptable range.
    #[error("price out of range: {0}")]
    PriceOutOfRange(String),

    /// A transparent wrapper for other errors.
    #[error(transparent)]
    Other(#[from] anyhow::Error),
}