pub mod bin_price;
pub mod fee_math;
pub mod fixed_point;
pub mod full_math;
pub mod liquidity_math;
pub mod price_math;
pub mod slippage;
pub mod swap_math;
pub mod tick_math;
pub use fixed_point::{
mul_div, mul_shr, pow, safe_mul_div_cast, safe_mul_shr_cast, safe_shl_div_cast, shl_div,
Rounding, MAX_EXPONENTIAL, ONE, PRECISION, SCALE_OFFSET,
};
pub use liquidity_math::{
decrease_liquidity_quote, decrease_liquidity_quote_a, decrease_liquidity_quote_b,
increase_liquidity_quote, increase_liquidity_quote_a, increase_liquidity_quote_b,
order_tick_indexes, DecreaseLiquidityQuote, IncreaseLiquidityQuote, TickRange, TransferFee,
};
pub use price_math::invert_price;
pub use slippage::{
apply_transfer_fee, max_amount_with_slippage, min_amount_with_slippage,
reverse_apply_transfer_fee, sqrt_price_slippage_bounds,
};
pub use swap_math::{
compute_swap_step, get_next_sqrt_price_from_input, get_next_sqrt_price_from_output,
SwapStepResult,
};
use thiserror::Error;
pub use tick_math::{
get_full_range_tick_indexes, get_initializable_tick_index, get_next_initializable_tick_index,
get_prev_initializable_tick_index, get_tick_array_start_index, get_tick_index_in_array,
invert_tick_index, is_position_in_range, is_tick_in_bounds, is_tick_initializable, tick_count,
RAYDIUM_TICK_ARRAY_SIZE, WHIRLPOOL_TICK_ARRAY_SIZE,
};
#[derive(Debug, Error, PartialEq, Eq)]
pub enum AmmMathError {
#[error("division by zero")]
DivisionByZero,
#[error("result overflow")]
Overflow,
#[error("tick out of range: {0}")]
TickOutOfRange(i32),
#[error("sqrt price out of range: {0}")]
SqrtPriceOutOfRange(u128),
#[error("invalid fee rate: {0} bps")]
InvalidFeeRate(u16),
}