pub struct PoolSwapInputs { /* private fields */ }Expand description
A validated weighted-pool swap request.
Unlike the option types, the pool’s validity is relational — it depends on
the balance ratio balance_in / (balance_in + amount_in) >= 0.01 and the
weight ratio weight_in / weight_out <= 20, not on independent per-field
bounds. PoolSwapInputs::from_raw checks the whole certified domain up
front, so holding a value proves the swap is quotable; Self::quote then
cannot fail for a domain reason and cannot panic. Rounding stays
protocol-favouring exactly as in crate::weighted_pool_swap.
Implementations§
Source§impl PoolSwapInputs
impl PoolSwapInputs
Sourcepub fn from_raw(
balance_in: u128,
balance_out: u128,
weight_in: u128,
weight_out: u128,
amount_in: u128,
fee_rate: u128,
) -> Result<Self, SolMathError>
pub fn from_raw( balance_in: u128, balance_out: u128, weight_in: u128, weight_out: u128, amount_in: u128, fee_rate: u128, ) -> Result<Self, SolMathError>
Validate a raw swap against the certified pool domain. Mirrors the guard
chain in crate::weighted_pool_swap: non-zero balances/weights, a fee
in [0, 100%], a weight ratio w_in / w_out <= 20, and a post-trade
balance ratio >= 0.01. amount_in == 0 is accepted (a no-op quote).
Trait Implementations§
Source§impl Clone for PoolSwapInputs
impl Clone for PoolSwapInputs
Source§fn clone(&self) -> PoolSwapInputs
fn clone(&self) -> PoolSwapInputs
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more