pub mod amm;
pub mod bonding_curve;
pub mod fees;
pub mod utils;
pub use bonding_curve::TOKEN_SUPPLY;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QuoteError {
EmptyReserves,
BaseOutExceedsReserve,
FeesExceedOutput,
DepletedBondingCurve,
MathOverflow,
SlippageExceeded,
}
impl std::fmt::Display for QuoteError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::EmptyReserves => write!(f, "pool reserves are zero"),
Self::BaseOutExceedsReserve => {
write!(f, "base_out exceeds the pool's base reserve")
}
Self::FeesExceedOutput => write!(f, "fees exceed the pool's quote output"),
Self::DepletedBondingCurve => {
write!(f, "bonding curve is depleted (real == virtual reserves)")
}
Self::MathOverflow => write!(f, "checked arithmetic overflowed"),
Self::SlippageExceeded => {
write!(f, "market cap fell outside the slippage envelope")
}
}
}
}
impl std::error::Error for QuoteError {}
pub type QuoteResult<T> = std::result::Result<T, QuoteError>;