cp-curve 0.1.0

Constant-product (x*y=k) AMM curve math primitives for Solana programs
Documentation
  • Coverage
  • 75%
    12 out of 16 items documented0 out of 7 items with examples
  • Size
  • Source code size: 19.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 281.87 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 19s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • dotsvm/cp-curve
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dotsvm

cp-curve

constant product (x*y=k) amm math primitives. no_std rust.

api

  • swap_output(reserve_in, reserve_out, amount_in) — swap, no fee
  • swap_output_with_fee(reserve_in, reserve_out, amount_in, fee_bps) — swap with fee in bps
  • deposit_amounts(reserve_x, reserve_y, total_lp, amount_x_in, amount_y_in) — lp deposit, first-deposit via integer sqrt
  • withdraw_amounts(reserve_x, reserve_y, total_lp, lp_burn) — proportional withdraw
  • integer_sqrt(value) — u128 newton's method

errors

CurveError: Overflow, ZeroInput, EmptyPool, InvalidFee, InsufficientLpSupply.

test

cargo test