@sundaeswap/math 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/PoolMath/ConstantSumPool.js +106 -1
- package/dist/cjs/PoolMath/ConstantSumPool.js.map +1 -1
- package/dist/cjs/PoolMath/V4StableswapPool.js +529 -0
- package/dist/cjs/PoolMath/V4StableswapPool.js.map +1 -0
- package/dist/cjs/PoolMath/index.js +3 -1
- package/dist/cjs/PoolMath/index.js.map +1 -1
- package/dist/esm/PoolMath/ConstantSumPool.js +81 -0
- package/dist/esm/PoolMath/ConstantSumPool.js.map +1 -1
- package/dist/esm/PoolMath/V4StableswapPool.js +495 -0
- package/dist/esm/PoolMath/V4StableswapPool.js.map +1 -0
- package/dist/esm/PoolMath/index.js +1 -0
- package/dist/esm/PoolMath/index.js.map +1 -1
- package/dist/types/PoolMath/ConstantSumPool.d.ts +43 -0
- package/dist/types/PoolMath/ConstantSumPool.d.ts.map +1 -1
- package/dist/types/PoolMath/V4StableswapPool.d.ts +221 -0
- package/dist/types/PoolMath/V4StableswapPool.d.ts.map +1 -0
- package/dist/types/PoolMath/index.d.ts +1 -0
- package/dist/types/PoolMath/index.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/PoolMath/ConstantSumPool.ts +131 -0
- package/src/PoolMath/V4StableswapPool.ts +638 -0
- package/src/PoolMath/__tests__/ConstantSumPool.test.ts +167 -6
- package/src/PoolMath/__tests__/V4StableswapPool.test.ts +688 -0
- package/src/PoolMath/index.ts +1 -0
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.pinnedDepositFromAnchor = exports.getSwapOutput = exports.getSwapInput = exports.calculatePinnedDeposit = exports.calculateLiquidity = exports.calculateDepositN = void 0;
|
|
6
|
+
exports.pinnedDepositFromAnchor = exports.getSwapOutput = exports.getSwapInput = exports.calculateZap = exports.calculatePinnedDeposit = exports.calculateLiquidity = exports.calculateDepositN = void 0;
|
|
7
7
|
var _asset = require("@sundaeswap/asset");
|
|
8
8
|
var _fraction = require("@sundaeswap/fraction");
|
|
9
9
|
var _index = require("./index.js");
|
|
10
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
11
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
14
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
15
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10
16
|
/**
|
|
11
17
|
* Holds the calculated outcome of a constant-sum swap. Mirrors
|
|
12
18
|
* {@link ConstantProductPool.TSwapOutcome} so both can flow through the same
|
|
@@ -281,4 +287,103 @@ var calculateDepositN = exports.calculateDepositN = function calculateDepositN(a
|
|
|
281
287
|
shareAfterDeposit: _index.SharedPoolMath.getShare(generatedLp, nextTotalLp)
|
|
282
288
|
};
|
|
283
289
|
};
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Outcome of {@link calculateZap}. Every array is aligned to `offered`.
|
|
293
|
+
*/
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* A zap on a 2-asset constant-sum pool: a non-proportional `offered` basket
|
|
297
|
+
* is rebalanced by swapping part of the over-weighted asset, then deposited
|
|
298
|
+
* under the target-pinned rule ({@link calculatePinnedDeposit}). The swap
|
|
299
|
+
* amount `dx` is the one that leaves the post-swap basket proportional to
|
|
300
|
+
* the post-swap reserves, so the pin consumes the whole basket up to
|
|
301
|
+
* rounding. With `k = (1−fee)·p_X/p_Y`,
|
|
302
|
+
*
|
|
303
|
+
* (a_X − dx)/(r_X + dx) = (a_Y + k·dx)/(r_Y − k·dx)
|
|
304
|
+
* ⇒ dx = (a_X·r_Y − a_Y·r_X) / (k·(r_X + a_X) + (r_Y + a_Y))
|
|
305
|
+
*
|
|
306
|
+
* (the dx² terms cancel). `dx` is floored and the swap leg follows
|
|
307
|
+
* {@link getSwapOutput}; whatever imbalance rounding leaves comes back as
|
|
308
|
+
* `change`.
|
|
309
|
+
*
|
|
310
|
+
* `fee` is the pool's fee for the swap direction — v4 splits bid and ask, so
|
|
311
|
+
* the caller picks. Two assets only: with more, which assets to swap is an
|
|
312
|
+
* allocation problem this formula does not address.
|
|
313
|
+
*/
|
|
314
|
+
var calculateZap = exports.calculateZap = function calculateZap(offered, reserves, prices, totalLp, fee) {
|
|
315
|
+
if (offered.length !== 2 || reserves.length !== 2 || prices.length !== 2) throw new Error("calculateZap supports exactly two assets");
|
|
316
|
+
if (prices.some(function (p) {
|
|
317
|
+
return p <= 0n;
|
|
318
|
+
})) throw new Error("Prices must be positive");
|
|
319
|
+
if (reserves.some(function (r) {
|
|
320
|
+
return r <= 0n;
|
|
321
|
+
})) throw new Error("Reserves must be positive");
|
|
322
|
+
if (offered.some(function (a) {
|
|
323
|
+
return a < 0n;
|
|
324
|
+
}) || offered.every(function (a) {
|
|
325
|
+
return a === 0n;
|
|
326
|
+
})) throw new Error("Offered amounts must be non-negative, with at least one positive");
|
|
327
|
+
if (totalLp <= 0n) throw new Error("Not enough pool liquidity");
|
|
328
|
+
var feeFraction = _fraction.Fraction.asFraction(fee);
|
|
329
|
+
if (feeFraction.lt(_fraction.Fraction.ZERO) || feeFraction.gte(_fraction.Fraction.ONE)) throw new Error("fee must be [0,1)");
|
|
330
|
+
var feeNum = BigInt(feeFraction.numerator);
|
|
331
|
+
var feeDen = BigInt(feeFraction.denominator);
|
|
332
|
+
|
|
333
|
+
// Over-weighted side: compare a_0/r_0 against a_1/r_1 without division.
|
|
334
|
+
var lhs = offered[0] * reserves[1];
|
|
335
|
+
var rhs = offered[1] * reserves[0];
|
|
336
|
+
var swapIndex = lhs > rhs ? 0 : lhs < rhs ? 1 : undefined;
|
|
337
|
+
var swapInput = 0n;
|
|
338
|
+
var swapOutput = 0n;
|
|
339
|
+
var nextReserves = _toConsumableArray(reserves);
|
|
340
|
+
var depositBasket = _toConsumableArray(offered);
|
|
341
|
+
if (swapIndex !== undefined) {
|
|
342
|
+
var x = swapIndex;
|
|
343
|
+
var y = 1 - swapIndex;
|
|
344
|
+
var _ref = [offered[x], offered[y]],
|
|
345
|
+
aX = _ref[0],
|
|
346
|
+
aY = _ref[1];
|
|
347
|
+
var _ref2 = [reserves[x], reserves[y]],
|
|
348
|
+
rX = _ref2[0],
|
|
349
|
+
rY = _ref2[1];
|
|
350
|
+
var _ref3 = [prices[x], prices[y]],
|
|
351
|
+
pX = _ref3[0],
|
|
352
|
+
pY = _ref3[1];
|
|
353
|
+
|
|
354
|
+
// dx with k = (feeDen−feeNum)·pX / (feeDen·pY), cleared of denominators.
|
|
355
|
+
var numerator = (aX * rY - aY * rX) * feeDen * pY;
|
|
356
|
+
var denominator = (feeDen - feeNum) * pX * (rX + aX) + feeDen * pY * (rY + aY);
|
|
357
|
+
swapInput = numerator / denominator;
|
|
358
|
+
if (swapInput > 0n) {
|
|
359
|
+
var inputValue = swapInput * pX;
|
|
360
|
+
var feeValue = inputValue * feeNum / feeDen;
|
|
361
|
+
swapOutput = (inputValue - feeValue) / pY;
|
|
362
|
+
if (swapOutput >= rY) throw new Error("Pool too shallow: the rebalancing swap would drain it");
|
|
363
|
+
nextReserves[x] = rX + swapInput;
|
|
364
|
+
nextReserves[y] = rY - swapOutput;
|
|
365
|
+
depositBasket[x] = aX - swapInput;
|
|
366
|
+
depositBasket[y] = aY + swapOutput;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (depositBasket.some(function (a) {
|
|
370
|
+
return a <= 0n;
|
|
371
|
+
})) throw new Error("Offered amount too small to zap into this pool");
|
|
372
|
+
var pinned = calculatePinnedDeposit(depositBasket, nextReserves, prices, totalLp);
|
|
373
|
+
return {
|
|
374
|
+
swapIndex: swapIndex,
|
|
375
|
+
swapInput: swapInput,
|
|
376
|
+
swapOutput: swapOutput,
|
|
377
|
+
nextReserves: nextReserves,
|
|
378
|
+
depositBasket: depositBasket,
|
|
379
|
+
deltas: pinned.deltas,
|
|
380
|
+
change: depositBasket.map(function (a, i) {
|
|
381
|
+
return a - pinned.deltas[i];
|
|
382
|
+
}),
|
|
383
|
+
targetDeltaV: pinned.targetDeltaV,
|
|
384
|
+
generatedLp: pinned.generatedLp,
|
|
385
|
+
nextTotalLp: pinned.nextTotalLp,
|
|
386
|
+
shareAfterDeposit: pinned.shareAfterDeposit
|
|
387
|
+
};
|
|
388
|
+
};
|
|
284
389
|
//# sourceMappingURL=ConstantSumPool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConstantSumPool.js","names":["_asset","require","_fraction","_index","getSwapOutput","exports","inputMetadata","input","inputReserve","outputReserve","priceIn","priceOut","fee","roundOutputUp","Error","feeFraction","Fraction","asFraction","lt","ZERO","gt","ONE","inputValue","feeValue","BigInt","numerator","denominator","quotient","outputValue","output","inputLpFee","nextInputReserve","nextOutputReserve","priceImpact","amountInLessFee","idealPrice","actualPrice","subtract","divide","lpFee","AssetAmount","getSwapInput","gte","feeNum","feeDen","feeDiff","targetValue","calculateLiquidity","a","b","aReserve","bReserve","totalLp","priceA","priceB","_calculatePinnedDepos","calculatePinnedDeposit","deltas","generatedLp","nextTotalLp","shareAfterDeposit","aChange","bChange","actualDepositedA","actualDepositedB","offered","reserves","prices","length","some","p","vB","i","t","cap","undefined","map","r","targetDeltaV","SharedPoolMath","getShare","pinnedDepositFromAnchor","anchorIndex","anchorAmount","calculateDepositN","amounts","every","totalValue","depositValue"],"sources":["../../../src/PoolMath/ConstantSumPool.ts"],"sourcesContent":["import { AssetAmount, IAssetAmountMetadata } from \"@sundaeswap/asset\";\nimport { Fraction, type TFractionLike } from \"@sundaeswap/fraction\";\nimport { SharedPoolMath } from \"./index.js\";\n\n/**\n * Holds the calculated outcome of a constant-sum swap. Mirrors\n * {@link ConstantProductPool.TSwapOutcome} so both can flow through the same\n * generic swap-outcome consumers.\n */\nexport type TSwapOutcome = {\n input: bigint;\n output: bigint;\n lpFee: AssetAmount<IAssetAmountMetadata>;\n nextInputReserve: bigint;\n nextOutputReserve: bigint;\n priceImpact: Fraction;\n};\n\n/**\n * Calculate the swap outcome for a constant-sum (fixed-price) pool — the\n * invariant used by Sundae v4 stable/pegged pools. Unlike constant product,\n * the exchange rate is fixed by the pool's per-asset `prices`: the input is\n * converted to \"value\" at `priceIn`, the fee is taken off that value, and the\n * remainder is converted to the output asset at `priceOut`. The result is\n * capped at the output reserve (you can't take more than the pool holds).\n *\n * Matches the scooper's `cs_swap_result`:\n * output = floor((input·priceIn − floor(input·priceIn·fee)) / priceOut)\n *\n * @param inputMetadata Metadata for the supplied (input) asset — used for the fee AssetAmount.\n * @param input The amount of the input asset being swapped.\n * @param inputReserve The pool's reserve of the input asset.\n * @param outputReserve The pool's reserve of the output asset.\n * @param priceIn The pool's price for the input asset (from the constant-sum config).\n * @param priceOut The pool's price for the output asset.\n * @param fee The liquidity-provider fee (plus protocol fee) as a fraction.\n * @param roundOutputUp When true, round the output up instead of flooring.\n * @returns The swap details in the shared {@link TSwapOutcome} shape.\n */\nexport const getSwapOutput = (\n inputMetadata: IAssetAmountMetadata,\n input: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n priceIn: bigint,\n priceOut: bigint,\n fee: TFractionLike,\n roundOutputUp?: boolean,\n): TSwapOutcome => {\n if (input <= 0n || inputReserve <= 0n || outputReserve <= 0n)\n throw new Error(\"Input and reserves must be positive\");\n if (priceIn <= 0n || priceOut <= 0n)\n throw new Error(\"Prices must be positive\");\n\n const feeFraction = Fraction.asFraction(fee);\n if (feeFraction.lt(Fraction.ZERO) || feeFraction.gt(Fraction.ONE))\n throw new Error(\"fee must be between 0 and 1\");\n\n const inputValue = input * priceIn;\n const feeValue = new Fraction(\n inputValue * BigInt(feeFraction.numerator),\n BigInt(feeFraction.denominator),\n ).quotient;\n const outputValue = inputValue - feeValue;\n\n let output = roundOutputUp\n ? (outputValue + priceOut - 1n) / priceOut\n : outputValue / priceOut;\n\n // Can't take more than the pool holds.\n if (output > outputReserve) {\n output = outputReserve;\n }\n\n // LP fee expressed in input-asset units (value scales linearly with input,\n // so the input-denominated fee is input·feeRate) — matching ConstantProductPool.\n const inputLpFee = new Fraction(\n input * BigInt(feeFraction.numerator),\n BigInt(feeFraction.denominator),\n ).quotient;\n\n const nextInputReserve = inputReserve + input;\n const nextOutputReserve = outputReserve - output;\n\n // Price impact vs the pool's par price (priceOut/priceIn input-per-output);\n // ~0 for a constant-sum pool aside from the fee. See ConstantProductPool.\n let priceImpact = Fraction.ZERO;\n if (output > 0n) {\n const amountInLessFee = input - inputLpFee;\n const idealPrice = new Fraction(priceOut, priceIn);\n const actualPrice = new Fraction(amountInLessFee, output);\n priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n }\n\n return {\n input,\n output,\n lpFee: new AssetAmount(inputLpFee, inputMetadata),\n nextInputReserve,\n nextOutputReserve,\n priceImpact,\n };\n};\n\n/**\n * Calculate the minimal input required to receive a given output from a\n * constant-sum pool — the exact inverse of {@link getSwapOutput}.\n *\n * The forward math floors the fee off the input value, which makes the\n * post-fee value `ceil(input·priceIn·(1−fee))`; inverting that ceiling gives\n * the smallest input whose forward swap yields at least `output`.\n *\n * Unlike constant product there is no asymptote, so an output equal to the\n * full output reserve is attainable (the pool can be drained at par).\n *\n * @param inputMetadata Metadata for the supplied (input) asset — used for the fee AssetAmount.\n * @param output The desired amount of the output asset.\n * @param inputReserve The pool's reserve of the input asset.\n * @param outputReserve The pool's reserve of the output asset.\n * @param priceIn The pool's price for the input asset (from the constant-sum config).\n * @param priceOut The pool's price for the output asset.\n * @param fee The liquidity-provider fee (plus protocol fee) as a fraction.\n * @returns The swap details in the shared {@link TSwapOutcome} shape.\n */\nexport const getSwapInput = (\n inputMetadata: IAssetAmountMetadata,\n output: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n priceIn: bigint,\n priceOut: bigint,\n fee: TFractionLike,\n): TSwapOutcome => {\n if (output <= 0n || inputReserve <= 0n || outputReserve <= 0n)\n throw new Error(\"Output and reserves must be positive\");\n if (priceIn <= 0n || priceOut <= 0n)\n throw new Error(\"Prices must be positive\");\n if (output > outputReserve)\n throw new Error(\"Output must not exceed the output reserve\");\n\n const feeFraction = Fraction.asFraction(fee);\n if (feeFraction.lt(Fraction.ZERO) || feeFraction.gte(Fraction.ONE))\n throw new Error(\"fee must be [0,1)\");\n\n const feeNum = BigInt(feeFraction.numerator);\n const feeDen = BigInt(feeFraction.denominator);\n const feeDiff = feeDen - feeNum;\n\n // Forward: outputValue = ceil(input·priceIn·feeDiff/feeDen), and the swap\n // yields ≥ output iff outputValue ≥ output·priceOut. ceil(x/d) ≥ T for\n // integer x iff x ≥ d·(T−1)+1, so the minimal input is the ceiling of\n // (feeDen·(output·priceOut − 1) + 1) / (feeDiff·priceIn).\n const targetValue = output * priceOut;\n const numerator = feeDen * (targetValue - 1n) + 1n;\n const denominator = feeDiff * priceIn;\n const input = (numerator + denominator - 1n) / denominator;\n\n const inputLpFee = new Fraction(input * feeNum, feeDen).quotient;\n const nextInputReserve = inputReserve + input;\n const nextOutputReserve = outputReserve - output;\n\n // Same par-price impact definition as getSwapOutput.\n const amountInLessFee = input - inputLpFee;\n const idealPrice = new Fraction(priceOut, priceIn);\n const actualPrice = new Fraction(amountInLessFee, output);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n\n return {\n input,\n output,\n lpFee: new AssetAmount(inputLpFee, inputMetadata),\n nextInputReserve,\n nextOutputReserve,\n priceImpact,\n };\n};\n\n/**\n * Calculate the deposit parameters for a 2-asset constant-sum pool via the\n * TARGET-PINNED rule the deployed validator enforces (see\n * {@link calculatePinnedDeposit}): the mint is capped by the scarcest offered\n * asset, both assets must be offered, and anything above the pinned deltas is\n * refunded via aChange/bChange.\n *\n * @param {bigint} a - The amount of token A to deposit.\n * @param {bigint} b - The amount of token B to deposit.\n * @param {bigint} aReserve - The current reserve of token A in the pool.\n * @param {bigint} bReserve - The current reserve of token B in the pool.\n * @param {bigint} totalLp - The total lp tokens for the pool before the deposit.\n * @param {bigint} priceA - The pool's price for token A (from the constant-sum config).\n * @param {bigint} priceB - The pool's price for token B.\n * @throws {Error} If the pool has no value or minted lp.\n * @throws {Error} If both deposit amounts are zero, or either is negative.\n * @throws {Error} If either price is non-positive.\n */\nexport const calculateLiquidity = (\n a: bigint,\n b: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n priceA: bigint,\n priceB: bigint,\n) => {\n // Target-pinned (what the deployed validator accepts): mint by the\n // scarcest offered asset; anything above the pinned deltas is refunded\n // (aChange/bChange).\n const { deltas, generatedLp, nextTotalLp, shareAfterDeposit } =\n calculatePinnedDeposit(\n [a, b],\n [aReserve, bReserve],\n [priceA, priceB],\n totalLp,\n );\n\n return {\n nextTotalLp,\n generatedLp,\n shareAfterDeposit,\n aChange: a - deltas[0],\n bChange: b - deltas[1],\n actualDepositedA: deltas[0],\n actualDepositedB: deltas[1],\n };\n};\n\n/**\n * The N-asset form of {@link calculateLiquidity}, mirroring the v4 contract's\n * `compute_deposit_n` exactly: a deposit of any mix of the pool's assets is\n * valued at the fixed prices against the value of ALL reserves —\n *\n * generatedLp = Σ(amount_i·price_i) · totalLp / Σ(reserve_i·price_i)\n *\n * The three arrays must be aligned to the pool's canonical asset order (the\n * API's `assets`/`quantities`/`prices`). Estimating an N-asset pool's deposit\n * from just two of its reserves overstates the minted LP — the denominator is\n * the whole pool's value — which is exactly the mistake this exists to\n * prevent.\n */\n/**\n * The target-pinned deposit — what the deployed CS validator (cs_check tag 6)\n * actually accepts, and what the scooper builds. Asymmetric deposits are\n * disallowed on-chain: the fill declares a value delta `t` and every asset's\n * contribution is ceil-pinned to `ceil(r_i·t/V_b)`, with total LP\n * floor-pinned to `floor(lp_b·(V_b+t)/V_b)`. Given what the user offers, the\n * largest fillable t is capped by the SCARCEST asset —\n * `t = min_i floor(offered_i·V_b/r_i)` — and anything above the pinned\n * deltas is returned as surplus. Every pool asset must be offered (> 0) or\n * t is zero and the deposit can never fill.\n *\n * Contrast with `calculateDepositN`, which is the plain value formula:\n * it matches the pin only for exactly proportional offers and OVERSTATES the\n * mint otherwise — using it for `minReceived` makes non-proportional orders\n * unfillable.\n */\nexport const calculatePinnedDeposit = (\n offered: bigint[],\n reserves: bigint[],\n prices: bigint[],\n totalLp: bigint,\n): {\n targetDeltaV: bigint;\n deltas: bigint[];\n generatedLp: bigint;\n nextTotalLp: bigint;\n shareAfterDeposit: Fraction;\n} => {\n if (offered.length !== reserves.length || reserves.length !== prices.length)\n throw new Error(\"offered, reserves and prices must be aligned\");\n if (prices.some((p) => p <= 0n)) throw new Error(\"Prices must be positive\");\n if (totalLp <= 0n) throw new Error(\"Not enough pool liquidity\");\n\n let vB = 0n;\n for (let i = 0; i < reserves.length; i++) {\n vB += reserves[i] * prices[i];\n }\n if (vB <= 0n) throw new Error(\"Pool value is zero\");\n\n let t: bigint | undefined;\n for (let i = 0; i < offered.length; i++) {\n if (reserves[i] === 0n) continue;\n const cap = (offered[i] * vB) / reserves[i];\n t = t === undefined || cap < t ? cap : t;\n }\n if (t === undefined || t <= 0n) {\n throw new Error(\n \"A constant-sum deposit must offer every pool asset in proportion (asymmetric deposits are disallowed on-chain)\",\n );\n }\n\n const deltas = reserves.map((r) => (r * t! + vB - 1n) / vB); // ceil\n const nextTotalLp = (totalLp * (vB + t)) / vB; // floor\n const generatedLp = nextTotalLp - totalLp;\n if (generatedLp <= 0n) throw new Error(\"Deposit mints zero LP\");\n\n return {\n targetDeltaV: t,\n deltas,\n generatedLp,\n nextTotalLp,\n shareAfterDeposit: SharedPoolMath.getShare(generatedLp, nextTotalLp),\n };\n};\n\n/**\n * The per-asset amounts a pinned deposit needs when the user anchors on one\n * asset's amount: t from the anchor (`floor(anchor·V_b/r_anchor)`), every\n * delta ceil-pinned to it. Drives proportional auto-fill in deposit forms.\n */\nexport const pinnedDepositFromAnchor = (\n anchorIndex: number,\n anchorAmount: bigint,\n reserves: bigint[],\n prices: bigint[],\n): bigint[] => {\n if (reserves.length !== prices.length)\n throw new Error(\"reserves and prices must be aligned\");\n if (\n anchorIndex < 0 ||\n anchorIndex >= reserves.length ||\n reserves[anchorIndex] <= 0n\n )\n throw new Error(\"anchor asset has no reserve\");\n if (anchorAmount <= 0n) return reserves.map(() => 0n);\n\n let vB = 0n;\n for (let i = 0; i < reserves.length; i++) {\n vB += reserves[i] * prices[i];\n }\n if (vB <= 0n) throw new Error(\"Pool value is zero\");\n\n const t = (anchorAmount * vB) / reserves[anchorIndex];\n return reserves.map((r, i) =>\n i === anchorIndex ? anchorAmount : (r * t + vB - 1n) / vB,\n );\n};\n\nexport const calculateDepositN = (\n amounts: bigint[],\n reserves: bigint[],\n prices: bigint[],\n totalLp: bigint,\n) => {\n if (amounts.length !== reserves.length || reserves.length !== prices.length)\n throw new Error(\"amounts, reserves and prices must be aligned\");\n if (prices.some((p) => p <= 0n)) throw new Error(\"Prices must be positive\");\n // Zeros in a MIX are fine — offering a subset is the point of the N-asset\n // form. What's rejected is a negative amount, or offering nothing at all.\n if (amounts.some((a) => a < 0n) || amounts.every((a) => a === 0n))\n throw new Error(\n \"Deposit amounts must be non-negative, with at least one positive\",\n );\n\n let totalValue = 0n;\n let depositValue = 0n;\n for (let i = 0; i < amounts.length; i++) {\n totalValue += reserves[i] * prices[i];\n depositValue += amounts[i] * prices[i];\n }\n if (totalValue <= 0n || totalLp <= 0n)\n throw new Error(\"Not enough pool liquidity\");\n\n const generatedLp = (depositValue * totalLp) / totalValue;\n const nextTotalLp = totalLp + generatedLp;\n\n return {\n nextTotalLp,\n generatedLp,\n shareAfterDeposit: SharedPoolMath.getShare(generatedLp, nextTotalLp),\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMG,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CACxBE,aAAmC,EACnCC,KAAa,EACbC,YAAoB,EACpBC,aAAqB,EACrBC,OAAe,EACfC,QAAgB,EAChBC,GAAkB,EAClBC,aAAuB,EACN;EACjB,IAAIN,KAAK,IAAI,EAAE,IAAIC,YAAY,IAAI,EAAE,IAAIC,aAAa,IAAI,EAAE,EAC1D,MAAM,IAAIK,KAAK,CAAC,qCAAqC,CAAC;EACxD,IAAIJ,OAAO,IAAI,EAAE,IAAIC,QAAQ,IAAI,EAAE,EACjC,MAAM,IAAIG,KAAK,CAAC,yBAAyB,CAAC;EAE5C,IAAMC,WAAW,GAAGC,kBAAQ,CAACC,UAAU,CAACL,GAAG,CAAC;EAC5C,IAAIG,WAAW,CAACG,EAAE,CAACF,kBAAQ,CAACG,IAAI,CAAC,IAAIJ,WAAW,CAACK,EAAE,CAACJ,kBAAQ,CAACK,GAAG,CAAC,EAC/D,MAAM,IAAIP,KAAK,CAAC,6BAA6B,CAAC;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GAAI8B,YAAY,GAAGpC,OAAO,GAAImC,UAAU;EACzD,IAAM5B,WAAW,GAAGP,OAAO,GAAGM,WAAW;EAEzC,OAAO;IACLC,WAAW,EAAXA,WAAW;IACXD,WAAW,EAAXA,WAAW;IACXE,iBAAiB,EAAEmB,qBAAc,CAACC,QAAQ,CAACtB,WAAW,EAAEC,WAAW;EACrE,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ConstantSumPool.js","names":["_asset","require","_fraction","_index","_toConsumableArray","r","_arrayWithoutHoles","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","TypeError","a","_arrayLikeToArray","t","toString","call","slice","constructor","name","Array","from","test","Symbol","iterator","isArray","length","e","n","getSwapOutput","exports","inputMetadata","input","inputReserve","outputReserve","priceIn","priceOut","fee","roundOutputUp","Error","feeFraction","Fraction","asFraction","lt","ZERO","gt","ONE","inputValue","feeValue","BigInt","numerator","denominator","quotient","outputValue","output","inputLpFee","nextInputReserve","nextOutputReserve","priceImpact","amountInLessFee","idealPrice","actualPrice","subtract","divide","lpFee","AssetAmount","getSwapInput","gte","feeNum","feeDen","feeDiff","targetValue","calculateLiquidity","b","aReserve","bReserve","totalLp","priceA","priceB","_calculatePinnedDepos","calculatePinnedDeposit","deltas","generatedLp","nextTotalLp","shareAfterDeposit","aChange","bChange","actualDepositedA","actualDepositedB","offered","reserves","prices","some","p","vB","i","cap","undefined","map","targetDeltaV","SharedPoolMath","getShare","pinnedDepositFromAnchor","anchorIndex","anchorAmount","calculateDepositN","amounts","every","totalValue","depositValue","calculateZap","lhs","rhs","swapIndex","swapInput","swapOutput","nextReserves","depositBasket","x","y","_ref","aX","aY","_ref2","rX","rY","_ref3","pX","pY","pinned","change"],"sources":["../../../src/PoolMath/ConstantSumPool.ts"],"sourcesContent":["import { AssetAmount, IAssetAmountMetadata } from \"@sundaeswap/asset\";\nimport { Fraction, type TFractionLike } from \"@sundaeswap/fraction\";\nimport { SharedPoolMath } from \"./index.js\";\n\n/**\n * Holds the calculated outcome of a constant-sum swap. Mirrors\n * {@link ConstantProductPool.TSwapOutcome} so both can flow through the same\n * generic swap-outcome consumers.\n */\nexport type TSwapOutcome = {\n input: bigint;\n output: bigint;\n lpFee: AssetAmount<IAssetAmountMetadata>;\n nextInputReserve: bigint;\n nextOutputReserve: bigint;\n priceImpact: Fraction;\n};\n\n/**\n * Calculate the swap outcome for a constant-sum (fixed-price) pool — the\n * invariant used by Sundae v4 stable/pegged pools. Unlike constant product,\n * the exchange rate is fixed by the pool's per-asset `prices`: the input is\n * converted to \"value\" at `priceIn`, the fee is taken off that value, and the\n * remainder is converted to the output asset at `priceOut`. The result is\n * capped at the output reserve (you can't take more than the pool holds).\n *\n * Matches the scooper's `cs_swap_result`:\n * output = floor((input·priceIn − floor(input·priceIn·fee)) / priceOut)\n *\n * @param inputMetadata Metadata for the supplied (input) asset — used for the fee AssetAmount.\n * @param input The amount of the input asset being swapped.\n * @param inputReserve The pool's reserve of the input asset.\n * @param outputReserve The pool's reserve of the output asset.\n * @param priceIn The pool's price for the input asset (from the constant-sum config).\n * @param priceOut The pool's price for the output asset.\n * @param fee The liquidity-provider fee (plus protocol fee) as a fraction.\n * @param roundOutputUp When true, round the output up instead of flooring.\n * @returns The swap details in the shared {@link TSwapOutcome} shape.\n */\nexport const getSwapOutput = (\n inputMetadata: IAssetAmountMetadata,\n input: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n priceIn: bigint,\n priceOut: bigint,\n fee: TFractionLike,\n roundOutputUp?: boolean,\n): TSwapOutcome => {\n if (input <= 0n || inputReserve <= 0n || outputReserve <= 0n)\n throw new Error(\"Input and reserves must be positive\");\n if (priceIn <= 0n || priceOut <= 0n)\n throw new Error(\"Prices must be positive\");\n\n const feeFraction = Fraction.asFraction(fee);\n if (feeFraction.lt(Fraction.ZERO) || feeFraction.gt(Fraction.ONE))\n throw new Error(\"fee must be between 0 and 1\");\n\n const inputValue = input * priceIn;\n const feeValue = new Fraction(\n inputValue * BigInt(feeFraction.numerator),\n BigInt(feeFraction.denominator),\n ).quotient;\n const outputValue = inputValue - feeValue;\n\n let output = roundOutputUp\n ? (outputValue + priceOut - 1n) / priceOut\n : outputValue / priceOut;\n\n // Can't take more than the pool holds.\n if (output > outputReserve) {\n output = outputReserve;\n }\n\n // LP fee expressed in input-asset units (value scales linearly with input,\n // so the input-denominated fee is input·feeRate) — matching ConstantProductPool.\n const inputLpFee = new Fraction(\n input * BigInt(feeFraction.numerator),\n BigInt(feeFraction.denominator),\n ).quotient;\n\n const nextInputReserve = inputReserve + input;\n const nextOutputReserve = outputReserve - output;\n\n // Price impact vs the pool's par price (priceOut/priceIn input-per-output);\n // ~0 for a constant-sum pool aside from the fee. See ConstantProductPool.\n let priceImpact = Fraction.ZERO;\n if (output > 0n) {\n const amountInLessFee = input - inputLpFee;\n const idealPrice = new Fraction(priceOut, priceIn);\n const actualPrice = new Fraction(amountInLessFee, output);\n priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n }\n\n return {\n input,\n output,\n lpFee: new AssetAmount(inputLpFee, inputMetadata),\n nextInputReserve,\n nextOutputReserve,\n priceImpact,\n };\n};\n\n/**\n * Calculate the minimal input required to receive a given output from a\n * constant-sum pool — the exact inverse of {@link getSwapOutput}.\n *\n * The forward math floors the fee off the input value, which makes the\n * post-fee value `ceil(input·priceIn·(1−fee))`; inverting that ceiling gives\n * the smallest input whose forward swap yields at least `output`.\n *\n * Unlike constant product there is no asymptote, so an output equal to the\n * full output reserve is attainable (the pool can be drained at par).\n *\n * @param inputMetadata Metadata for the supplied (input) asset — used for the fee AssetAmount.\n * @param output The desired amount of the output asset.\n * @param inputReserve The pool's reserve of the input asset.\n * @param outputReserve The pool's reserve of the output asset.\n * @param priceIn The pool's price for the input asset (from the constant-sum config).\n * @param priceOut The pool's price for the output asset.\n * @param fee The liquidity-provider fee (plus protocol fee) as a fraction.\n * @returns The swap details in the shared {@link TSwapOutcome} shape.\n */\nexport const getSwapInput = (\n inputMetadata: IAssetAmountMetadata,\n output: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n priceIn: bigint,\n priceOut: bigint,\n fee: TFractionLike,\n): TSwapOutcome => {\n if (output <= 0n || inputReserve <= 0n || outputReserve <= 0n)\n throw new Error(\"Output and reserves must be positive\");\n if (priceIn <= 0n || priceOut <= 0n)\n throw new Error(\"Prices must be positive\");\n if (output > outputReserve)\n throw new Error(\"Output must not exceed the output reserve\");\n\n const feeFraction = Fraction.asFraction(fee);\n if (feeFraction.lt(Fraction.ZERO) || feeFraction.gte(Fraction.ONE))\n throw new Error(\"fee must be [0,1)\");\n\n const feeNum = BigInt(feeFraction.numerator);\n const feeDen = BigInt(feeFraction.denominator);\n const feeDiff = feeDen - feeNum;\n\n // Forward: outputValue = ceil(input·priceIn·feeDiff/feeDen), and the swap\n // yields ≥ output iff outputValue ≥ output·priceOut. ceil(x/d) ≥ T for\n // integer x iff x ≥ d·(T−1)+1, so the minimal input is the ceiling of\n // (feeDen·(output·priceOut − 1) + 1) / (feeDiff·priceIn).\n const targetValue = output * priceOut;\n const numerator = feeDen * (targetValue - 1n) + 1n;\n const denominator = feeDiff * priceIn;\n const input = (numerator + denominator - 1n) / denominator;\n\n const inputLpFee = new Fraction(input * feeNum, feeDen).quotient;\n const nextInputReserve = inputReserve + input;\n const nextOutputReserve = outputReserve - output;\n\n // Same par-price impact definition as getSwapOutput.\n const amountInLessFee = input - inputLpFee;\n const idealPrice = new Fraction(priceOut, priceIn);\n const actualPrice = new Fraction(amountInLessFee, output);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n\n return {\n input,\n output,\n lpFee: new AssetAmount(inputLpFee, inputMetadata),\n nextInputReserve,\n nextOutputReserve,\n priceImpact,\n };\n};\n\n/**\n * Calculate the deposit parameters for a 2-asset constant-sum pool via the\n * TARGET-PINNED rule the deployed validator enforces (see\n * {@link calculatePinnedDeposit}): the mint is capped by the scarcest offered\n * asset, both assets must be offered, and anything above the pinned deltas is\n * refunded via aChange/bChange.\n *\n * @param {bigint} a - The amount of token A to deposit.\n * @param {bigint} b - The amount of token B to deposit.\n * @param {bigint} aReserve - The current reserve of token A in the pool.\n * @param {bigint} bReserve - The current reserve of token B in the pool.\n * @param {bigint} totalLp - The total lp tokens for the pool before the deposit.\n * @param {bigint} priceA - The pool's price for token A (from the constant-sum config).\n * @param {bigint} priceB - The pool's price for token B.\n * @throws {Error} If the pool has no value or minted lp.\n * @throws {Error} If both deposit amounts are zero, or either is negative.\n * @throws {Error} If either price is non-positive.\n */\nexport const calculateLiquidity = (\n a: bigint,\n b: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n priceA: bigint,\n priceB: bigint,\n) => {\n // Target-pinned (what the deployed validator accepts): mint by the\n // scarcest offered asset; anything above the pinned deltas is refunded\n // (aChange/bChange).\n const { deltas, generatedLp, nextTotalLp, shareAfterDeposit } =\n calculatePinnedDeposit(\n [a, b],\n [aReserve, bReserve],\n [priceA, priceB],\n totalLp,\n );\n\n return {\n nextTotalLp,\n generatedLp,\n shareAfterDeposit,\n aChange: a - deltas[0],\n bChange: b - deltas[1],\n actualDepositedA: deltas[0],\n actualDepositedB: deltas[1],\n };\n};\n\n/**\n * The N-asset form of {@link calculateLiquidity}, mirroring the v4 contract's\n * `compute_deposit_n` exactly: a deposit of any mix of the pool's assets is\n * valued at the fixed prices against the value of ALL reserves —\n *\n * generatedLp = Σ(amount_i·price_i) · totalLp / Σ(reserve_i·price_i)\n *\n * The three arrays must be aligned to the pool's canonical asset order (the\n * API's `assets`/`quantities`/`prices`). Estimating an N-asset pool's deposit\n * from just two of its reserves overstates the minted LP — the denominator is\n * the whole pool's value — which is exactly the mistake this exists to\n * prevent.\n */\n/**\n * The target-pinned deposit — what the deployed CS validator (cs_check tag 6)\n * actually accepts, and what the scooper builds. Asymmetric deposits are\n * disallowed on-chain: the fill declares a value delta `t` and every asset's\n * contribution is ceil-pinned to `ceil(r_i·t/V_b)`, with total LP\n * floor-pinned to `floor(lp_b·(V_b+t)/V_b)`. Given what the user offers, the\n * largest fillable t is capped by the SCARCEST asset —\n * `t = min_i floor(offered_i·V_b/r_i)` — and anything above the pinned\n * deltas is returned as surplus. Every pool asset must be offered (> 0) or\n * t is zero and the deposit can never fill.\n *\n * Contrast with `calculateDepositN`, which is the plain value formula:\n * it matches the pin only for exactly proportional offers and OVERSTATES the\n * mint otherwise — using it for `minReceived` makes non-proportional orders\n * unfillable.\n */\nexport const calculatePinnedDeposit = (\n offered: bigint[],\n reserves: bigint[],\n prices: bigint[],\n totalLp: bigint,\n): {\n targetDeltaV: bigint;\n deltas: bigint[];\n generatedLp: bigint;\n nextTotalLp: bigint;\n shareAfterDeposit: Fraction;\n} => {\n if (offered.length !== reserves.length || reserves.length !== prices.length)\n throw new Error(\"offered, reserves and prices must be aligned\");\n if (prices.some((p) => p <= 0n)) throw new Error(\"Prices must be positive\");\n if (totalLp <= 0n) throw new Error(\"Not enough pool liquidity\");\n\n let vB = 0n;\n for (let i = 0; i < reserves.length; i++) {\n vB += reserves[i] * prices[i];\n }\n if (vB <= 0n) throw new Error(\"Pool value is zero\");\n\n let t: bigint | undefined;\n for (let i = 0; i < offered.length; i++) {\n if (reserves[i] === 0n) continue;\n const cap = (offered[i] * vB) / reserves[i];\n t = t === undefined || cap < t ? cap : t;\n }\n if (t === undefined || t <= 0n) {\n throw new Error(\n \"A constant-sum deposit must offer every pool asset in proportion (asymmetric deposits are disallowed on-chain)\",\n );\n }\n\n const deltas = reserves.map((r) => (r * t! + vB - 1n) / vB); // ceil\n const nextTotalLp = (totalLp * (vB + t)) / vB; // floor\n const generatedLp = nextTotalLp - totalLp;\n if (generatedLp <= 0n) throw new Error(\"Deposit mints zero LP\");\n\n return {\n targetDeltaV: t,\n deltas,\n generatedLp,\n nextTotalLp,\n shareAfterDeposit: SharedPoolMath.getShare(generatedLp, nextTotalLp),\n };\n};\n\n/**\n * The per-asset amounts a pinned deposit needs when the user anchors on one\n * asset's amount: t from the anchor (`floor(anchor·V_b/r_anchor)`), every\n * delta ceil-pinned to it. Drives proportional auto-fill in deposit forms.\n */\nexport const pinnedDepositFromAnchor = (\n anchorIndex: number,\n anchorAmount: bigint,\n reserves: bigint[],\n prices: bigint[],\n): bigint[] => {\n if (reserves.length !== prices.length)\n throw new Error(\"reserves and prices must be aligned\");\n if (\n anchorIndex < 0 ||\n anchorIndex >= reserves.length ||\n reserves[anchorIndex] <= 0n\n )\n throw new Error(\"anchor asset has no reserve\");\n if (anchorAmount <= 0n) return reserves.map(() => 0n);\n\n let vB = 0n;\n for (let i = 0; i < reserves.length; i++) {\n vB += reserves[i] * prices[i];\n }\n if (vB <= 0n) throw new Error(\"Pool value is zero\");\n\n const t = (anchorAmount * vB) / reserves[anchorIndex];\n return reserves.map((r, i) =>\n i === anchorIndex ? anchorAmount : (r * t + vB - 1n) / vB,\n );\n};\n\nexport const calculateDepositN = (\n amounts: bigint[],\n reserves: bigint[],\n prices: bigint[],\n totalLp: bigint,\n) => {\n if (amounts.length !== reserves.length || reserves.length !== prices.length)\n throw new Error(\"amounts, reserves and prices must be aligned\");\n if (prices.some((p) => p <= 0n)) throw new Error(\"Prices must be positive\");\n // Zeros in a MIX are fine — offering a subset is the point of the N-asset\n // form. What's rejected is a negative amount, or offering nothing at all.\n if (amounts.some((a) => a < 0n) || amounts.every((a) => a === 0n))\n throw new Error(\n \"Deposit amounts must be non-negative, with at least one positive\",\n );\n\n let totalValue = 0n;\n let depositValue = 0n;\n for (let i = 0; i < amounts.length; i++) {\n totalValue += reserves[i] * prices[i];\n depositValue += amounts[i] * prices[i];\n }\n if (totalValue <= 0n || totalLp <= 0n)\n throw new Error(\"Not enough pool liquidity\");\n\n const generatedLp = (depositValue * totalLp) / totalValue;\n const nextTotalLp = totalLp + generatedLp;\n\n return {\n nextTotalLp,\n generatedLp,\n shareAfterDeposit: SharedPoolMath.getShare(generatedLp, nextTotalLp),\n };\n};\n\n/**\n * Outcome of {@link calculateZap}. Every array is aligned to `offered`.\n */\nexport type TZapOutcome = {\n /** Index of the offered asset swapped away; `undefined` when the basket already matches the reserves. */\n swapIndex: number | undefined;\n /** Amount of `offered[swapIndex]` swapped away. */\n swapInput: bigint;\n /** Amount of the other asset the swap yields. */\n swapOutput: bigint;\n /** Reserves after the swap — what the deposit pins against. */\n nextReserves: bigint[];\n /** `offered` after the swap: what is actually deposited. */\n depositBasket: bigint[];\n /** Per-asset ceil-pinned deposit. */\n deltas: bigint[];\n /** `depositBasket − deltas`: surplus returned to the user. */\n change: bigint[];\n targetDeltaV: bigint;\n generatedLp: bigint;\n nextTotalLp: bigint;\n shareAfterDeposit: Fraction;\n};\n\n/**\n * A zap on a 2-asset constant-sum pool: a non-proportional `offered` basket\n * is rebalanced by swapping part of the over-weighted asset, then deposited\n * under the target-pinned rule ({@link calculatePinnedDeposit}). The swap\n * amount `dx` is the one that leaves the post-swap basket proportional to\n * the post-swap reserves, so the pin consumes the whole basket up to\n * rounding. With `k = (1−fee)·p_X/p_Y`,\n *\n * (a_X − dx)/(r_X + dx) = (a_Y + k·dx)/(r_Y − k·dx)\n * ⇒ dx = (a_X·r_Y − a_Y·r_X) / (k·(r_X + a_X) + (r_Y + a_Y))\n *\n * (the dx² terms cancel). `dx` is floored and the swap leg follows\n * {@link getSwapOutput}; whatever imbalance rounding leaves comes back as\n * `change`.\n *\n * `fee` is the pool's fee for the swap direction — v4 splits bid and ask, so\n * the caller picks. Two assets only: with more, which assets to swap is an\n * allocation problem this formula does not address.\n */\nexport const calculateZap = (\n offered: bigint[],\n reserves: bigint[],\n prices: bigint[],\n totalLp: bigint,\n fee: TFractionLike,\n): TZapOutcome => {\n if (offered.length !== 2 || reserves.length !== 2 || prices.length !== 2)\n throw new Error(\"calculateZap supports exactly two assets\");\n if (prices.some((p) => p <= 0n)) throw new Error(\"Prices must be positive\");\n if (reserves.some((r) => r <= 0n))\n throw new Error(\"Reserves must be positive\");\n if (offered.some((a) => a < 0n) || offered.every((a) => a === 0n))\n throw new Error(\n \"Offered amounts must be non-negative, with at least one positive\",\n );\n if (totalLp <= 0n) throw new Error(\"Not enough pool liquidity\");\n\n const feeFraction = Fraction.asFraction(fee);\n if (feeFraction.lt(Fraction.ZERO) || feeFraction.gte(Fraction.ONE))\n throw new Error(\"fee must be [0,1)\");\n const feeNum = BigInt(feeFraction.numerator);\n const feeDen = BigInt(feeFraction.denominator);\n\n // Over-weighted side: compare a_0/r_0 against a_1/r_1 without division.\n const lhs = offered[0] * reserves[1];\n const rhs = offered[1] * reserves[0];\n const swapIndex = lhs > rhs ? 0 : lhs < rhs ? 1 : undefined;\n\n let swapInput = 0n;\n let swapOutput = 0n;\n const nextReserves = [...reserves];\n const depositBasket = [...offered];\n\n if (swapIndex !== undefined) {\n const x = swapIndex;\n const y = 1 - swapIndex;\n const [aX, aY] = [offered[x], offered[y]];\n const [rX, rY] = [reserves[x], reserves[y]];\n const [pX, pY] = [prices[x], prices[y]];\n\n // dx with k = (feeDen−feeNum)·pX / (feeDen·pY), cleared of denominators.\n const numerator = (aX * rY - aY * rX) * feeDen * pY;\n const denominator =\n (feeDen - feeNum) * pX * (rX + aX) + feeDen * pY * (rY + aY);\n swapInput = numerator / denominator;\n\n if (swapInput > 0n) {\n const inputValue = swapInput * pX;\n const feeValue = (inputValue * feeNum) / feeDen;\n swapOutput = (inputValue - feeValue) / pY;\n if (swapOutput >= rY)\n throw new Error(\n \"Pool too shallow: the rebalancing swap would drain it\",\n );\n\n nextReserves[x] = rX + swapInput;\n nextReserves[y] = rY - swapOutput;\n depositBasket[x] = aX - swapInput;\n depositBasket[y] = aY + swapOutput;\n }\n }\n\n if (depositBasket.some((a) => a <= 0n))\n throw new Error(\"Offered amount too small to zap into this pool\");\n\n const pinned = calculatePinnedDeposit(\n depositBasket,\n nextReserves,\n prices,\n totalLp,\n );\n\n return {\n swapIndex,\n swapInput,\n swapOutput,\n nextReserves,\n depositBasket,\n deltas: pinned.deltas,\n change: depositBasket.map((a, i) => a - pinned.deltas[i]),\n targetDeltaV: pinned.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