Pure Rust implementation of Curve Finance AMM math.
Exact on-chain match — no tolerances, no approximations, wei-level precision.
Differentially fuzz-tested against on-chain get_dy for 200+ pools.
Architecture
core— stateless math functions (Newton solvers, Cardano cubic, fee). Always available, zero dependencies beyondalloy-primitives.swap+Pool— pool simulation with normalization, fees, and denormalization. Requires theswapfeature.
Quick start
use Pool; // requires feature "swap"
use U256;
let pool = StableSwapV2 ;
let dx = U256from; // 1 token
let dy = pool.get_amount_out.expect;
assert!;
Supported variants
All 11 Curve pool types: StableSwapV0, StableSwapV1, StableSwapV2,
StableSwapALend, StableSwapNG, StableSwapMeta, TwoCryptoV1,
TwoCryptoNG, TwoCryptoStable, TriCryptoV1, TriCryptoNG.