@ deep 流动性/ 曲线- math
组合数学( 大缩写) 深处 连接曲线(深曲线索拉纳方案)和
恒产引出. 它与程序Rust相对应 math.rs 位元: 两个测试套件运行
同样的矢量。 没有浮点,没有依赖.
DEEP 程序继续运行 主网 财务报告和审定财务报表 脱网。 。 。 .
安装
npm install @deepliquidity/curve-math
仅限无害环境管理,有类型脚本声明. 22号节点或任何现代浏览器捆绑.
四舍五入
- 支付金额 关闭 给交易商 下来· ;
- 交易商必须支付的费用和金额 内 圆形 上来· ;
- 所以曲线变化无常
k = virtualSol × virtualToken从不减少.
快开始
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 掷出 CurveMathError 带有程序错误名称( i)ZeroAmount, (中文(简体) ),
CurveComplete, (中文(简体) ), InsufficientReserves, (中文(简体) ), SlippageExceeded, (中文(简体) ), InvalidFee, (中文(简体) ), InvalidParams, (中文(简体) ),
Overflow程序会拒绝的地方.
许可证
麻省理工学院
链接
网站和应用程序 • 妇女 文档 • 妇女 融合指南 • 妇女 GitHub 图像 • 妇女 博客 • 妇女 状态 • 妇女 页:1 • 妇女 电报
