pool
AMM Pool Math (f64)
Constant product (x×y=k) AMM formulas for 32.32 fixed-point. Gas-optimized versions of the f128 pool functions.
Swap Functions
constant_product_out- Calculate output for given inputconstant_product_in- Calculate input for desired output
Price & Slippage
price_from_reserves- Get spot price from reservesslippage- Calculate execution slippage
Liquidity Functions
initial_lp_tokens- LP tokens for initial depositmint_lp_tokens- LP tokens for subsequent depositsliquidity_share- User’s share of reservesremove_liquidity- Amounts returned on withdrawal
Fully qualified path: cairo_fp::f64::math::pool
Free functions
| constant_product_out | Calculates output amount for a constant product swap. Given reserves x, y and input dx, returns dy such that (x+dx)(y-dy) = xy. Formula: dy = y × dx / (x + dx) |
| constant_product_in | — |
| price_from_reserves | — |
| slippage | — |
| liquidity_share | — |
| calculate_k | — |
| initial_lp_tokens | — |
| remove_liquidity | — |