@deepliquidity/curve-math

中文文档
0.1.3发布于 2026/10/13MITTypeScriptES Module零依赖近 30 天下载 2216

Deterministic integer (BigInt) math for the DEEP bonding curve (deep-curve) and DeepSwap constant-product quotes. Mirrors the on-chain Rust bit for bit.

原始使用文档
文档目录5 节
  1. Install
  2. Rounding
  3. Quick start
  4. Licence
  5. Links

@deepliquidity/curve-math

DEEP — Launch deeper.

App Integration guide API X @LaunchOnDL Telegram @LaunchOnDL

Integer (BigInt) maths for the DEEP bonding curve (the deep-curve Solana program) and constant-product quotes. It mirrors the program's Rust math.rs bit for bit: both test suites run the same committed vectors. No floating point, no dependencies.

The DEEP programs run on mainnet and devnet.

Install

npm install @deepliquidity/curve-math

ESM only, with TypeScript declarations. Node ≥ 22 or any modern browser bundle.

Rounding

  • amounts paid out to the trader round down;
  • fees and amounts the trader must pay in round up;
  • so the curve invariant k = virtualSol × virtualToken never decreases.

Quick start

import { quoteBuyV1, quoteSellV1, depthBps, marketCapLamports } from "@deepliquidity/curve-math";

// `state` and `fees` come from the token's BondingCurve account: decode it with the SDK
// (`decodeBondingCurve`, `curveFees`). Every token keeps the rates it was launched with.
const buy = quoteBuyV1(state, 1_000_000_000n, fees); // 1 SOL budget
buy.solIn; // lamports actually charged (less than the budget when the buy completes the curve)
buy.fees; // { total, protocol, creator }: rounded up, on top of what reaches the curve
buy.routing; // who receives the reward part: the creator or the token's holders
buy.tokensOut; // floor(vToken × net / (vSol + net)), capped at the tokens left
buy.next; // the curve state after the trade

const sell = quoteSellV1(state, 1_000_000n, fees);
sell.solOut; // floor(vSol × tokens / (vToken + tokens)) minus fees rounded up

depthBps(state); // curve progress in basis points of the curve supply (rounded down)
marketCapLamports(state); // fully diluted value at the spot price: not liquidity

quoteBuyV1/quoteSellV1 throw CurveMathError with the program's error names (ZeroAmount, CurveComplete, InsufficientReserves, SlippageExceeded, InvalidFee, InvalidParams, Overflow) where the program would reject.

Licence

MIT

Website and app · Docs · Integration guide · GitHub · Blog · Status · X · Telegram

版本与发布记录

@deepliquidity/curve-math 共发布 5 个版本,首次发布于 2026/10/09;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.1.3latest2026/10/131 个月前
0.1.22026/10/131 个月前
0.1.12026/10/091 个月前
0.1.02026/10/091 个月前
0.0.0-stage2026/10/091 个月前

关于 @deepliquidity/curve-math 的常见问题

@deepliquidity/curve-math 是什么?

Deterministic integer (BigInt) math for the DEEP bonding curve (deep-curve) and DeepSwap constant-product quotes. Mirrors the on-chain Rust bit for bit.

如何安装 @deepliquidity/curve-math?

在项目目录运行 npm install @deepliquidity/curve-math,或使用 pnpm add / yarn add / bun add。

@deepliquidity/curve-math 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@deepliquidity/curve-math 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@deepliquidity/curve-math 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@deepliquidity/curve-math 可以商用吗?

@deepliquidity/curve-math 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@deepliquidity/curve-math 的下载量有多少?

根据 npm 官方下载统计,@deepliquidity/curve-math 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,216 次,日均约 74 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@deepliquidity/curve-math 还在维护吗?

最新版本 0.1.3 发布于 2026/10/13(1 个月前);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/10/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。