@sundaeswap/math 0.5.0 → 0.5.1
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/StableSwapsPool.js +8 -8
- package/dist/cjs/PoolMath/StableSwapsPool.js.map +1 -1
- package/dist/esm/PoolMath/StableSwapsPool.js +8 -8
- package/dist/esm/PoolMath/StableSwapsPool.js.map +1 -1
- package/dist/types/PoolMath/StableSwapsPool.d.ts +6 -5
- package/dist/types/PoolMath/StableSwapsPool.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/PoolMath/StableSwapsPool.ts +8 -8
- package/src/PoolMath/__tests__/StableSwapsPool.test.ts +76 -23
|
@@ -323,27 +323,27 @@ var getSwapOutput = exports.getSwapOutput = function getSwapOutput(outputMetadat
|
|
|
323
323
|
};
|
|
324
324
|
|
|
325
325
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
326
|
+
* The pool's marginal price as raw units of asset A per raw unit of asset B,
|
|
327
|
+
* |dx/dy| at the current reserves. This is the "ideal" price that swap price
|
|
328
|
+
* impact is measured against.
|
|
328
329
|
*
|
|
329
|
-
*
|
|
330
|
+
* Derived from the Stableswaps invariant 4A(x + y) + D = 4AD + D^3 / (4xy):
|
|
330
331
|
* price = (xpA + (dR * aReserve) / bReserve) / (xpA + dR)
|
|
331
|
-
* where xpA =
|
|
332
|
+
* where xpA = 4 * laf * aReserve and dR = D^3 / (4 * aReserve * bReserve)
|
|
332
333
|
*
|
|
333
334
|
* @param {bigint} aReserve - The current reserve amount of asset A in the pool.
|
|
334
335
|
* @param {bigint} bReserve - The current reserve amount of asset B in the pool.
|
|
335
336
|
* @param {bigint} laf - The linear amplification factor of the pool.
|
|
336
|
-
* @returns {Fraction}
|
|
337
|
+
* @returns {Fraction} Raw A per raw B at the current reserves.
|
|
337
338
|
*/
|
|
338
339
|
function getPrice(aReserve, bReserve, laf) {
|
|
339
|
-
// dx_0 / dx_1 only, however can have any number of coins in pool
|
|
340
|
-
var ann = laf * 2n * A_PRECISION;
|
|
341
340
|
var sumInvariant = getSumInvariant(laf, aReserve, bReserve) / RESERVE_PRECISION;
|
|
342
341
|
// D / n^n with n = 2
|
|
343
342
|
var dR = sumInvariant / 4n;
|
|
344
343
|
dR = dR * sumInvariant / aReserve;
|
|
345
344
|
dR = dR * sumInvariant / bReserve;
|
|
346
|
-
|
|
345
|
+
// 4A is the amplification term of the on-chain invariant, A = laf.
|
|
346
|
+
var xpA = 4n * laf * aReserve;
|
|
347
347
|
var p = new _fraction.Fraction(xpA + dR * aReserve / bReserve, xpA + dR);
|
|
348
348
|
return p;
|
|
349
349
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StableSwapsPool.js","names":["_asset","require","_index","_fraction","liquidityInvariant","assetA","assetB","linearAmplification","newSumInvariant","four_a","four_x_y","d_plus_one","d_cubed","d_plus_one_cubed","x_plus_y","sixteen_a_x_y","sixteen_a_x_y_x_plus_y","f1","f2","A_PRECISION","exports","RESERVE_PRECISION","FEE_PRECISION","getSumInvariant","a","x","y","Error","sum","d","ann","i","d_p","d_prev","getNewY","newX","aRaw","sumInvariant","yPrev","c","b","getFirstLp","laf","calculateLiquidity","aReserve","bReserve","totalLp","oldSumInvariant","newLpTokens","newTotalLpTokens","nextTotalLp","generatedLp","shareAfterDeposit","SharedPoolMath","getShare","aChange","bChange","actualDepositedA","actualDepositedB","getTokensForLp","lp","Fraction","quotient","getSwapOutput","outputMetadata","input","inputReserve","outputReserve","fee","protocolFee","roundOutputUp","asFraction","lt","ZERO","gte","ONE","combinedFee","add","nextInputReserve","newY","deltaYPrec","deltaY","totalFee","multiply","divide","totalProtocolFee","totalLpFee","output","subtract","safeOutput","numerator","denominator","nextOutputReserve","idealPrice","getPrice","actualPrice","priceImpact","lpFee","AssetAmount","nextSumInvariant","dR","xpA","p","getSwapInput","rawOutputF","sub","rawOutput"],"sources":["../../../src/PoolMath/StableSwapsPool.ts"],"sourcesContent":["import { AssetAmount, IAssetAmountMetadata } from \"@sundaeswap/asset\";\nimport { SharedPoolMath } from \"./index.js\";\nimport { Fraction, type TFractionLike } from \"@sundaeswap/fraction\";\n\n/**\n * Validates that a given sum invariant (D) satisfies the liquidity invariant equation\n * for the Stableswaps curve. This function checks if D is within the valid range by\n * evaluating the invariant function at D and D+1.\n *\n * The liquidity invariant ensures that the curve equation is satisfied:\n * 4A * 4xy * D + D^3 - (4xy * 4A * (x + y) + 4xy * D) should be <= 0 at D and > 0 at D+1\n *\n * @param {bigint} assetA - The reserve amount of asset A (already scaled by RESERVE_PRECISION).\n * @param {bigint} assetB - The reserve amount of asset B (already scaled by RESERVE_PRECISION).\n * @param {bigint} linearAmplification - The amplification coefficient for the pool.\n * @param {bigint} newSumInvariant - The proposed sum invariant (D) to validate.\n * @returns {boolean} True if the sum invariant satisfies the liquidity invariant equation, false otherwise.\n */\nexport function liquidityInvariant(\n assetA: bigint,\n assetB: bigint,\n linearAmplification: bigint,\n newSumInvariant: bigint,\n) {\n // 4 * A * 4 * (x*y) * D + D^3 - (4(x*y) * (4A(x + y) + D))\n // 4A * 4xy * D + D^3 - (4xy * 4a * (x + y) + 4xy * D)\n // 16Axy * D + D^3 - (16Axy * (x + y) + 4xy * D)\n const four_a = 4n * linearAmplification;\n const four_x_y = 4n * assetA * assetB;\n const d_plus_one = newSumInvariant + 1n;\n const d_cubed = newSumInvariant * newSumInvariant * newSumInvariant;\n const d_plus_one_cubed = d_plus_one * d_plus_one * d_plus_one;\n const x_plus_y = assetA + assetB;\n const sixteen_a_x_y = four_a * four_x_y;\n const sixteen_a_x_y_x_plus_y = sixteen_a_x_y * x_plus_y;\n const f1 =\n sixteen_a_x_y * newSumInvariant +\n d_cubed -\n (sixteen_a_x_y_x_plus_y + four_x_y * newSumInvariant);\n const f2 =\n sixteen_a_x_y * d_plus_one +\n d_plus_one_cubed -\n (sixteen_a_x_y_x_plus_y + four_x_y * d_plus_one);\n return f1 <= 0n && f2 > 0n;\n}\n\n/**\n * Precision factor for the amplification coefficient calculations.\n * Used to scale the amplification factor for more precise arithmetic operations.\n */\nexport const A_PRECISION: bigint = 200n;\n\n/**\n * Precision factor for reserve calculations in the Stableswaps curve.\n * Reserves are multiplied by this value to maintain precision during calculations.\n * This allows for accurate fractional calculations with integer arithmetic.\n */\nexport const RESERVE_PRECISION: bigint = 1_000_000_000_000n;\n\n/**\n * Precision factor for fee calculations, representing basis points.\n * A value of 10,000 means fees are calculated with 0.01% precision (1 basis point).\n */\nexport const FEE_PRECISION: bigint = 10_000n;\n\n/**\n * Calculates the sum invariant (D) for a Stableswaps pool using Newton's method.\n * The sum invariant represents the total value in the pool and is used to determine\n * the fair exchange rate between assets.\n *\n * This function iteratively solves for D in the Stableswaps invariant equation:\n * Ann * sum + D_p * 2 = Ann * D + D_p * 3\n * where D_p = D^3 / (4 * x * y) and Ann = A * n^n (with n=2)\n *\n * The iteration continues until convergence (difference <= 1) or fails after 255 iterations.\n *\n * @param {bigint} a - The amplification coefficient for the pool (will be scaled by A_PRECISION).\n * @param {bigint} x - The reserve amount of the first asset (will be scaled by RESERVE_PRECISION).\n * @param {bigint} y - The reserve amount of the second asset (will be scaled by RESERVE_PRECISION).\n * @returns {bigint} The calculated sum invariant (D) scaled by RESERVE_PRECISION.\n * @throws {Error} If the amplification coefficient is not positive.\n * @throws {Error} If convergence fails after 255 iterations.\n */\nexport function getSumInvariant(a: bigint, x: bigint, y: bigint): bigint {\n if (a <= 0n) {\n throw new Error(\"Amplification coefficient must be positive.\");\n }\n x = x * RESERVE_PRECISION;\n y = y * RESERVE_PRECISION;\n a = a * A_PRECISION;\n const sum: bigint = x + y;\n if (sum === 0n) {\n return 0n;\n }\n\n let d = sum;\n const ann = a * 2n;\n for (let i = 0; i < 255; i++) {\n const d_p = (d * d * d) / (4n * x * y);\n const d_prev = d;\n\n d =\n (((ann * sum) / 100n + d_p * 2n) * d) /\n (((ann - 100n) * d) / 100n + 3n * d_p);\n\n if (d > d_prev) {\n if (d - d_prev <= 1) {\n if (liquidityInvariant(x, y, a / A_PRECISION, d)) {\n return d;\n } else {\n return d - 1n;\n }\n }\n } else {\n if (d_prev - d <= 1) {\n if (liquidityInvariant(x, y, a / A_PRECISION, d)) {\n return d;\n } else {\n return d - 1n;\n }\n }\n }\n }\n throw new Error(\"Failed to converge on D value after 255 iterations.\");\n}\n\n/**\n * Calculates the new Y reserve value given a new X reserve value and the sum invariant.\n * This function uses Newton's method to iteratively solve for Y in the Stableswaps equation\n * while maintaining the pool's invariant (D).\n *\n * The function solves: Y^2 + (sum + (D * A_PRECISION) / (2 * Ann) - D) * Y - c = 0\n * where c is derived from D and the pool parameters.\n *\n * This is used during swaps to determine the output reserve after an input is added.\n *\n * @param {bigint} newX - The new reserve amount for asset X (will be scaled by RESERVE_PRECISION internally).\n * @param {bigint} aRaw - The raw amplification coefficient for the pool (will be scaled by A_PRECISION).\n * @param {bigint} sumInvariant - The pool's sum invariant (D), already scaled.\n * @returns {bigint} The calculated Y reserve value scaled by RESERVE_PRECISION.\n * @throws {Error} If convergence fails after 255 iterations.\n */\nexport function getNewY(\n newX: bigint,\n aRaw: bigint,\n sumInvariant: bigint,\n): bigint {\n newX = newX * RESERVE_PRECISION;\n const sum = newX;\n let yPrev: bigint;\n let c = sumInvariant;\n const ann = aRaw * A_PRECISION * 2n;\n\n c = (c * sumInvariant) / (newX * 2n);\n c = (c * sumInvariant * A_PRECISION) / 2n;\n c = c / (ann * 2n);\n const b = sum + (sumInvariant * A_PRECISION) / 2n / ann;\n let y = sumInvariant;\n for (let i = 0; i < 255; i++) {\n yPrev = y;\n y = (y * y + c) / (y * 2n + b - sumInvariant);\n if (y > yPrev) {\n if (y - yPrev <= 1n) {\n if (liquidityInvariant(newX, y, aRaw, sumInvariant)) {\n return y;\n } else {\n return y + 1n;\n }\n }\n } else {\n if (yPrev - y <= 1n) {\n if (liquidityInvariant(newX, y, aRaw, sumInvariant)) {\n return y;\n } else {\n return y + 1n;\n }\n }\n }\n }\n throw new Error(\"Failed to converge on y value after 255 iterations.\");\n}\n\n/**\n * Calculates the initial LP token amount for the first liquidity provision to a pool.\n * This is used when bootstrapping a new pool with initial reserves of assets A and B.\n *\n * The LP tokens minted are derived from the sum invariant (D) divided by the reserve precision,\n * effectively representing the pool's total value at inception.\n *\n * @param {bigint} a - The initial amount of token A being deposited.\n * @param {bigint} b - The initial amount of token B being deposited.\n * @param {bigint} laf - The linear amplification factor for the pool.\n * @returns {bigint} The amount of LP tokens to mint for the first liquidity provision.\n */\nexport const getFirstLp = (a: bigint, b: bigint, laf: bigint) =>\n getSumInvariant(laf, a, b) / RESERVE_PRECISION;\n\n/**\n * Calculates the liquidity parameters for adding liquidity to a Stableswaps pool.\n * This function supports mixed deposits where both assets can be deposited in any proportion.\n *\n * The calculation is based on the change in the sum invariant (D) before and after the deposit.\n * LP tokens are minted proportionally to the increase in D relative to the old D value.\n *\n * TODO: Investigate way to optimize actual deposited amounts\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} laf - The linear amplification factor of the pool.\n * @throws {Error} If the pool doesn't have enough liquidity (both reserves are zero).\n * @throws {Error} If both deposit amounts are zero.\n * @returns {Object} An object containing:\n * - nextTotalLp: The total LP tokens for the pool after the deposit.\n * - generatedLp: The amount of LP tokens generated by the deposit.\n * - shareAfterDeposit: The depositor's share of the pool after the deposit (as a Fraction).\n * - aChange: Always 0n for Stableswaps (no refund needed).\n * - bChange: Always 0n for Stableswaps (no refund needed).\n * - actualDepositedA: The actual amount of A deposited (always equal to input a).\n * - actualDepositedB: The actual amount of B deposited (always equal to input b).\n */\nexport const calculateLiquidity = (\n a: bigint,\n b: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n laf: bigint,\n) => {\n if (aReserve === 0n && bReserve === 0n) {\n throw new Error(\"Not enough pool liquidity\");\n }\n\n if (a === 0n && b === 0n) {\n throw new Error(\"Cannot use a deposit asset amount of 0\");\n }\n\n const oldSumInvariant = getSumInvariant(laf, aReserve, bReserve);\n\n const newSumInvariant = getSumInvariant(laf, aReserve + a, bReserve + b);\n\n const newLpTokens =\n ((newSumInvariant - oldSumInvariant) * totalLp) / oldSumInvariant;\n\n const newTotalLpTokens = totalLp + newLpTokens;\n\n return {\n nextTotalLp: newTotalLpTokens,\n generatedLp: newLpTokens,\n shareAfterDeposit: SharedPoolMath.getShare(newLpTokens, newTotalLpTokens),\n aChange: 0n,\n bChange: 0n,\n actualDepositedA: a,\n actualDepositedB: b,\n };\n};\n\n/**\n * Calculates the token amounts that a given LP token amount represents when withdrawing\n * from a Stableswaps pool. The withdrawal is proportional to the LP tokens being redeemed\n * relative to the total LP supply.\n *\n * This uses a simple linear proportion: amount = (lp * reserve) / totalLp for each asset.\n *\n * @param {bigint} lp - The amount of LP tokens being redeemed.\n * @param {bigint} aReserve - The pool's current reserve amount of token A.\n * @param {bigint} bReserve - The pool's current reserve amount of token B.\n * @param {bigint} totalLp - The pool's total minted LP tokens currently in circulation.\n * @returns {SharedPoolMath.TPair} A tuple [a, b] containing the amounts of tokens A and B to withdraw.\n */\nexport const getTokensForLp = (\n lp: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n): SharedPoolMath.TPair => [\n new Fraction(lp * aReserve, totalLp).quotient,\n new Fraction(lp * bReserve, totalLp).quotient,\n];\n\n/**\n * Represents the complete outcome of a swap operation in a Stableswaps pool.\n * Contains all relevant information about the swap including amounts, fees, updated reserves,\n * and price impact.\n */\nexport type TSwapOutcome = {\n /** The amount of input tokens being swapped */\n input: bigint;\n /** The amount of output tokens received (after all fees) */\n output: bigint;\n /** The portion of fees that goes to liquidity providers */\n lpFee: AssetAmount<IAssetAmountMetadata>;\n /** The portion of fees that goes to the protocol */\n protocolFee: AssetAmount<IAssetAmountMetadata>;\n /** The input asset reserve amount after the swap */\n nextInputReserve: bigint;\n /** The output asset reserve amount after the swap (excluding protocol fees) */\n nextOutputReserve: bigint;\n /** The pool's sum invariant (D) after the swap */\n nextSumInvariant: bigint;\n /** The price impact of the swap as a fraction (difference between ideal and actual price) */\n priceImpact: Fraction;\n};\n\n/**\n * Calculates the output amount and all swap parameters for a given input amount in a Stableswaps pool.\n * This function determines how many output tokens will be received for a given input, accounting for\n * the Stableswaps curve, LP fees, and protocol fees.\n *\n * The calculation process:\n * 1. Validates inputs and fees\n * 2. Calculates the current sum invariant (D)\n * 3. Determines the new Y value after adding input to X\n * 4. Calculates raw output and applies fees (LP + protocol)\n * 5. Computes price impact by comparing ideal vs actual execution price\n *\n * @param {bigint} input - The amount of input tokens to swap.\n * @param {bigint} inputReserve - The current reserve amount of the input token in the pool.\n * @param {bigint} outputReserve - The current reserve amount of the output token in the pool.\n * @param {TFractionLike} fee - The liquidity provider fee as a fraction (e.g., 0.003 for 0.3%).\n * @param {TFractionLike} protocolFee - The protocol fee as a fraction.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @param {boolean} [roundOutputUp] - Optional flag to round output up instead of down (default: false).\n * @returns {TSwapOutcome} The complete swap outcome including output, fees, reserves, and price impact.\n * @throws {Error} If input or reserves are not positive.\n * @throws {Error} If fee is not in the range [0, 1).\n * @throws {Error} If protocol fee is not in the range [0, 1).\n * @throws {Error} If combined fee is greater than or equal to 1.\n */\nexport const getSwapOutput = (\n outputMetadata: IAssetAmountMetadata,\n input: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n fee: TFractionLike,\n protocolFee: TFractionLike,\n laf: bigint,\n roundOutputUp?: boolean,\n): TSwapOutcome => {\n if (input <= 0 || inputReserve <= 0 || outputReserve <= 0)\n throw new Error(\"Input and reserves must be positive\");\n\n fee = Fraction.asFraction(fee);\n if (fee.lt(Fraction.ZERO) || fee.gte(Fraction.ONE))\n throw new Error(\"fee must be between 0 and 1\");\n\n protocolFee = Fraction.asFraction(protocolFee);\n if (protocolFee.lt(Fraction.ZERO) || protocolFee.gte(Fraction.ONE))\n throw new Error(\"protocolFee must be between 0 and 1\");\n\n const combinedFee = fee.add(protocolFee);\n if (combinedFee.gte(Fraction.ONE))\n throw new Error(\"Combined fee must be less than 1\");\n const sumInvariant = getSumInvariant(laf, inputReserve, outputReserve);\n const nextInputReserve = inputReserve + input;\n const newY = getNewY(nextInputReserve, laf, sumInvariant);\n\n const deltaYPrec = outputReserve * RESERVE_PRECISION - newY;\n const deltaY = new Fraction(deltaYPrec, RESERVE_PRECISION);\n const totalFee = combinedFee\n .multiply(FEE_PRECISION)\n .multiply(deltaY.quotient)\n .add(Fraction.asFraction(FEE_PRECISION - 1n))\n .divide(FEE_PRECISION).quotient;\n const totalProtocolFee = protocolFee\n .multiply(totalFee)\n .divide(combinedFee).quotient;\n const totalLpFee = totalFee - totalProtocolFee;\n const output = deltaY.subtract(totalFee);\n const safeOutput = roundOutputUp\n ? (output.numerator + output.denominator - 1n) / output.denominator\n : output.quotient;\n const nextOutputReserve = outputReserve - safeOutput - totalProtocolFee;\n\n // PRICEIMPACT: \"priceImpact\" is slightly misleadingly named in the industry as a whole\n // just by it's name, it would imply that it's the percentage difference between\n // the current price and the price after the swap, but it's actually the percentage\n // difference between the real price of your swap, and the price implied by the current\n // reserves; We got this wrong in v1, but this aligns it with the industry standard\n // Source: https://dailydefi.org/articles/price-impact-and-how-to-calculate/\n const idealPrice = getPrice(inputReserve, outputReserve, laf);\n const actualPrice = new Fraction(input, safeOutput);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n return {\n input,\n output: safeOutput,\n lpFee: new AssetAmount(totalLpFee, outputMetadata),\n protocolFee: new AssetAmount(totalProtocolFee, outputMetadata),\n nextInputReserve,\n nextOutputReserve,\n nextSumInvariant: getSumInvariant(laf, nextInputReserve, nextOutputReserve),\n priceImpact,\n };\n};\n\n/**\n * Calculates the current price (exchange rate) of asset A in terms of asset B for a Stableswaps pool.\n * The price is derived from the Stableswaps curve equation and takes into account the amplification factor.\n *\n * The calculation uses the formula:\n * price = (xpA + (dR * aReserve) / bReserve) / (xpA + dR)\n * where xpA = (Ann * aReserve) / A_PRECISION and dR is derived from the sum invariant\n *\n * @param {bigint} aReserve - The current reserve amount of asset A in the pool.\n * @param {bigint} bReserve - The current reserve amount of asset B in the pool.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @returns {Fraction} The price of asset A in terms of asset B as a Fraction.\n */\nexport function getPrice(\n aReserve: bigint,\n bReserve: bigint,\n laf: bigint,\n): Fraction {\n // dx_0 / dx_1 only, however can have any number of coins in pool\n const ann = laf * 2n * A_PRECISION;\n const sumInvariant =\n getSumInvariant(laf, aReserve, bReserve) / RESERVE_PRECISION;\n // D / n^n with n = 2\n let dR = sumInvariant / 4n;\n dR = (dR * sumInvariant) / aReserve;\n dR = (dR * sumInvariant) / bReserve;\n const xpA = (ann * aReserve) / A_PRECISION;\n const p = new Fraction(xpA + (dR * aReserve) / bReserve, xpA + dR);\n return p;\n}\n\n/**\n * Calculates the required input amount and all swap parameters for a desired output amount in a Stableswaps pool.\n * This is the reverse operation of getSwapOutput - given how much you want to receive, it determines\n * how much you need to provide as input, accounting for fees and the Stableswaps curve.\n *\n * The calculation process:\n * 1. Validates inputs, fees, and output constraints\n * 2. Calculates raw output needed before fees\n * 3. Determines the new X value to achieve the desired Y reduction\n * 4. Calculates required input and separates LP and protocol fees\n * 5. Computes price impact by comparing ideal vs actual execution price\n *\n * @param {bigint} output - The desired amount of output tokens to receive.\n * @param {bigint} inputReserve - The current reserve amount of the input token in the pool.\n * @param {bigint} outputReserve - The current reserve amount of the output token in the pool.\n * @param {TFractionLike} fee - The liquidity provider fee as a fraction (e.g., 0.003 for 0.3%).\n * @param {TFractionLike} protocolFee - The protocol fee as a fraction.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @returns {TSwapOutcome} The complete swap outcome including required input, fees, reserves, and price impact.\n * @throws {Error} If output or reserves are not positive.\n * @throws {Error} If output is greater than or equal to the output reserve.\n * @throws {Error} If fee is not in the range [0, 1).\n * @throws {Error} If protocol fee is not in the range [0, 1).\n * @throws {Error} If combined fee is greater than or equal to 1.\n */\nexport const getSwapInput = (\n outputMetadata: IAssetAmountMetadata,\n output: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n fee: TFractionLike,\n protocolFee: TFractionLike,\n laf: bigint,\n): TSwapOutcome => {\n if (output <= 0 || inputReserve <= 0 || outputReserve <= 0)\n throw new Error(\"Output and reserves must be positive\");\n\n if (output >= outputReserve)\n throw new Error(\"Output must be less than output reserve\");\n\n fee = Fraction.asFraction(fee);\n if (fee.lt(Fraction.ZERO) || fee.gte(Fraction.ONE))\n throw new Error(\"fee must be [0,1)\");\n\n protocolFee = Fraction.asFraction(protocolFee);\n if (protocolFee.lt(Fraction.ZERO) || protocolFee.gte(Fraction.ONE))\n throw new Error(\"protocolFee must be between 0 and 1\");\n\n const combinedFee = fee.add(protocolFee);\n if (combinedFee.gte(Fraction.ONE))\n throw new Error(\"Combined fee must be less than 1\");\n\n // output = rawOutput * (1-fee)\n // rawOutput = output / (1-fee)\n const rawOutputF = Fraction.asFraction(output).divide(\n Fraction.ONE.sub(combinedFee),\n );\n const rawOutput =\n (rawOutputF.numerator + rawOutputF.denominator - 1n) /\n rawOutputF.denominator;\n const sumInvariant = getSumInvariant(laf, inputReserve, outputReserve);\n const newX = getNewY(outputReserve - rawOutput, laf, sumInvariant);\n const input =\n (newX - inputReserve * RESERVE_PRECISION + RESERVE_PRECISION - 1n) /\n RESERVE_PRECISION;\n\n const totalFee =\n (combinedFee.multiply(FEE_PRECISION).quotient * rawOutput +\n FEE_PRECISION -\n 1n) /\n FEE_PRECISION;\n const totalProtocolFee = protocolFee\n .multiply(totalFee)\n .divide(combinedFee).quotient;\n\n const totalLpFee = totalFee - totalProtocolFee;\n\n const nextInputReserve = inputReserve + input;\n const nextOutputReserve = outputReserve - output - totalProtocolFee;\n\n // See PRICEIMPACT\n const idealPrice = getPrice(inputReserve, outputReserve, laf);\n const actualPrice = new Fraction(input, output);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n\n const nextSumInvariant = getSumInvariant(\n laf,\n nextInputReserve,\n nextOutputReserve,\n );\n\n return {\n input,\n output,\n lpFee: new AssetAmount(totalLpFee, outputMetadata),\n protocolFee: new AssetAmount(totalProtocolFee, outputMetadata),\n nextInputReserve,\n nextOutputReserve,\n priceImpact,\n nextSumInvariant,\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,kBAAkBA,CAChCC,MAAc,EACdC,MAAc,EACdC,mBAA2B,EAC3BC,eAAuB,EACvB;EACA;EACA;EACA;EACA,IAAMC,MAAM,GAAG,EAAE,GAAGF,mBAAmB;EACvC,IAAMG,QAAQ,GAAG,EAAE,GAAGL,MAAM,GAAGC,MAAM;EACrC,IAAMK,UAAU,GAAGH,eAAe,GAAG,EAAE;EACvC,IAAMI,OAAO,GAAGJ,eAAe,GAAGA,eAAe,GAAGA,eAAe;EACnE,IAAMK,gBAAgB,GAAGF,UAAU,GAAGA,UAAU,GAAGA,UAAU;EAC7D,IAAMG,QAAQ,GAAGT,MAAM,GAAGC,MAAM;EAChC,IAAMS,aAAa,GAAGN,MAAM,GAAGC,QAAQ;EACvC,IAAMM,sBAAsB,GAAGD,aAAa,GAAGD,QAAQ;EACvD,IAAMG,EAAE,GACNF,aAAa,GAAGP,eAAe,GAC/BI,OAAO,IACNI,sBAAsB,GAAGN,QAAQ,GAAGF,eAAe,CAAC;EACvD,IAAMU,EAAE,GACNH,aAAa,GAAGJ,UAAU,GAC1BE,gBAAgB,IACfG,sBAAsB,GAAGN,QAAQ,GAAGC,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3B,KAAK,EAALA,KAAK;IACLsB,MAAM,EAANA,MAAM;IACNU,KAAK,EAAE,IAAIC,kBAAW,CAACZ,UAAU,EAAEtB,cAAc,CAAC;IAClDK,WAAW,EAAE,IAAI6B,kBAAW,CAACb,gBAAgB,EAAErB,cAAc,CAAC;IAC9Dc,gBAAgB,EAAhBA,gBAAgB;IAChBc,iBAAiB,EAAjBA,iBAAiB;IACjBI,WAAW,EAAXA,WAAW;IACXG,gBAAgB,EAAhBA;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"StableSwapsPool.js","names":["_asset","require","_index","_fraction","liquidityInvariant","assetA","assetB","linearAmplification","newSumInvariant","four_a","four_x_y","d_plus_one","d_cubed","d_plus_one_cubed","x_plus_y","sixteen_a_x_y","sixteen_a_x_y_x_plus_y","f1","f2","A_PRECISION","exports","RESERVE_PRECISION","FEE_PRECISION","getSumInvariant","a","x","y","Error","sum","d","ann","i","d_p","d_prev","getNewY","newX","aRaw","sumInvariant","yPrev","c","b","getFirstLp","laf","calculateLiquidity","aReserve","bReserve","totalLp","oldSumInvariant","newLpTokens","newTotalLpTokens","nextTotalLp","generatedLp","shareAfterDeposit","SharedPoolMath","getShare","aChange","bChange","actualDepositedA","actualDepositedB","getTokensForLp","lp","Fraction","quotient","getSwapOutput","outputMetadata","input","inputReserve","outputReserve","fee","protocolFee","roundOutputUp","asFraction","lt","ZERO","gte","ONE","combinedFee","add","nextInputReserve","newY","deltaYPrec","deltaY","totalFee","multiply","divide","totalProtocolFee","totalLpFee","output","subtract","safeOutput","numerator","denominator","nextOutputReserve","idealPrice","getPrice","actualPrice","priceImpact","lpFee","AssetAmount","nextSumInvariant","dR","xpA","p","getSwapInput","rawOutputF","sub","rawOutput"],"sources":["../../../src/PoolMath/StableSwapsPool.ts"],"sourcesContent":["import { AssetAmount, IAssetAmountMetadata } from \"@sundaeswap/asset\";\nimport { SharedPoolMath } from \"./index.js\";\nimport { Fraction, type TFractionLike } from \"@sundaeswap/fraction\";\n\n/**\n * Validates that a given sum invariant (D) satisfies the liquidity invariant equation\n * for the Stableswaps curve. This function checks if D is within the valid range by\n * evaluating the invariant function at D and D+1.\n *\n * The liquidity invariant ensures that the curve equation is satisfied:\n * 4A * 4xy * D + D^3 - (4xy * 4A * (x + y) + 4xy * D) should be <= 0 at D and > 0 at D+1\n *\n * @param {bigint} assetA - The reserve amount of asset A (already scaled by RESERVE_PRECISION).\n * @param {bigint} assetB - The reserve amount of asset B (already scaled by RESERVE_PRECISION).\n * @param {bigint} linearAmplification - The amplification coefficient for the pool.\n * @param {bigint} newSumInvariant - The proposed sum invariant (D) to validate.\n * @returns {boolean} True if the sum invariant satisfies the liquidity invariant equation, false otherwise.\n */\nexport function liquidityInvariant(\n assetA: bigint,\n assetB: bigint,\n linearAmplification: bigint,\n newSumInvariant: bigint,\n) {\n // 4 * A * 4 * (x*y) * D + D^3 - (4(x*y) * (4A(x + y) + D))\n // 4A * 4xy * D + D^3 - (4xy * 4a * (x + y) + 4xy * D)\n // 16Axy * D + D^3 - (16Axy * (x + y) + 4xy * D)\n const four_a = 4n * linearAmplification;\n const four_x_y = 4n * assetA * assetB;\n const d_plus_one = newSumInvariant + 1n;\n const d_cubed = newSumInvariant * newSumInvariant * newSumInvariant;\n const d_plus_one_cubed = d_plus_one * d_plus_one * d_plus_one;\n const x_plus_y = assetA + assetB;\n const sixteen_a_x_y = four_a * four_x_y;\n const sixteen_a_x_y_x_plus_y = sixteen_a_x_y * x_plus_y;\n const f1 =\n sixteen_a_x_y * newSumInvariant +\n d_cubed -\n (sixteen_a_x_y_x_plus_y + four_x_y * newSumInvariant);\n const f2 =\n sixteen_a_x_y * d_plus_one +\n d_plus_one_cubed -\n (sixteen_a_x_y_x_plus_y + four_x_y * d_plus_one);\n return f1 <= 0n && f2 > 0n;\n}\n\n/**\n * Precision factor for the amplification coefficient calculations.\n * Used to scale the amplification factor for more precise arithmetic operations.\n */\nexport const A_PRECISION: bigint = 200n;\n\n/**\n * Precision factor for reserve calculations in the Stableswaps curve.\n * Reserves are multiplied by this value to maintain precision during calculations.\n * This allows for accurate fractional calculations with integer arithmetic.\n */\nexport const RESERVE_PRECISION: bigint = 1_000_000_000_000n;\n\n/**\n * Precision factor for fee calculations, representing basis points.\n * A value of 10,000 means fees are calculated with 0.01% precision (1 basis point).\n */\nexport const FEE_PRECISION: bigint = 10_000n;\n\n/**\n * Calculates the sum invariant (D) for a Stableswaps pool using Newton's method.\n * The sum invariant represents the total value in the pool and is used to determine\n * the fair exchange rate between assets.\n *\n * This function iteratively solves for D in the Stableswaps invariant equation:\n * Ann * sum + D_p * 2 = Ann * D + D_p * 3\n * where D_p = D^3 / (4 * x * y) and Ann = A * n^n (with n=2)\n *\n * The iteration continues until convergence (difference <= 1) or fails after 255 iterations.\n *\n * @param {bigint} a - The amplification coefficient for the pool (will be scaled by A_PRECISION).\n * @param {bigint} x - The reserve amount of the first asset (will be scaled by RESERVE_PRECISION).\n * @param {bigint} y - The reserve amount of the second asset (will be scaled by RESERVE_PRECISION).\n * @returns {bigint} The calculated sum invariant (D) scaled by RESERVE_PRECISION.\n * @throws {Error} If the amplification coefficient is not positive.\n * @throws {Error} If convergence fails after 255 iterations.\n */\nexport function getSumInvariant(a: bigint, x: bigint, y: bigint): bigint {\n if (a <= 0n) {\n throw new Error(\"Amplification coefficient must be positive.\");\n }\n x = x * RESERVE_PRECISION;\n y = y * RESERVE_PRECISION;\n a = a * A_PRECISION;\n const sum: bigint = x + y;\n if (sum === 0n) {\n return 0n;\n }\n\n let d = sum;\n const ann = a * 2n;\n for (let i = 0; i < 255; i++) {\n const d_p = (d * d * d) / (4n * x * y);\n const d_prev = d;\n\n d =\n (((ann * sum) / 100n + d_p * 2n) * d) /\n (((ann - 100n) * d) / 100n + 3n * d_p);\n\n if (d > d_prev) {\n if (d - d_prev <= 1) {\n if (liquidityInvariant(x, y, a / A_PRECISION, d)) {\n return d;\n } else {\n return d - 1n;\n }\n }\n } else {\n if (d_prev - d <= 1) {\n if (liquidityInvariant(x, y, a / A_PRECISION, d)) {\n return d;\n } else {\n return d - 1n;\n }\n }\n }\n }\n throw new Error(\"Failed to converge on D value after 255 iterations.\");\n}\n\n/**\n * Calculates the new Y reserve value given a new X reserve value and the sum invariant.\n * This function uses Newton's method to iteratively solve for Y in the Stableswaps equation\n * while maintaining the pool's invariant (D).\n *\n * The function solves: Y^2 + (sum + (D * A_PRECISION) / (2 * Ann) - D) * Y - c = 0\n * where c is derived from D and the pool parameters.\n *\n * This is used during swaps to determine the output reserve after an input is added.\n *\n * @param {bigint} newX - The new reserve amount for asset X (will be scaled by RESERVE_PRECISION internally).\n * @param {bigint} aRaw - The raw amplification coefficient for the pool (will be scaled by A_PRECISION).\n * @param {bigint} sumInvariant - The pool's sum invariant (D), already scaled.\n * @returns {bigint} The calculated Y reserve value scaled by RESERVE_PRECISION.\n * @throws {Error} If convergence fails after 255 iterations.\n */\nexport function getNewY(\n newX: bigint,\n aRaw: bigint,\n sumInvariant: bigint,\n): bigint {\n newX = newX * RESERVE_PRECISION;\n const sum = newX;\n let yPrev: bigint;\n let c = sumInvariant;\n const ann = aRaw * A_PRECISION * 2n;\n\n c = (c * sumInvariant) / (newX * 2n);\n c = (c * sumInvariant * A_PRECISION) / 2n;\n c = c / (ann * 2n);\n const b = sum + (sumInvariant * A_PRECISION) / 2n / ann;\n let y = sumInvariant;\n for (let i = 0; i < 255; i++) {\n yPrev = y;\n y = (y * y + c) / (y * 2n + b - sumInvariant);\n if (y > yPrev) {\n if (y - yPrev <= 1n) {\n if (liquidityInvariant(newX, y, aRaw, sumInvariant)) {\n return y;\n } else {\n return y + 1n;\n }\n }\n } else {\n if (yPrev - y <= 1n) {\n if (liquidityInvariant(newX, y, aRaw, sumInvariant)) {\n return y;\n } else {\n return y + 1n;\n }\n }\n }\n }\n throw new Error(\"Failed to converge on y value after 255 iterations.\");\n}\n\n/**\n * Calculates the initial LP token amount for the first liquidity provision to a pool.\n * This is used when bootstrapping a new pool with initial reserves of assets A and B.\n *\n * The LP tokens minted are derived from the sum invariant (D) divided by the reserve precision,\n * effectively representing the pool's total value at inception.\n *\n * @param {bigint} a - The initial amount of token A being deposited.\n * @param {bigint} b - The initial amount of token B being deposited.\n * @param {bigint} laf - The linear amplification factor for the pool.\n * @returns {bigint} The amount of LP tokens to mint for the first liquidity provision.\n */\nexport const getFirstLp = (a: bigint, b: bigint, laf: bigint) =>\n getSumInvariant(laf, a, b) / RESERVE_PRECISION;\n\n/**\n * Calculates the liquidity parameters for adding liquidity to a Stableswaps pool.\n * This function supports mixed deposits where both assets can be deposited in any proportion.\n *\n * The calculation is based on the change in the sum invariant (D) before and after the deposit.\n * LP tokens are minted proportionally to the increase in D relative to the old D value.\n *\n * TODO: Investigate way to optimize actual deposited amounts\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} laf - The linear amplification factor of the pool.\n * @throws {Error} If the pool doesn't have enough liquidity (both reserves are zero).\n * @throws {Error} If both deposit amounts are zero.\n * @returns {Object} An object containing:\n * - nextTotalLp: The total LP tokens for the pool after the deposit.\n * - generatedLp: The amount of LP tokens generated by the deposit.\n * - shareAfterDeposit: The depositor's share of the pool after the deposit (as a Fraction).\n * - aChange: Always 0n for Stableswaps (no refund needed).\n * - bChange: Always 0n for Stableswaps (no refund needed).\n * - actualDepositedA: The actual amount of A deposited (always equal to input a).\n * - actualDepositedB: The actual amount of B deposited (always equal to input b).\n */\nexport const calculateLiquidity = (\n a: bigint,\n b: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n laf: bigint,\n) => {\n if (aReserve === 0n && bReserve === 0n) {\n throw new Error(\"Not enough pool liquidity\");\n }\n\n if (a === 0n && b === 0n) {\n throw new Error(\"Cannot use a deposit asset amount of 0\");\n }\n\n const oldSumInvariant = getSumInvariant(laf, aReserve, bReserve);\n\n const newSumInvariant = getSumInvariant(laf, aReserve + a, bReserve + b);\n\n const newLpTokens =\n ((newSumInvariant - oldSumInvariant) * totalLp) / oldSumInvariant;\n\n const newTotalLpTokens = totalLp + newLpTokens;\n\n return {\n nextTotalLp: newTotalLpTokens,\n generatedLp: newLpTokens,\n shareAfterDeposit: SharedPoolMath.getShare(newLpTokens, newTotalLpTokens),\n aChange: 0n,\n bChange: 0n,\n actualDepositedA: a,\n actualDepositedB: b,\n };\n};\n\n/**\n * Calculates the token amounts that a given LP token amount represents when withdrawing\n * from a Stableswaps pool. The withdrawal is proportional to the LP tokens being redeemed\n * relative to the total LP supply.\n *\n * This uses a simple linear proportion: amount = (lp * reserve) / totalLp for each asset.\n *\n * @param {bigint} lp - The amount of LP tokens being redeemed.\n * @param {bigint} aReserve - The pool's current reserve amount of token A.\n * @param {bigint} bReserve - The pool's current reserve amount of token B.\n * @param {bigint} totalLp - The pool's total minted LP tokens currently in circulation.\n * @returns {SharedPoolMath.TPair} A tuple [a, b] containing the amounts of tokens A and B to withdraw.\n */\nexport const getTokensForLp = (\n lp: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n): SharedPoolMath.TPair => [\n new Fraction(lp * aReserve, totalLp).quotient,\n new Fraction(lp * bReserve, totalLp).quotient,\n];\n\n/**\n * Represents the complete outcome of a swap operation in a Stableswaps pool.\n * Contains all relevant information about the swap including amounts, fees, updated reserves,\n * and price impact.\n */\nexport type TSwapOutcome = {\n /** The amount of input tokens being swapped */\n input: bigint;\n /** The amount of output tokens received (after all fees) */\n output: bigint;\n /** The portion of fees that goes to liquidity providers */\n lpFee: AssetAmount<IAssetAmountMetadata>;\n /** The portion of fees that goes to the protocol */\n protocolFee: AssetAmount<IAssetAmountMetadata>;\n /** The input asset reserve amount after the swap */\n nextInputReserve: bigint;\n /** The output asset reserve amount after the swap (excluding protocol fees) */\n nextOutputReserve: bigint;\n /** The pool's sum invariant (D) after the swap */\n nextSumInvariant: bigint;\n /** The price impact of the swap as a fraction (difference between ideal and actual price) */\n priceImpact: Fraction;\n};\n\n/**\n * Calculates the output amount and all swap parameters for a given input amount in a Stableswaps pool.\n * This function determines how many output tokens will be received for a given input, accounting for\n * the Stableswaps curve, LP fees, and protocol fees.\n *\n * The calculation process:\n * 1. Validates inputs and fees\n * 2. Calculates the current sum invariant (D)\n * 3. Determines the new Y value after adding input to X\n * 4. Calculates raw output and applies fees (LP + protocol)\n * 5. Computes price impact by comparing ideal vs actual execution price\n *\n * @param {bigint} input - The amount of input tokens to swap.\n * @param {bigint} inputReserve - The current reserve amount of the input token in the pool.\n * @param {bigint} outputReserve - The current reserve amount of the output token in the pool.\n * @param {TFractionLike} fee - The liquidity provider fee as a fraction (e.g., 0.003 for 0.3%).\n * @param {TFractionLike} protocolFee - The protocol fee as a fraction.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @param {boolean} [roundOutputUp] - Optional flag to round output up instead of down (default: false).\n * @returns {TSwapOutcome} The complete swap outcome including output, fees, reserves, and price impact.\n * @throws {Error} If input or reserves are not positive.\n * @throws {Error} If fee is not in the range [0, 1).\n * @throws {Error} If protocol fee is not in the range [0, 1).\n * @throws {Error} If combined fee is greater than or equal to 1.\n */\nexport const getSwapOutput = (\n outputMetadata: IAssetAmountMetadata,\n input: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n fee: TFractionLike,\n protocolFee: TFractionLike,\n laf: bigint,\n roundOutputUp?: boolean,\n): TSwapOutcome => {\n if (input <= 0 || inputReserve <= 0 || outputReserve <= 0)\n throw new Error(\"Input and reserves must be positive\");\n\n fee = Fraction.asFraction(fee);\n if (fee.lt(Fraction.ZERO) || fee.gte(Fraction.ONE))\n throw new Error(\"fee must be between 0 and 1\");\n\n protocolFee = Fraction.asFraction(protocolFee);\n if (protocolFee.lt(Fraction.ZERO) || protocolFee.gte(Fraction.ONE))\n throw new Error(\"protocolFee must be between 0 and 1\");\n\n const combinedFee = fee.add(protocolFee);\n if (combinedFee.gte(Fraction.ONE))\n throw new Error(\"Combined fee must be less than 1\");\n const sumInvariant = getSumInvariant(laf, inputReserve, outputReserve);\n const nextInputReserve = inputReserve + input;\n const newY = getNewY(nextInputReserve, laf, sumInvariant);\n\n const deltaYPrec = outputReserve * RESERVE_PRECISION - newY;\n const deltaY = new Fraction(deltaYPrec, RESERVE_PRECISION);\n const totalFee = combinedFee\n .multiply(FEE_PRECISION)\n .multiply(deltaY.quotient)\n .add(Fraction.asFraction(FEE_PRECISION - 1n))\n .divide(FEE_PRECISION).quotient;\n const totalProtocolFee = protocolFee\n .multiply(totalFee)\n .divide(combinedFee).quotient;\n const totalLpFee = totalFee - totalProtocolFee;\n const output = deltaY.subtract(totalFee);\n const safeOutput = roundOutputUp\n ? (output.numerator + output.denominator - 1n) / output.denominator\n : output.quotient;\n const nextOutputReserve = outputReserve - safeOutput - totalProtocolFee;\n\n // PRICEIMPACT: \"priceImpact\" is slightly misleadingly named in the industry as a whole\n // just by it's name, it would imply that it's the percentage difference between\n // the current price and the price after the swap, but it's actually the percentage\n // difference between the real price of your swap, and the price implied by the current\n // reserves; We got this wrong in v1, but this aligns it with the industry standard\n // Source: https://dailydefi.org/articles/price-impact-and-how-to-calculate/\n const idealPrice = getPrice(inputReserve, outputReserve, laf);\n const actualPrice = new Fraction(input, safeOutput);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n return {\n input,\n output: safeOutput,\n lpFee: new AssetAmount(totalLpFee, outputMetadata),\n protocolFee: new AssetAmount(totalProtocolFee, outputMetadata),\n nextInputReserve,\n nextOutputReserve,\n nextSumInvariant: getSumInvariant(laf, nextInputReserve, nextOutputReserve),\n priceImpact,\n };\n};\n\n/**\n * The pool's marginal price as raw units of asset A per raw unit of asset B,\n * |dx/dy| at the current reserves. This is the \"ideal\" price that swap price\n * impact is measured against.\n *\n * Derived from the Stableswaps invariant 4A(x + y) + D = 4AD + D^3 / (4xy):\n * price = (xpA + (dR * aReserve) / bReserve) / (xpA + dR)\n * where xpA = 4 * laf * aReserve and dR = D^3 / (4 * aReserve * bReserve)\n *\n * @param {bigint} aReserve - The current reserve amount of asset A in the pool.\n * @param {bigint} bReserve - The current reserve amount of asset B in the pool.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @returns {Fraction} Raw A per raw B at the current reserves.\n */\nexport function getPrice(\n aReserve: bigint,\n bReserve: bigint,\n laf: bigint,\n): Fraction {\n const sumInvariant =\n getSumInvariant(laf, aReserve, bReserve) / RESERVE_PRECISION;\n // D / n^n with n = 2\n let dR = sumInvariant / 4n;\n dR = (dR * sumInvariant) / aReserve;\n dR = (dR * sumInvariant) / bReserve;\n // 4A is the amplification term of the on-chain invariant, A = laf.\n const xpA = 4n * laf * aReserve;\n const p = new Fraction(xpA + (dR * aReserve) / bReserve, xpA + dR);\n return p;\n}\n\n/**\n * Calculates the required input amount and all swap parameters for a desired output amount in a Stableswaps pool.\n * This is the reverse operation of getSwapOutput - given how much you want to receive, it determines\n * how much you need to provide as input, accounting for fees and the Stableswaps curve.\n *\n * The calculation process:\n * 1. Validates inputs, fees, and output constraints\n * 2. Calculates raw output needed before fees\n * 3. Determines the new X value to achieve the desired Y reduction\n * 4. Calculates required input and separates LP and protocol fees\n * 5. Computes price impact by comparing ideal vs actual execution price\n *\n * @param {bigint} output - The desired amount of output tokens to receive.\n * @param {bigint} inputReserve - The current reserve amount of the input token in the pool.\n * @param {bigint} outputReserve - The current reserve amount of the output token in the pool.\n * @param {TFractionLike} fee - The liquidity provider fee as a fraction (e.g., 0.003 for 0.3%).\n * @param {TFractionLike} protocolFee - The protocol fee as a fraction.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @returns {TSwapOutcome} The complete swap outcome including required input, fees, reserves, and price impact.\n * @throws {Error} If output or reserves are not positive.\n * @throws {Error} If output is greater than or equal to the output reserve.\n * @throws {Error} If fee is not in the range [0, 1).\n * @throws {Error} If protocol fee is not in the range [0, 1).\n * @throws {Error} If combined fee is greater than or equal to 1.\n */\nexport const getSwapInput = (\n outputMetadata: IAssetAmountMetadata,\n output: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n fee: TFractionLike,\n protocolFee: TFractionLike,\n laf: bigint,\n): TSwapOutcome => {\n if (output <= 0 || inputReserve <= 0 || outputReserve <= 0)\n throw new Error(\"Output and reserves must be positive\");\n\n if (output >= outputReserve)\n throw new Error(\"Output must be less than output reserve\");\n\n fee = Fraction.asFraction(fee);\n if (fee.lt(Fraction.ZERO) || fee.gte(Fraction.ONE))\n throw new Error(\"fee must be [0,1)\");\n\n protocolFee = Fraction.asFraction(protocolFee);\n if (protocolFee.lt(Fraction.ZERO) || protocolFee.gte(Fraction.ONE))\n throw new Error(\"protocolFee must be between 0 and 1\");\n\n const combinedFee = fee.add(protocolFee);\n if (combinedFee.gte(Fraction.ONE))\n throw new Error(\"Combined fee must be less than 1\");\n\n // output = rawOutput * (1-fee)\n // rawOutput = output / (1-fee)\n const rawOutputF = Fraction.asFraction(output).divide(\n Fraction.ONE.sub(combinedFee),\n );\n const rawOutput =\n (rawOutputF.numerator + rawOutputF.denominator - 1n) /\n rawOutputF.denominator;\n const sumInvariant = getSumInvariant(laf, inputReserve, outputReserve);\n const newX = getNewY(outputReserve - rawOutput, laf, sumInvariant);\n const input =\n (newX - inputReserve * RESERVE_PRECISION + RESERVE_PRECISION - 1n) /\n RESERVE_PRECISION;\n\n const totalFee =\n (combinedFee.multiply(FEE_PRECISION).quotient * rawOutput +\n FEE_PRECISION -\n 1n) /\n FEE_PRECISION;\n const totalProtocolFee = protocolFee\n .multiply(totalFee)\n .divide(combinedFee).quotient;\n\n const totalLpFee = totalFee - totalProtocolFee;\n\n const nextInputReserve = inputReserve + input;\n const nextOutputReserve = outputReserve - output - totalProtocolFee;\n\n // See PRICEIMPACT\n const idealPrice = getPrice(inputReserve, outputReserve, laf);\n const actualPrice = new Fraction(input, output);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n\n const nextSumInvariant = getSumInvariant(\n laf,\n nextInputReserve,\n nextOutputReserve,\n );\n\n return {\n input,\n output,\n lpFee: new AssetAmount(totalLpFee, outputMetadata),\n protocolFee: new AssetAmount(totalProtocolFee, outputMetadata),\n nextInputReserve,\n nextOutputReserve,\n priceImpact,\n nextSumInvariant,\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,kBAAkBA,CAChCC,MAAc,EACdC,MAAc,EACdC,mBAA2B,EAC3BC,eAAuB,EACvB;EACA;EACA;EACA;EACA,IAAMC,MAAM,GAAG,EAAE,GAAGF,mBAAmB;EACvC,IAAMG,QAAQ,GAAG,EAAE,GAAGL,MAAM,GAAGC,MAAM;EACrC,IAAMK,UAAU,GAAGH,eAAe,GAAG,EAAE;EACvC,IAAMI,OAAO,GAAGJ,eAAe,GAAGA,eAAe,GAAGA,eAAe;EACnE,IAAMK,gBAAgB,GAAGF,UAAU,GAAGA,UAAU,GAAGA,UAAU;EAC7D,IAAMG,QAAQ,GAAGT,MAAM,GAAGC,MAAM;EAChC,IAAMS,aAAa,GAAGN,MAAM,GAAGC,QAAQ;EACvC,IAAMM,sBAAsB,GAAGD,aAAa,GAAGD,QAAQ;EACvD,IAAMG,EAAE,GACNF,aAAa,GAAGP,eAAe,GAC/BI,OAAO,IACNI,sBAAsB,GAAGN,QAAQ,GAAGF,eAAe,CAAC;EACvD,IAAMU,EAAE,GACNH,aAAa,GAAGJ,UAAU,GAC1BE,gBAAgB,IACfG,sBAAsB,GAAGN,QAAQ,GAAGC,UAAU,CAAC;EAClD,OAAOM,EAAE,IAAI,EAAE,IAAIC,EAAE,GAAG,EAAE;AAC5B;;AAEA;AACA;AACA;AACA;AACO,IAAMC,WAAmB,GAAAC,OAAA,CAAAD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gB,EAAhBA,gBAAgB;IAChBc,iBAAiB,EAAjBA,iBAAiB;IACjBI,WAAW,EAAXA,WAAW;IACXG,gBAAgB,EAAhBA;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -309,27 +309,27 @@ export const getSwapOutput = (outputMetadata, input, inputReserve, outputReserve
|
|
|
309
309
|
};
|
|
310
310
|
|
|
311
311
|
/**
|
|
312
|
-
*
|
|
313
|
-
*
|
|
312
|
+
* The pool's marginal price as raw units of asset A per raw unit of asset B,
|
|
313
|
+
* |dx/dy| at the current reserves. This is the "ideal" price that swap price
|
|
314
|
+
* impact is measured against.
|
|
314
315
|
*
|
|
315
|
-
*
|
|
316
|
+
* Derived from the Stableswaps invariant 4A(x + y) + D = 4AD + D^3 / (4xy):
|
|
316
317
|
* price = (xpA + (dR * aReserve) / bReserve) / (xpA + dR)
|
|
317
|
-
* where xpA =
|
|
318
|
+
* where xpA = 4 * laf * aReserve and dR = D^3 / (4 * aReserve * bReserve)
|
|
318
319
|
*
|
|
319
320
|
* @param {bigint} aReserve - The current reserve amount of asset A in the pool.
|
|
320
321
|
* @param {bigint} bReserve - The current reserve amount of asset B in the pool.
|
|
321
322
|
* @param {bigint} laf - The linear amplification factor of the pool.
|
|
322
|
-
* @returns {Fraction}
|
|
323
|
+
* @returns {Fraction} Raw A per raw B at the current reserves.
|
|
323
324
|
*/
|
|
324
325
|
export function getPrice(aReserve, bReserve, laf) {
|
|
325
|
-
// dx_0 / dx_1 only, however can have any number of coins in pool
|
|
326
|
-
const ann = laf * 2n * A_PRECISION;
|
|
327
326
|
const sumInvariant = getSumInvariant(laf, aReserve, bReserve) / RESERVE_PRECISION;
|
|
328
327
|
// D / n^n with n = 2
|
|
329
328
|
let dR = sumInvariant / 4n;
|
|
330
329
|
dR = dR * sumInvariant / aReserve;
|
|
331
330
|
dR = dR * sumInvariant / bReserve;
|
|
332
|
-
|
|
331
|
+
// 4A is the amplification term of the on-chain invariant, A = laf.
|
|
332
|
+
const xpA = 4n * laf * aReserve;
|
|
333
333
|
const p = new Fraction(xpA + dR * aReserve / bReserve, xpA + dR);
|
|
334
334
|
return p;
|
|
335
335
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StableSwapsPool.js","names":["AssetAmount","SharedPoolMath","Fraction","liquidityInvariant","assetA","assetB","linearAmplification","newSumInvariant","four_a","four_x_y","d_plus_one","d_cubed","d_plus_one_cubed","x_plus_y","sixteen_a_x_y","sixteen_a_x_y_x_plus_y","f1","f2","A_PRECISION","RESERVE_PRECISION","FEE_PRECISION","getSumInvariant","a","x","y","Error","sum","d","ann","i","d_p","d_prev","getNewY","newX","aRaw","sumInvariant","yPrev","c","b","getFirstLp","laf","calculateLiquidity","aReserve","bReserve","totalLp","oldSumInvariant","newLpTokens","newTotalLpTokens","nextTotalLp","generatedLp","shareAfterDeposit","getShare","aChange","bChange","actualDepositedA","actualDepositedB","getTokensForLp","lp","quotient","getSwapOutput","outputMetadata","input","inputReserve","outputReserve","fee","protocolFee","roundOutputUp","asFraction","lt","ZERO","gte","ONE","combinedFee","add","nextInputReserve","newY","deltaYPrec","deltaY","totalFee","multiply","divide","totalProtocolFee","totalLpFee","output","subtract","safeOutput","numerator","denominator","nextOutputReserve","idealPrice","getPrice","actualPrice","priceImpact","lpFee","nextSumInvariant","dR","xpA","p","getSwapInput","rawOutputF","sub","rawOutput"],"sources":["../../../src/PoolMath/StableSwapsPool.ts"],"sourcesContent":["import { AssetAmount, IAssetAmountMetadata } from \"@sundaeswap/asset\";\nimport { SharedPoolMath } from \"./index.js\";\nimport { Fraction, type TFractionLike } from \"@sundaeswap/fraction\";\n\n/**\n * Validates that a given sum invariant (D) satisfies the liquidity invariant equation\n * for the Stableswaps curve. This function checks if D is within the valid range by\n * evaluating the invariant function at D and D+1.\n *\n * The liquidity invariant ensures that the curve equation is satisfied:\n * 4A * 4xy * D + D^3 - (4xy * 4A * (x + y) + 4xy * D) should be <= 0 at D and > 0 at D+1\n *\n * @param {bigint} assetA - The reserve amount of asset A (already scaled by RESERVE_PRECISION).\n * @param {bigint} assetB - The reserve amount of asset B (already scaled by RESERVE_PRECISION).\n * @param {bigint} linearAmplification - The amplification coefficient for the pool.\n * @param {bigint} newSumInvariant - The proposed sum invariant (D) to validate.\n * @returns {boolean} True if the sum invariant satisfies the liquidity invariant equation, false otherwise.\n */\nexport function liquidityInvariant(\n assetA: bigint,\n assetB: bigint,\n linearAmplification: bigint,\n newSumInvariant: bigint,\n) {\n // 4 * A * 4 * (x*y) * D + D^3 - (4(x*y) * (4A(x + y) + D))\n // 4A * 4xy * D + D^3 - (4xy * 4a * (x + y) + 4xy * D)\n // 16Axy * D + D^3 - (16Axy * (x + y) + 4xy * D)\n const four_a = 4n * linearAmplification;\n const four_x_y = 4n * assetA * assetB;\n const d_plus_one = newSumInvariant + 1n;\n const d_cubed = newSumInvariant * newSumInvariant * newSumInvariant;\n const d_plus_one_cubed = d_plus_one * d_plus_one * d_plus_one;\n const x_plus_y = assetA + assetB;\n const sixteen_a_x_y = four_a * four_x_y;\n const sixteen_a_x_y_x_plus_y = sixteen_a_x_y * x_plus_y;\n const f1 =\n sixteen_a_x_y * newSumInvariant +\n d_cubed -\n (sixteen_a_x_y_x_plus_y + four_x_y * newSumInvariant);\n const f2 =\n sixteen_a_x_y * d_plus_one +\n d_plus_one_cubed -\n (sixteen_a_x_y_x_plus_y + four_x_y * d_plus_one);\n return f1 <= 0n && f2 > 0n;\n}\n\n/**\n * Precision factor for the amplification coefficient calculations.\n * Used to scale the amplification factor for more precise arithmetic operations.\n */\nexport const A_PRECISION: bigint = 200n;\n\n/**\n * Precision factor for reserve calculations in the Stableswaps curve.\n * Reserves are multiplied by this value to maintain precision during calculations.\n * This allows for accurate fractional calculations with integer arithmetic.\n */\nexport const RESERVE_PRECISION: bigint = 1_000_000_000_000n;\n\n/**\n * Precision factor for fee calculations, representing basis points.\n * A value of 10,000 means fees are calculated with 0.01% precision (1 basis point).\n */\nexport const FEE_PRECISION: bigint = 10_000n;\n\n/**\n * Calculates the sum invariant (D) for a Stableswaps pool using Newton's method.\n * The sum invariant represents the total value in the pool and is used to determine\n * the fair exchange rate between assets.\n *\n * This function iteratively solves for D in the Stableswaps invariant equation:\n * Ann * sum + D_p * 2 = Ann * D + D_p * 3\n * where D_p = D^3 / (4 * x * y) and Ann = A * n^n (with n=2)\n *\n * The iteration continues until convergence (difference <= 1) or fails after 255 iterations.\n *\n * @param {bigint} a - The amplification coefficient for the pool (will be scaled by A_PRECISION).\n * @param {bigint} x - The reserve amount of the first asset (will be scaled by RESERVE_PRECISION).\n * @param {bigint} y - The reserve amount of the second asset (will be scaled by RESERVE_PRECISION).\n * @returns {bigint} The calculated sum invariant (D) scaled by RESERVE_PRECISION.\n * @throws {Error} If the amplification coefficient is not positive.\n * @throws {Error} If convergence fails after 255 iterations.\n */\nexport function getSumInvariant(a: bigint, x: bigint, y: bigint): bigint {\n if (a <= 0n) {\n throw new Error(\"Amplification coefficient must be positive.\");\n }\n x = x * RESERVE_PRECISION;\n y = y * RESERVE_PRECISION;\n a = a * A_PRECISION;\n const sum: bigint = x + y;\n if (sum === 0n) {\n return 0n;\n }\n\n let d = sum;\n const ann = a * 2n;\n for (let i = 0; i < 255; i++) {\n const d_p = (d * d * d) / (4n * x * y);\n const d_prev = d;\n\n d =\n (((ann * sum) / 100n + d_p * 2n) * d) /\n (((ann - 100n) * d) / 100n + 3n * d_p);\n\n if (d > d_prev) {\n if (d - d_prev <= 1) {\n if (liquidityInvariant(x, y, a / A_PRECISION, d)) {\n return d;\n } else {\n return d - 1n;\n }\n }\n } else {\n if (d_prev - d <= 1) {\n if (liquidityInvariant(x, y, a / A_PRECISION, d)) {\n return d;\n } else {\n return d - 1n;\n }\n }\n }\n }\n throw new Error(\"Failed to converge on D value after 255 iterations.\");\n}\n\n/**\n * Calculates the new Y reserve value given a new X reserve value and the sum invariant.\n * This function uses Newton's method to iteratively solve for Y in the Stableswaps equation\n * while maintaining the pool's invariant (D).\n *\n * The function solves: Y^2 + (sum + (D * A_PRECISION) / (2 * Ann) - D) * Y - c = 0\n * where c is derived from D and the pool parameters.\n *\n * This is used during swaps to determine the output reserve after an input is added.\n *\n * @param {bigint} newX - The new reserve amount for asset X (will be scaled by RESERVE_PRECISION internally).\n * @param {bigint} aRaw - The raw amplification coefficient for the pool (will be scaled by A_PRECISION).\n * @param {bigint} sumInvariant - The pool's sum invariant (D), already scaled.\n * @returns {bigint} The calculated Y reserve value scaled by RESERVE_PRECISION.\n * @throws {Error} If convergence fails after 255 iterations.\n */\nexport function getNewY(\n newX: bigint,\n aRaw: bigint,\n sumInvariant: bigint,\n): bigint {\n newX = newX * RESERVE_PRECISION;\n const sum = newX;\n let yPrev: bigint;\n let c = sumInvariant;\n const ann = aRaw * A_PRECISION * 2n;\n\n c = (c * sumInvariant) / (newX * 2n);\n c = (c * sumInvariant * A_PRECISION) / 2n;\n c = c / (ann * 2n);\n const b = sum + (sumInvariant * A_PRECISION) / 2n / ann;\n let y = sumInvariant;\n for (let i = 0; i < 255; i++) {\n yPrev = y;\n y = (y * y + c) / (y * 2n + b - sumInvariant);\n if (y > yPrev) {\n if (y - yPrev <= 1n) {\n if (liquidityInvariant(newX, y, aRaw, sumInvariant)) {\n return y;\n } else {\n return y + 1n;\n }\n }\n } else {\n if (yPrev - y <= 1n) {\n if (liquidityInvariant(newX, y, aRaw, sumInvariant)) {\n return y;\n } else {\n return y + 1n;\n }\n }\n }\n }\n throw new Error(\"Failed to converge on y value after 255 iterations.\");\n}\n\n/**\n * Calculates the initial LP token amount for the first liquidity provision to a pool.\n * This is used when bootstrapping a new pool with initial reserves of assets A and B.\n *\n * The LP tokens minted are derived from the sum invariant (D) divided by the reserve precision,\n * effectively representing the pool's total value at inception.\n *\n * @param {bigint} a - The initial amount of token A being deposited.\n * @param {bigint} b - The initial amount of token B being deposited.\n * @param {bigint} laf - The linear amplification factor for the pool.\n * @returns {bigint} The amount of LP tokens to mint for the first liquidity provision.\n */\nexport const getFirstLp = (a: bigint, b: bigint, laf: bigint) =>\n getSumInvariant(laf, a, b) / RESERVE_PRECISION;\n\n/**\n * Calculates the liquidity parameters for adding liquidity to a Stableswaps pool.\n * This function supports mixed deposits where both assets can be deposited in any proportion.\n *\n * The calculation is based on the change in the sum invariant (D) before and after the deposit.\n * LP tokens are minted proportionally to the increase in D relative to the old D value.\n *\n * TODO: Investigate way to optimize actual deposited amounts\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} laf - The linear amplification factor of the pool.\n * @throws {Error} If the pool doesn't have enough liquidity (both reserves are zero).\n * @throws {Error} If both deposit amounts are zero.\n * @returns {Object} An object containing:\n * - nextTotalLp: The total LP tokens for the pool after the deposit.\n * - generatedLp: The amount of LP tokens generated by the deposit.\n * - shareAfterDeposit: The depositor's share of the pool after the deposit (as a Fraction).\n * - aChange: Always 0n for Stableswaps (no refund needed).\n * - bChange: Always 0n for Stableswaps (no refund needed).\n * - actualDepositedA: The actual amount of A deposited (always equal to input a).\n * - actualDepositedB: The actual amount of B deposited (always equal to input b).\n */\nexport const calculateLiquidity = (\n a: bigint,\n b: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n laf: bigint,\n) => {\n if (aReserve === 0n && bReserve === 0n) {\n throw new Error(\"Not enough pool liquidity\");\n }\n\n if (a === 0n && b === 0n) {\n throw new Error(\"Cannot use a deposit asset amount of 0\");\n }\n\n const oldSumInvariant = getSumInvariant(laf, aReserve, bReserve);\n\n const newSumInvariant = getSumInvariant(laf, aReserve + a, bReserve + b);\n\n const newLpTokens =\n ((newSumInvariant - oldSumInvariant) * totalLp) / oldSumInvariant;\n\n const newTotalLpTokens = totalLp + newLpTokens;\n\n return {\n nextTotalLp: newTotalLpTokens,\n generatedLp: newLpTokens,\n shareAfterDeposit: SharedPoolMath.getShare(newLpTokens, newTotalLpTokens),\n aChange: 0n,\n bChange: 0n,\n actualDepositedA: a,\n actualDepositedB: b,\n };\n};\n\n/**\n * Calculates the token amounts that a given LP token amount represents when withdrawing\n * from a Stableswaps pool. The withdrawal is proportional to the LP tokens being redeemed\n * relative to the total LP supply.\n *\n * This uses a simple linear proportion: amount = (lp * reserve) / totalLp for each asset.\n *\n * @param {bigint} lp - The amount of LP tokens being redeemed.\n * @param {bigint} aReserve - The pool's current reserve amount of token A.\n * @param {bigint} bReserve - The pool's current reserve amount of token B.\n * @param {bigint} totalLp - The pool's total minted LP tokens currently in circulation.\n * @returns {SharedPoolMath.TPair} A tuple [a, b] containing the amounts of tokens A and B to withdraw.\n */\nexport const getTokensForLp = (\n lp: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n): SharedPoolMath.TPair => [\n new Fraction(lp * aReserve, totalLp).quotient,\n new Fraction(lp * bReserve, totalLp).quotient,\n];\n\n/**\n * Represents the complete outcome of a swap operation in a Stableswaps pool.\n * Contains all relevant information about the swap including amounts, fees, updated reserves,\n * and price impact.\n */\nexport type TSwapOutcome = {\n /** The amount of input tokens being swapped */\n input: bigint;\n /** The amount of output tokens received (after all fees) */\n output: bigint;\n /** The portion of fees that goes to liquidity providers */\n lpFee: AssetAmount<IAssetAmountMetadata>;\n /** The portion of fees that goes to the protocol */\n protocolFee: AssetAmount<IAssetAmountMetadata>;\n /** The input asset reserve amount after the swap */\n nextInputReserve: bigint;\n /** The output asset reserve amount after the swap (excluding protocol fees) */\n nextOutputReserve: bigint;\n /** The pool's sum invariant (D) after the swap */\n nextSumInvariant: bigint;\n /** The price impact of the swap as a fraction (difference between ideal and actual price) */\n priceImpact: Fraction;\n};\n\n/**\n * Calculates the output amount and all swap parameters for a given input amount in a Stableswaps pool.\n * This function determines how many output tokens will be received for a given input, accounting for\n * the Stableswaps curve, LP fees, and protocol fees.\n *\n * The calculation process:\n * 1. Validates inputs and fees\n * 2. Calculates the current sum invariant (D)\n * 3. Determines the new Y value after adding input to X\n * 4. Calculates raw output and applies fees (LP + protocol)\n * 5. Computes price impact by comparing ideal vs actual execution price\n *\n * @param {bigint} input - The amount of input tokens to swap.\n * @param {bigint} inputReserve - The current reserve amount of the input token in the pool.\n * @param {bigint} outputReserve - The current reserve amount of the output token in the pool.\n * @param {TFractionLike} fee - The liquidity provider fee as a fraction (e.g., 0.003 for 0.3%).\n * @param {TFractionLike} protocolFee - The protocol fee as a fraction.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @param {boolean} [roundOutputUp] - Optional flag to round output up instead of down (default: false).\n * @returns {TSwapOutcome} The complete swap outcome including output, fees, reserves, and price impact.\n * @throws {Error} If input or reserves are not positive.\n * @throws {Error} If fee is not in the range [0, 1).\n * @throws {Error} If protocol fee is not in the range [0, 1).\n * @throws {Error} If combined fee is greater than or equal to 1.\n */\nexport const getSwapOutput = (\n outputMetadata: IAssetAmountMetadata,\n input: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n fee: TFractionLike,\n protocolFee: TFractionLike,\n laf: bigint,\n roundOutputUp?: boolean,\n): TSwapOutcome => {\n if (input <= 0 || inputReserve <= 0 || outputReserve <= 0)\n throw new Error(\"Input and reserves must be positive\");\n\n fee = Fraction.asFraction(fee);\n if (fee.lt(Fraction.ZERO) || fee.gte(Fraction.ONE))\n throw new Error(\"fee must be between 0 and 1\");\n\n protocolFee = Fraction.asFraction(protocolFee);\n if (protocolFee.lt(Fraction.ZERO) || protocolFee.gte(Fraction.ONE))\n throw new Error(\"protocolFee must be between 0 and 1\");\n\n const combinedFee = fee.add(protocolFee);\n if (combinedFee.gte(Fraction.ONE))\n throw new Error(\"Combined fee must be less than 1\");\n const sumInvariant = getSumInvariant(laf, inputReserve, outputReserve);\n const nextInputReserve = inputReserve + input;\n const newY = getNewY(nextInputReserve, laf, sumInvariant);\n\n const deltaYPrec = outputReserve * RESERVE_PRECISION - newY;\n const deltaY = new Fraction(deltaYPrec, RESERVE_PRECISION);\n const totalFee = combinedFee\n .multiply(FEE_PRECISION)\n .multiply(deltaY.quotient)\n .add(Fraction.asFraction(FEE_PRECISION - 1n))\n .divide(FEE_PRECISION).quotient;\n const totalProtocolFee = protocolFee\n .multiply(totalFee)\n .divide(combinedFee).quotient;\n const totalLpFee = totalFee - totalProtocolFee;\n const output = deltaY.subtract(totalFee);\n const safeOutput = roundOutputUp\n ? (output.numerator + output.denominator - 1n) / output.denominator\n : output.quotient;\n const nextOutputReserve = outputReserve - safeOutput - totalProtocolFee;\n\n // PRICEIMPACT: \"priceImpact\" is slightly misleadingly named in the industry as a whole\n // just by it's name, it would imply that it's the percentage difference between\n // the current price and the price after the swap, but it's actually the percentage\n // difference between the real price of your swap, and the price implied by the current\n // reserves; We got this wrong in v1, but this aligns it with the industry standard\n // Source: https://dailydefi.org/articles/price-impact-and-how-to-calculate/\n const idealPrice = getPrice(inputReserve, outputReserve, laf);\n const actualPrice = new Fraction(input, safeOutput);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n return {\n input,\n output: safeOutput,\n lpFee: new AssetAmount(totalLpFee, outputMetadata),\n protocolFee: new AssetAmount(totalProtocolFee, outputMetadata),\n nextInputReserve,\n nextOutputReserve,\n nextSumInvariant: getSumInvariant(laf, nextInputReserve, nextOutputReserve),\n priceImpact,\n };\n};\n\n/**\n * Calculates the current price (exchange rate) of asset A in terms of asset B for a Stableswaps pool.\n * The price is derived from the Stableswaps curve equation and takes into account the amplification factor.\n *\n * The calculation uses the formula:\n * price = (xpA + (dR * aReserve) / bReserve) / (xpA + dR)\n * where xpA = (Ann * aReserve) / A_PRECISION and dR is derived from the sum invariant\n *\n * @param {bigint} aReserve - The current reserve amount of asset A in the pool.\n * @param {bigint} bReserve - The current reserve amount of asset B in the pool.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @returns {Fraction} The price of asset A in terms of asset B as a Fraction.\n */\nexport function getPrice(\n aReserve: bigint,\n bReserve: bigint,\n laf: bigint,\n): Fraction {\n // dx_0 / dx_1 only, however can have any number of coins in pool\n const ann = laf * 2n * A_PRECISION;\n const sumInvariant =\n getSumInvariant(laf, aReserve, bReserve) / RESERVE_PRECISION;\n // D / n^n with n = 2\n let dR = sumInvariant / 4n;\n dR = (dR * sumInvariant) / aReserve;\n dR = (dR * sumInvariant) / bReserve;\n const xpA = (ann * aReserve) / A_PRECISION;\n const p = new Fraction(xpA + (dR * aReserve) / bReserve, xpA + dR);\n return p;\n}\n\n/**\n * Calculates the required input amount and all swap parameters for a desired output amount in a Stableswaps pool.\n * This is the reverse operation of getSwapOutput - given how much you want to receive, it determines\n * how much you need to provide as input, accounting for fees and the Stableswaps curve.\n *\n * The calculation process:\n * 1. Validates inputs, fees, and output constraints\n * 2. Calculates raw output needed before fees\n * 3. Determines the new X value to achieve the desired Y reduction\n * 4. Calculates required input and separates LP and protocol fees\n * 5. Computes price impact by comparing ideal vs actual execution price\n *\n * @param {bigint} output - The desired amount of output tokens to receive.\n * @param {bigint} inputReserve - The current reserve amount of the input token in the pool.\n * @param {bigint} outputReserve - The current reserve amount of the output token in the pool.\n * @param {TFractionLike} fee - The liquidity provider fee as a fraction (e.g., 0.003 for 0.3%).\n * @param {TFractionLike} protocolFee - The protocol fee as a fraction.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @returns {TSwapOutcome} The complete swap outcome including required input, fees, reserves, and price impact.\n * @throws {Error} If output or reserves are not positive.\n * @throws {Error} If output is greater than or equal to the output reserve.\n * @throws {Error} If fee is not in the range [0, 1).\n * @throws {Error} If protocol fee is not in the range [0, 1).\n * @throws {Error} If combined fee is greater than or equal to 1.\n */\nexport const getSwapInput = (\n outputMetadata: IAssetAmountMetadata,\n output: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n fee: TFractionLike,\n protocolFee: TFractionLike,\n laf: bigint,\n): TSwapOutcome => {\n if (output <= 0 || inputReserve <= 0 || outputReserve <= 0)\n throw new Error(\"Output and reserves must be positive\");\n\n if (output >= outputReserve)\n throw new Error(\"Output must be less than output reserve\");\n\n fee = Fraction.asFraction(fee);\n if (fee.lt(Fraction.ZERO) || fee.gte(Fraction.ONE))\n throw new Error(\"fee must be [0,1)\");\n\n protocolFee = Fraction.asFraction(protocolFee);\n if (protocolFee.lt(Fraction.ZERO) || protocolFee.gte(Fraction.ONE))\n throw new Error(\"protocolFee must be between 0 and 1\");\n\n const combinedFee = fee.add(protocolFee);\n if (combinedFee.gte(Fraction.ONE))\n throw new Error(\"Combined fee must be less than 1\");\n\n // output = rawOutput * (1-fee)\n // rawOutput = output / (1-fee)\n const rawOutputF = Fraction.asFraction(output).divide(\n Fraction.ONE.sub(combinedFee),\n );\n const rawOutput =\n (rawOutputF.numerator + rawOutputF.denominator - 1n) /\n rawOutputF.denominator;\n const sumInvariant = getSumInvariant(laf, inputReserve, outputReserve);\n const newX = getNewY(outputReserve - rawOutput, laf, sumInvariant);\n const input =\n (newX - inputReserve * RESERVE_PRECISION + RESERVE_PRECISION - 1n) /\n RESERVE_PRECISION;\n\n const totalFee =\n (combinedFee.multiply(FEE_PRECISION).quotient * rawOutput +\n FEE_PRECISION -\n 1n) /\n FEE_PRECISION;\n const totalProtocolFee = protocolFee\n .multiply(totalFee)\n .divide(combinedFee).quotient;\n\n const totalLpFee = totalFee - totalProtocolFee;\n\n const nextInputReserve = inputReserve + input;\n const nextOutputReserve = outputReserve - output - totalProtocolFee;\n\n // See PRICEIMPACT\n const idealPrice = getPrice(inputReserve, outputReserve, laf);\n const actualPrice = new Fraction(input, output);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n\n const nextSumInvariant = getSumInvariant(\n laf,\n nextInputReserve,\n nextOutputReserve,\n );\n\n return {\n input,\n output,\n lpFee: new AssetAmount(totalLpFee, outputMetadata),\n protocolFee: new AssetAmount(totalProtocolFee, outputMetadata),\n nextInputReserve,\n nextOutputReserve,\n priceImpact,\n nextSumInvariant,\n };\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAA8B,mBA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ACR,WAAW,CAAC,CAACd,QAAQ;EAE/B,MAAMwB,UAAU,GAAGJ,QAAQ,GAAGG,gBAAgB;EAE9C,MAAMP,gBAAgB,GAAGZ,YAAY,GAAGD,KAAK;EAC7C,MAAM2B,iBAAiB,GAAGzB,aAAa,GAAGoB,MAAM,GAAGF,gBAAgB;;EAEnE;EACA,MAAMQ,UAAU,GAAGC,QAAQ,CAAC5B,YAAY,EAAEC,aAAa,EAAEvB,GAAG,CAAC;EAC7D,MAAMmD,WAAW,GAAG,IAAIzF,QAAQ,CAAC2D,KAAK,EAAEsB,MAAM,CAAC;EAC/C,MAAMS,WAAW,GAAG1F,QAAQ,CAACqE,GAAG,CAACa,QAAQ,CAACK,UAAU,CAACT,MAAM,CAACW,WAAW,CAAC,CAAC;EAEzE,MAAMG,gBAAgB,GAAGzE,eAAe,CACtCmB,GAAG,EACHkC,gBAAgB,EAChBc,iBACF,CAAC;EAED,OAAO;IACL3B,KAAK;IACLsB,MAAM;IACNU,KAAK,EAAE,IAAI7F,WAAW,CAACkF,UAAU,EAAEtB,cAAc,CAAC;IAClDK,WAAW,EAAE,IAAIjE,WAAW,CAACiF,gBAAgB,EAAErB,cAAc,CAAC;IAC9Dc,gBAAgB;IAChBc,iBAAiB;IACjBI,WAAW;IACXE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"StableSwapsPool.js","names":["AssetAmount","SharedPoolMath","Fraction","liquidityInvariant","assetA","assetB","linearAmplification","newSumInvariant","four_a","four_x_y","d_plus_one","d_cubed","d_plus_one_cubed","x_plus_y","sixteen_a_x_y","sixteen_a_x_y_x_plus_y","f1","f2","A_PRECISION","RESERVE_PRECISION","FEE_PRECISION","getSumInvariant","a","x","y","Error","sum","d","ann","i","d_p","d_prev","getNewY","newX","aRaw","sumInvariant","yPrev","c","b","getFirstLp","laf","calculateLiquidity","aReserve","bReserve","totalLp","oldSumInvariant","newLpTokens","newTotalLpTokens","nextTotalLp","generatedLp","shareAfterDeposit","getShare","aChange","bChange","actualDepositedA","actualDepositedB","getTokensForLp","lp","quotient","getSwapOutput","outputMetadata","input","inputReserve","outputReserve","fee","protocolFee","roundOutputUp","asFraction","lt","ZERO","gte","ONE","combinedFee","add","nextInputReserve","newY","deltaYPrec","deltaY","totalFee","multiply","divide","totalProtocolFee","totalLpFee","output","subtract","safeOutput","numerator","denominator","nextOutputReserve","idealPrice","getPrice","actualPrice","priceImpact","lpFee","nextSumInvariant","dR","xpA","p","getSwapInput","rawOutputF","sub","rawOutput"],"sources":["../../../src/PoolMath/StableSwapsPool.ts"],"sourcesContent":["import { AssetAmount, IAssetAmountMetadata } from \"@sundaeswap/asset\";\nimport { SharedPoolMath } from \"./index.js\";\nimport { Fraction, type TFractionLike } from \"@sundaeswap/fraction\";\n\n/**\n * Validates that a given sum invariant (D) satisfies the liquidity invariant equation\n * for the Stableswaps curve. This function checks if D is within the valid range by\n * evaluating the invariant function at D and D+1.\n *\n * The liquidity invariant ensures that the curve equation is satisfied:\n * 4A * 4xy * D + D^3 - (4xy * 4A * (x + y) + 4xy * D) should be <= 0 at D and > 0 at D+1\n *\n * @param {bigint} assetA - The reserve amount of asset A (already scaled by RESERVE_PRECISION).\n * @param {bigint} assetB - The reserve amount of asset B (already scaled by RESERVE_PRECISION).\n * @param {bigint} linearAmplification - The amplification coefficient for the pool.\n * @param {bigint} newSumInvariant - The proposed sum invariant (D) to validate.\n * @returns {boolean} True if the sum invariant satisfies the liquidity invariant equation, false otherwise.\n */\nexport function liquidityInvariant(\n assetA: bigint,\n assetB: bigint,\n linearAmplification: bigint,\n newSumInvariant: bigint,\n) {\n // 4 * A * 4 * (x*y) * D + D^3 - (4(x*y) * (4A(x + y) + D))\n // 4A * 4xy * D + D^3 - (4xy * 4a * (x + y) + 4xy * D)\n // 16Axy * D + D^3 - (16Axy * (x + y) + 4xy * D)\n const four_a = 4n * linearAmplification;\n const four_x_y = 4n * assetA * assetB;\n const d_plus_one = newSumInvariant + 1n;\n const d_cubed = newSumInvariant * newSumInvariant * newSumInvariant;\n const d_plus_one_cubed = d_plus_one * d_plus_one * d_plus_one;\n const x_plus_y = assetA + assetB;\n const sixteen_a_x_y = four_a * four_x_y;\n const sixteen_a_x_y_x_plus_y = sixteen_a_x_y * x_plus_y;\n const f1 =\n sixteen_a_x_y * newSumInvariant +\n d_cubed -\n (sixteen_a_x_y_x_plus_y + four_x_y * newSumInvariant);\n const f2 =\n sixteen_a_x_y * d_plus_one +\n d_plus_one_cubed -\n (sixteen_a_x_y_x_plus_y + four_x_y * d_plus_one);\n return f1 <= 0n && f2 > 0n;\n}\n\n/**\n * Precision factor for the amplification coefficient calculations.\n * Used to scale the amplification factor for more precise arithmetic operations.\n */\nexport const A_PRECISION: bigint = 200n;\n\n/**\n * Precision factor for reserve calculations in the Stableswaps curve.\n * Reserves are multiplied by this value to maintain precision during calculations.\n * This allows for accurate fractional calculations with integer arithmetic.\n */\nexport const RESERVE_PRECISION: bigint = 1_000_000_000_000n;\n\n/**\n * Precision factor for fee calculations, representing basis points.\n * A value of 10,000 means fees are calculated with 0.01% precision (1 basis point).\n */\nexport const FEE_PRECISION: bigint = 10_000n;\n\n/**\n * Calculates the sum invariant (D) for a Stableswaps pool using Newton's method.\n * The sum invariant represents the total value in the pool and is used to determine\n * the fair exchange rate between assets.\n *\n * This function iteratively solves for D in the Stableswaps invariant equation:\n * Ann * sum + D_p * 2 = Ann * D + D_p * 3\n * where D_p = D^3 / (4 * x * y) and Ann = A * n^n (with n=2)\n *\n * The iteration continues until convergence (difference <= 1) or fails after 255 iterations.\n *\n * @param {bigint} a - The amplification coefficient for the pool (will be scaled by A_PRECISION).\n * @param {bigint} x - The reserve amount of the first asset (will be scaled by RESERVE_PRECISION).\n * @param {bigint} y - The reserve amount of the second asset (will be scaled by RESERVE_PRECISION).\n * @returns {bigint} The calculated sum invariant (D) scaled by RESERVE_PRECISION.\n * @throws {Error} If the amplification coefficient is not positive.\n * @throws {Error} If convergence fails after 255 iterations.\n */\nexport function getSumInvariant(a: bigint, x: bigint, y: bigint): bigint {\n if (a <= 0n) {\n throw new Error(\"Amplification coefficient must be positive.\");\n }\n x = x * RESERVE_PRECISION;\n y = y * RESERVE_PRECISION;\n a = a * A_PRECISION;\n const sum: bigint = x + y;\n if (sum === 0n) {\n return 0n;\n }\n\n let d = sum;\n const ann = a * 2n;\n for (let i = 0; i < 255; i++) {\n const d_p = (d * d * d) / (4n * x * y);\n const d_prev = d;\n\n d =\n (((ann * sum) / 100n + d_p * 2n) * d) /\n (((ann - 100n) * d) / 100n + 3n * d_p);\n\n if (d > d_prev) {\n if (d - d_prev <= 1) {\n if (liquidityInvariant(x, y, a / A_PRECISION, d)) {\n return d;\n } else {\n return d - 1n;\n }\n }\n } else {\n if (d_prev - d <= 1) {\n if (liquidityInvariant(x, y, a / A_PRECISION, d)) {\n return d;\n } else {\n return d - 1n;\n }\n }\n }\n }\n throw new Error(\"Failed to converge on D value after 255 iterations.\");\n}\n\n/**\n * Calculates the new Y reserve value given a new X reserve value and the sum invariant.\n * This function uses Newton's method to iteratively solve for Y in the Stableswaps equation\n * while maintaining the pool's invariant (D).\n *\n * The function solves: Y^2 + (sum + (D * A_PRECISION) / (2 * Ann) - D) * Y - c = 0\n * where c is derived from D and the pool parameters.\n *\n * This is used during swaps to determine the output reserve after an input is added.\n *\n * @param {bigint} newX - The new reserve amount for asset X (will be scaled by RESERVE_PRECISION internally).\n * @param {bigint} aRaw - The raw amplification coefficient for the pool (will be scaled by A_PRECISION).\n * @param {bigint} sumInvariant - The pool's sum invariant (D), already scaled.\n * @returns {bigint} The calculated Y reserve value scaled by RESERVE_PRECISION.\n * @throws {Error} If convergence fails after 255 iterations.\n */\nexport function getNewY(\n newX: bigint,\n aRaw: bigint,\n sumInvariant: bigint,\n): bigint {\n newX = newX * RESERVE_PRECISION;\n const sum = newX;\n let yPrev: bigint;\n let c = sumInvariant;\n const ann = aRaw * A_PRECISION * 2n;\n\n c = (c * sumInvariant) / (newX * 2n);\n c = (c * sumInvariant * A_PRECISION) / 2n;\n c = c / (ann * 2n);\n const b = sum + (sumInvariant * A_PRECISION) / 2n / ann;\n let y = sumInvariant;\n for (let i = 0; i < 255; i++) {\n yPrev = y;\n y = (y * y + c) / (y * 2n + b - sumInvariant);\n if (y > yPrev) {\n if (y - yPrev <= 1n) {\n if (liquidityInvariant(newX, y, aRaw, sumInvariant)) {\n return y;\n } else {\n return y + 1n;\n }\n }\n } else {\n if (yPrev - y <= 1n) {\n if (liquidityInvariant(newX, y, aRaw, sumInvariant)) {\n return y;\n } else {\n return y + 1n;\n }\n }\n }\n }\n throw new Error(\"Failed to converge on y value after 255 iterations.\");\n}\n\n/**\n * Calculates the initial LP token amount for the first liquidity provision to a pool.\n * This is used when bootstrapping a new pool with initial reserves of assets A and B.\n *\n * The LP tokens minted are derived from the sum invariant (D) divided by the reserve precision,\n * effectively representing the pool's total value at inception.\n *\n * @param {bigint} a - The initial amount of token A being deposited.\n * @param {bigint} b - The initial amount of token B being deposited.\n * @param {bigint} laf - The linear amplification factor for the pool.\n * @returns {bigint} The amount of LP tokens to mint for the first liquidity provision.\n */\nexport const getFirstLp = (a: bigint, b: bigint, laf: bigint) =>\n getSumInvariant(laf, a, b) / RESERVE_PRECISION;\n\n/**\n * Calculates the liquidity parameters for adding liquidity to a Stableswaps pool.\n * This function supports mixed deposits where both assets can be deposited in any proportion.\n *\n * The calculation is based on the change in the sum invariant (D) before and after the deposit.\n * LP tokens are minted proportionally to the increase in D relative to the old D value.\n *\n * TODO: Investigate way to optimize actual deposited amounts\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} laf - The linear amplification factor of the pool.\n * @throws {Error} If the pool doesn't have enough liquidity (both reserves are zero).\n * @throws {Error} If both deposit amounts are zero.\n * @returns {Object} An object containing:\n * - nextTotalLp: The total LP tokens for the pool after the deposit.\n * - generatedLp: The amount of LP tokens generated by the deposit.\n * - shareAfterDeposit: The depositor's share of the pool after the deposit (as a Fraction).\n * - aChange: Always 0n for Stableswaps (no refund needed).\n * - bChange: Always 0n for Stableswaps (no refund needed).\n * - actualDepositedA: The actual amount of A deposited (always equal to input a).\n * - actualDepositedB: The actual amount of B deposited (always equal to input b).\n */\nexport const calculateLiquidity = (\n a: bigint,\n b: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n laf: bigint,\n) => {\n if (aReserve === 0n && bReserve === 0n) {\n throw new Error(\"Not enough pool liquidity\");\n }\n\n if (a === 0n && b === 0n) {\n throw new Error(\"Cannot use a deposit asset amount of 0\");\n }\n\n const oldSumInvariant = getSumInvariant(laf, aReserve, bReserve);\n\n const newSumInvariant = getSumInvariant(laf, aReserve + a, bReserve + b);\n\n const newLpTokens =\n ((newSumInvariant - oldSumInvariant) * totalLp) / oldSumInvariant;\n\n const newTotalLpTokens = totalLp + newLpTokens;\n\n return {\n nextTotalLp: newTotalLpTokens,\n generatedLp: newLpTokens,\n shareAfterDeposit: SharedPoolMath.getShare(newLpTokens, newTotalLpTokens),\n aChange: 0n,\n bChange: 0n,\n actualDepositedA: a,\n actualDepositedB: b,\n };\n};\n\n/**\n * Calculates the token amounts that a given LP token amount represents when withdrawing\n * from a Stableswaps pool. The withdrawal is proportional to the LP tokens being redeemed\n * relative to the total LP supply.\n *\n * This uses a simple linear proportion: amount = (lp * reserve) / totalLp for each asset.\n *\n * @param {bigint} lp - The amount of LP tokens being redeemed.\n * @param {bigint} aReserve - The pool's current reserve amount of token A.\n * @param {bigint} bReserve - The pool's current reserve amount of token B.\n * @param {bigint} totalLp - The pool's total minted LP tokens currently in circulation.\n * @returns {SharedPoolMath.TPair} A tuple [a, b] containing the amounts of tokens A and B to withdraw.\n */\nexport const getTokensForLp = (\n lp: bigint,\n aReserve: bigint,\n bReserve: bigint,\n totalLp: bigint,\n): SharedPoolMath.TPair => [\n new Fraction(lp * aReserve, totalLp).quotient,\n new Fraction(lp * bReserve, totalLp).quotient,\n];\n\n/**\n * Represents the complete outcome of a swap operation in a Stableswaps pool.\n * Contains all relevant information about the swap including amounts, fees, updated reserves,\n * and price impact.\n */\nexport type TSwapOutcome = {\n /** The amount of input tokens being swapped */\n input: bigint;\n /** The amount of output tokens received (after all fees) */\n output: bigint;\n /** The portion of fees that goes to liquidity providers */\n lpFee: AssetAmount<IAssetAmountMetadata>;\n /** The portion of fees that goes to the protocol */\n protocolFee: AssetAmount<IAssetAmountMetadata>;\n /** The input asset reserve amount after the swap */\n nextInputReserve: bigint;\n /** The output asset reserve amount after the swap (excluding protocol fees) */\n nextOutputReserve: bigint;\n /** The pool's sum invariant (D) after the swap */\n nextSumInvariant: bigint;\n /** The price impact of the swap as a fraction (difference between ideal and actual price) */\n priceImpact: Fraction;\n};\n\n/**\n * Calculates the output amount and all swap parameters for a given input amount in a Stableswaps pool.\n * This function determines how many output tokens will be received for a given input, accounting for\n * the Stableswaps curve, LP fees, and protocol fees.\n *\n * The calculation process:\n * 1. Validates inputs and fees\n * 2. Calculates the current sum invariant (D)\n * 3. Determines the new Y value after adding input to X\n * 4. Calculates raw output and applies fees (LP + protocol)\n * 5. Computes price impact by comparing ideal vs actual execution price\n *\n * @param {bigint} input - The amount of input tokens to swap.\n * @param {bigint} inputReserve - The current reserve amount of the input token in the pool.\n * @param {bigint} outputReserve - The current reserve amount of the output token in the pool.\n * @param {TFractionLike} fee - The liquidity provider fee as a fraction (e.g., 0.003 for 0.3%).\n * @param {TFractionLike} protocolFee - The protocol fee as a fraction.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @param {boolean} [roundOutputUp] - Optional flag to round output up instead of down (default: false).\n * @returns {TSwapOutcome} The complete swap outcome including output, fees, reserves, and price impact.\n * @throws {Error} If input or reserves are not positive.\n * @throws {Error} If fee is not in the range [0, 1).\n * @throws {Error} If protocol fee is not in the range [0, 1).\n * @throws {Error} If combined fee is greater than or equal to 1.\n */\nexport const getSwapOutput = (\n outputMetadata: IAssetAmountMetadata,\n input: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n fee: TFractionLike,\n protocolFee: TFractionLike,\n laf: bigint,\n roundOutputUp?: boolean,\n): TSwapOutcome => {\n if (input <= 0 || inputReserve <= 0 || outputReserve <= 0)\n throw new Error(\"Input and reserves must be positive\");\n\n fee = Fraction.asFraction(fee);\n if (fee.lt(Fraction.ZERO) || fee.gte(Fraction.ONE))\n throw new Error(\"fee must be between 0 and 1\");\n\n protocolFee = Fraction.asFraction(protocolFee);\n if (protocolFee.lt(Fraction.ZERO) || protocolFee.gte(Fraction.ONE))\n throw new Error(\"protocolFee must be between 0 and 1\");\n\n const combinedFee = fee.add(protocolFee);\n if (combinedFee.gte(Fraction.ONE))\n throw new Error(\"Combined fee must be less than 1\");\n const sumInvariant = getSumInvariant(laf, inputReserve, outputReserve);\n const nextInputReserve = inputReserve + input;\n const newY = getNewY(nextInputReserve, laf, sumInvariant);\n\n const deltaYPrec = outputReserve * RESERVE_PRECISION - newY;\n const deltaY = new Fraction(deltaYPrec, RESERVE_PRECISION);\n const totalFee = combinedFee\n .multiply(FEE_PRECISION)\n .multiply(deltaY.quotient)\n .add(Fraction.asFraction(FEE_PRECISION - 1n))\n .divide(FEE_PRECISION).quotient;\n const totalProtocolFee = protocolFee\n .multiply(totalFee)\n .divide(combinedFee).quotient;\n const totalLpFee = totalFee - totalProtocolFee;\n const output = deltaY.subtract(totalFee);\n const safeOutput = roundOutputUp\n ? (output.numerator + output.denominator - 1n) / output.denominator\n : output.quotient;\n const nextOutputReserve = outputReserve - safeOutput - totalProtocolFee;\n\n // PRICEIMPACT: \"priceImpact\" is slightly misleadingly named in the industry as a whole\n // just by it's name, it would imply that it's the percentage difference between\n // the current price and the price after the swap, but it's actually the percentage\n // difference between the real price of your swap, and the price implied by the current\n // reserves; We got this wrong in v1, but this aligns it with the industry standard\n // Source: https://dailydefi.org/articles/price-impact-and-how-to-calculate/\n const idealPrice = getPrice(inputReserve, outputReserve, laf);\n const actualPrice = new Fraction(input, safeOutput);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n return {\n input,\n output: safeOutput,\n lpFee: new AssetAmount(totalLpFee, outputMetadata),\n protocolFee: new AssetAmount(totalProtocolFee, outputMetadata),\n nextInputReserve,\n nextOutputReserve,\n nextSumInvariant: getSumInvariant(laf, nextInputReserve, nextOutputReserve),\n priceImpact,\n };\n};\n\n/**\n * The pool's marginal price as raw units of asset A per raw unit of asset B,\n * |dx/dy| at the current reserves. This is the \"ideal\" price that swap price\n * impact is measured against.\n *\n * Derived from the Stableswaps invariant 4A(x + y) + D = 4AD + D^3 / (4xy):\n * price = (xpA + (dR * aReserve) / bReserve) / (xpA + dR)\n * where xpA = 4 * laf * aReserve and dR = D^3 / (4 * aReserve * bReserve)\n *\n * @param {bigint} aReserve - The current reserve amount of asset A in the pool.\n * @param {bigint} bReserve - The current reserve amount of asset B in the pool.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @returns {Fraction} Raw A per raw B at the current reserves.\n */\nexport function getPrice(\n aReserve: bigint,\n bReserve: bigint,\n laf: bigint,\n): Fraction {\n const sumInvariant =\n getSumInvariant(laf, aReserve, bReserve) / RESERVE_PRECISION;\n // D / n^n with n = 2\n let dR = sumInvariant / 4n;\n dR = (dR * sumInvariant) / aReserve;\n dR = (dR * sumInvariant) / bReserve;\n // 4A is the amplification term of the on-chain invariant, A = laf.\n const xpA = 4n * laf * aReserve;\n const p = new Fraction(xpA + (dR * aReserve) / bReserve, xpA + dR);\n return p;\n}\n\n/**\n * Calculates the required input amount and all swap parameters for a desired output amount in a Stableswaps pool.\n * This is the reverse operation of getSwapOutput - given how much you want to receive, it determines\n * how much you need to provide as input, accounting for fees and the Stableswaps curve.\n *\n * The calculation process:\n * 1. Validates inputs, fees, and output constraints\n * 2. Calculates raw output needed before fees\n * 3. Determines the new X value to achieve the desired Y reduction\n * 4. Calculates required input and separates LP and protocol fees\n * 5. Computes price impact by comparing ideal vs actual execution price\n *\n * @param {bigint} output - The desired amount of output tokens to receive.\n * @param {bigint} inputReserve - The current reserve amount of the input token in the pool.\n * @param {bigint} outputReserve - The current reserve amount of the output token in the pool.\n * @param {TFractionLike} fee - The liquidity provider fee as a fraction (e.g., 0.003 for 0.3%).\n * @param {TFractionLike} protocolFee - The protocol fee as a fraction.\n * @param {bigint} laf - The linear amplification factor of the pool.\n * @returns {TSwapOutcome} The complete swap outcome including required input, fees, reserves, and price impact.\n * @throws {Error} If output or reserves are not positive.\n * @throws {Error} If output is greater than or equal to the output reserve.\n * @throws {Error} If fee is not in the range [0, 1).\n * @throws {Error} If protocol fee is not in the range [0, 1).\n * @throws {Error} If combined fee is greater than or equal to 1.\n */\nexport const getSwapInput = (\n outputMetadata: IAssetAmountMetadata,\n output: bigint,\n inputReserve: bigint,\n outputReserve: bigint,\n fee: TFractionLike,\n protocolFee: TFractionLike,\n laf: bigint,\n): TSwapOutcome => {\n if (output <= 0 || inputReserve <= 0 || outputReserve <= 0)\n throw new Error(\"Output and reserves must be positive\");\n\n if (output >= outputReserve)\n throw new Error(\"Output must be less than output reserve\");\n\n fee = Fraction.asFraction(fee);\n if (fee.lt(Fraction.ZERO) || fee.gte(Fraction.ONE))\n throw new Error(\"fee must be [0,1)\");\n\n protocolFee = Fraction.asFraction(protocolFee);\n if (protocolFee.lt(Fraction.ZERO) || protocolFee.gte(Fraction.ONE))\n throw new Error(\"protocolFee must be between 0 and 1\");\n\n const combinedFee = fee.add(protocolFee);\n if (combinedFee.gte(Fraction.ONE))\n throw new Error(\"Combined fee must be less than 1\");\n\n // output = rawOutput * (1-fee)\n // rawOutput = output / (1-fee)\n const rawOutputF = Fraction.asFraction(output).divide(\n Fraction.ONE.sub(combinedFee),\n );\n const rawOutput =\n (rawOutputF.numerator + rawOutputF.denominator - 1n) /\n rawOutputF.denominator;\n const sumInvariant = getSumInvariant(laf, inputReserve, outputReserve);\n const newX = getNewY(outputReserve - rawOutput, laf, sumInvariant);\n const input =\n (newX - inputReserve * RESERVE_PRECISION + RESERVE_PRECISION - 1n) /\n RESERVE_PRECISION;\n\n const totalFee =\n (combinedFee.multiply(FEE_PRECISION).quotient * rawOutput +\n FEE_PRECISION -\n 1n) /\n FEE_PRECISION;\n const totalProtocolFee = protocolFee\n .multiply(totalFee)\n .divide(combinedFee).quotient;\n\n const totalLpFee = totalFee - totalProtocolFee;\n\n const nextInputReserve = inputReserve + input;\n const nextOutputReserve = outputReserve - output - totalProtocolFee;\n\n // See PRICEIMPACT\n const idealPrice = getPrice(inputReserve, outputReserve, laf);\n const actualPrice = new Fraction(input, output);\n const priceImpact = Fraction.ONE.subtract(idealPrice.divide(actualPrice));\n\n const nextSumInvariant = getSumInvariant(\n laf,\n nextInputReserve,\n nextOutputReserve,\n );\n\n return {\n input,\n output,\n lpFee: new AssetAmount(totalLpFee, outputMetadata),\n protocolFee: new AssetAmount(totalProtocolFee, outputMetadata),\n nextInputReserve,\n nextOutputReserve,\n priceImpact,\n nextSumInvariant,\n };\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAA8B,mBAAmB;AACrE,SAASC,cAAc,QAAQ,YAAY;AAC3C,SAASC,QAAQ,QAA4B,sBAAsB;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAChCC,MAAc,EACdC,MAAc,EACdC,mBAA2B,EAC3BC,eAAuB,EACvB;EACA;EACA;EACA;EACA,MAAMC,MAAM,GAAG,EAAE,GAAGF,mBAAmB;EACvC,MAAMG,QAAQ,GAAG,EAAE,GAAGL,MAAM,GAAGC,MAAM;EACrC,MAAMK,UAAU,GAAGH,eAAe,GAAG,EAAE;EACvC,MAAMI,OAAO,GAAGJ,eAAe,GAAGA,eAAe,GAAGA,eAAe;EACnE,MAAMK,gBAAgB,GAAGF,UAAU,GAAGA,UAAU,GAAGA,UAAU;EAC7D,MAA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AK;IACLsB,MAAM;IACNU,KAAK,EAAE,IAAI7F,WAAW,CAACkF,UAAU,EAAEtB,cAAc,CAAC;IAClDK,WAAW,EAAE,IAAIjE,WAAW,CAACiF,gBAAgB,EAAErB,cAAc,CAAC;IAC9Dc,gBAAgB;IAChBc,iBAAiB;IACjBI,WAAW;IACXE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -180,17 +180,18 @@ export type TSwapOutcome = {
|
|
|
180
180
|
*/
|
|
181
181
|
export declare const getSwapOutput: (outputMetadata: IAssetAmountMetadata, input: bigint, inputReserve: bigint, outputReserve: bigint, fee: TFractionLike, protocolFee: TFractionLike, laf: bigint, roundOutputUp?: boolean) => TSwapOutcome;
|
|
182
182
|
/**
|
|
183
|
-
*
|
|
184
|
-
*
|
|
183
|
+
* The pool's marginal price as raw units of asset A per raw unit of asset B,
|
|
184
|
+
* |dx/dy| at the current reserves. This is the "ideal" price that swap price
|
|
185
|
+
* impact is measured against.
|
|
185
186
|
*
|
|
186
|
-
*
|
|
187
|
+
* Derived from the Stableswaps invariant 4A(x + y) + D = 4AD + D^3 / (4xy):
|
|
187
188
|
* price = (xpA + (dR * aReserve) / bReserve) / (xpA + dR)
|
|
188
|
-
* where xpA =
|
|
189
|
+
* where xpA = 4 * laf * aReserve and dR = D^3 / (4 * aReserve * bReserve)
|
|
189
190
|
*
|
|
190
191
|
* @param {bigint} aReserve - The current reserve amount of asset A in the pool.
|
|
191
192
|
* @param {bigint} bReserve - The current reserve amount of asset B in the pool.
|
|
192
193
|
* @param {bigint} laf - The linear amplification factor of the pool.
|
|
193
|
-
* @returns {Fraction}
|
|
194
|
+
* @returns {Fraction} Raw A per raw B at the current reserves.
|
|
194
195
|
*/
|
|
195
196
|
export declare function getPrice(aReserve: bigint, bReserve: bigint, laf: bigint): Fraction;
|
|
196
197
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StableSwapsPool.d.ts","sourceRoot":"","sources":["../../../src/PoolMath/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iBACL,MAAM,OAChB,aAAa,eACL,aAAa,OACrB,MAAM,kBACK,OAAO,KACtB,YAuDF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,QAAQ,CAWV;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,YAAY,mBACP,oBAAoB,UAC5B,MAAM,gBACA,MAAM,iBACL,MAAM,OAChB,aAAa,eACL,aAAa,OACrB,MAAM,KACV,YAoEF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/Asset.d.ts","../../../../node_modules/@sundaeswap/fraction/dist/types/Fraction.d.ts","../../../../node_modules/@sundaeswap/fraction/dist/types/index.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/AssetRatio.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/AssetAmount.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/TokenBundle.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/index.d.ts","../../../../node_modules/@sundaeswap/bigint-math/dist/types/BigIntMath.d.ts","../../../../node_modules/@sundaeswap/bigint-math/dist/types/index.d.ts","../../src/PoolMath/ConstantProductPool.ts","../../src/PoolMath/ConcentratedLiquidityPool.ts","../../src/PoolMath/ConstantSumPool.ts","../../src/PoolMath/StableSwapsPool.ts","../../src/PoolMath/V4StableswapPool.ts","../../src/PoolMath/SharedPoolMath.ts","../../src/PoolMath/index.ts","../../src/@types/index.ts","../../src/index.ts","../../../../node_modules/buffer/index.d.ts","../../../../node_modules/undici-types/header.d.ts","../../../../node_modules/undici-types/readable.d.ts","../../../../node_modules/@types/node/compatibility/disposable.d.ts","../../../../node_modules/@types/node/compatibility/indexable.d.ts","../../../../node_modules/@types/node/compatibility/iterators.d.ts","../../../../node_modules/@types/node/compatibility/index.d.ts","../../../../node_modules/@types/node/ts5.6/globals.typedarray.d.ts","../../../../node_modules/@types/node/ts5.6/buffer.buffer.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/dom-events.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/readline/promises.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/stream/consumers.d.ts","../../../../node_modules/@types/node/stream/web.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/test.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/ts5.6/index.d.ts","../../../../node_modules/undici-types/file.d.ts","../../../../node_modules/undici-types/fetch.d.ts","../../../../node_modules/undici-types/formdata.d.ts","../../../../node_modules/undici-types/connector.d.ts","../../../../node_modules/undici-types/client.d.ts","../../../../node_modules/undici-types/errors.d.ts","../../../../node_modules/undici-types/dispatcher.d.ts","../../../../node_modules/undici-types/global-dispatcher.d.ts","../../../../node_modules/undici-types/global-origin.d.ts","../../../../node_modules/undici-types/pool-stats.d.ts","../../../../node_modules/undici-types/pool.d.ts","../../../../node_modules/undici-types/handlers.d.ts","../../../../node_modules/undici-types/balanced-pool.d.ts","../../../../node_modules/undici-types/agent.d.ts","../../../../node_modules/undici-types/mock-interceptor.d.ts","../../../../node_modules/undici-types/mock-agent.d.ts","../../../../node_modules/undici-types/mock-client.d.ts","../../../../node_modules/undici-types/mock-pool.d.ts","../../../../node_modules/undici-types/mock-errors.d.ts","../../../../node_modules/undici-types/proxy-agent.d.ts","../../../../node_modules/undici-types/api.d.ts","../../../../node_modules/undici-types/cookies.d.ts","../../../../node_modules/undici-types/patch.d.ts","../../../../node_modules/undici-types/filereader.d.ts","../../../../node_modules/undici-types/diagnostics-channel.d.ts","../../../../node_modules/undici-types/websocket.d.ts","../../../../node_modules/undici-types/content-type.d.ts","../../../../node_modules/undici-types/cache.d.ts","../../../../node_modules/undici-types/interceptors.d.ts","../../../../node_modules/undici-types/index.d.ts","../../node_modules/@types/bun/node_modules/bun-types/globals.d.ts","../../node_modules/@types/bun/node_modules/bun-types/s3.d.ts","../../node_modules/@types/bun/node_modules/bun-types/fetch.d.ts","../../node_modules/@types/bun/node_modules/bun-types/jsx.d.ts","../../node_modules/@types/bun/node_modules/bun-types/bun.d.ts","../../node_modules/@types/bun/node_modules/bun-types/extensions.d.ts","../../node_modules/@types/bun/node_modules/bun-types/devserver.d.ts","../../node_modules/@types/bun/node_modules/bun-types/ffi.d.ts","../../node_modules/@types/bun/node_modules/bun-types/html-rewriter.d.ts","../../node_modules/@types/bun/node_modules/bun-types/jsc.d.ts","../../node_modules/@types/bun/node_modules/bun-types/sqlite.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/utils.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/overloads.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/branding.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/messages.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/index.d.ts","../../node_modules/@types/bun/node_modules/bun-types/test.d.ts","../../node_modules/@types/bun/node_modules/bun-types/wasm.d.ts","../../node_modules/@types/bun/node_modules/bun-types/overrides.d.ts","../../node_modules/@types/bun/node_modules/bun-types/deprecated.d.ts","../../node_modules/@types/bun/node_modules/bun-types/redis.d.ts","../../node_modules/@types/bun/node_modules/bun-types/shell.d.ts","../../node_modules/@types/bun/node_modules/bun-types/serve.d.ts","../../node_modules/@types/bun/node_modules/bun-types/sql.d.ts","../../node_modules/@types/bun/node_modules/bun-types/security.d.ts","../../node_modules/@types/bun/node_modules/bun-types/bundle.d.ts","../../node_modules/@types/bun/node_modules/bun-types/bun.ns.d.ts","../../node_modules/@types/bun/node_modules/bun-types/index.d.ts","../../node_modules/@types/bun/index.d.ts","../../../../node_modules/@types/aria-query/index.d.ts","../../../../node_modules/@babel/types/lib/index.d.ts","../../../../node_modules/@types/babel__generator/index.d.ts","../../../../node_modules/@babel/parser/typings/babel-parser.d.ts","../../../../node_modules/@types/babel__template/index.d.ts","../../../../node_modules/@types/babel__traverse/index.d.ts","../../../../node_modules/@types/babel__core/index.d.ts","../../../../node_modules/@types/connect/index.d.ts","../../../../node_modules/@types/body-parser/index.d.ts","../../../../node_modules/@types/bonjour/index.d.ts","../../../../node_modules/@types/cli-progress/index.d.ts","../../../../node_modules/mime/dist/src/Mime.d.ts","../../../../node_modules/mime/dist/src/index.d.ts","../../../../node_modules/@types/send/index.d.ts","../../../../node_modules/@types/qs/index.d.ts","../../../../node_modules/@types/range-parser/index.d.ts","../../../../node_modules/@types/express-serve-static-core/index.d.ts","../../../../node_modules/@types/connect-history-api-fallback/index.d.ts","../../../../node_modules/@types/dns-packet/index.d.ts","../../../../node_modules/@types/estree/index.d.ts","../../../../node_modules/@types/json-schema/index.d.ts","../../../../node_modules/@types/eslint/use-at-your-own-risk.d.ts","../../../../node_modules/@types/eslint/index.d.ts","../../../../node_modules/@eslint/core/dist/esm/types.d.ts","../../../../node_modules/eslint/lib/types/use-at-your-own-risk.d.ts","../../../../node_modules/eslint/lib/types/index.d.ts","../../../../node_modules/@types/eslint-scope/index.d.ts","../../../../node_modules/@types/http-errors/index.d.ts","../../../../node_modules/@types/serve-static/index.d.ts","../../../../node_modules/@types/express/node_modules/@types/express-serve-static-core/index.d.ts","../../../../node_modules/@types/express/index.d.ts","../../../../node_modules/@types/minimatch/index.d.ts","../../../../node_modules/@types/glob/index.d.ts","../../../../node_modules/@types/graceful-fs/index.d.ts","../../../../node_modules/@types/unist/index.d.ts","../../../../node_modules/@types/hast/index.d.ts","../../../../node_modules/@types/html-minifier-terser/index.d.ts","../../../../node_modules/@types/http-proxy/index.d.ts","../../../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../../../node_modules/@types/istanbul-lib-report/index.d.ts","../../../../node_modules/@types/istanbul-reports/index.d.ts","../../../../node_modules/@jest/expect-utils/build/index.d.ts","../../../../node_modules/chalk/index.d.ts","../../../../node_modules/@jest/schemas/node_modules/@sinclair/typebox/typebox.d.ts","../../../../node_modules/@jest/schemas/build/index.d.ts","../../../../node_modules/pretty-format/build/index.d.ts","../../../../node_modules/jest-matcher-utils/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/jest-matcher-utils/build/index.d.ts","../../../../node_modules/expect/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts","../../../../node_modules/parse5/dist/common/html.d.ts","../../../../node_modules/parse5/dist/common/token.d.ts","../../../../node_modules/parse5/dist/common/error-codes.d.ts","../../../../node_modules/parse5/dist/tokenizer/preprocessor.d.ts","../../../../node_modules/parse5/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts","../../../../node_modules/parse5/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts","../../../../node_modules/parse5/node_modules/entities/dist/commonjs/decode-codepoint.d.ts","../../../../node_modules/parse5/node_modules/entities/dist/commonjs/decode.d.ts","../../../../node_modules/parse5/node_modules/entities/decode.d.ts","../../../../node_modules/parse5/dist/tokenizer/index.d.ts","../../../../node_modules/parse5/dist/tree-adapters/interface.d.ts","../../../../node_modules/parse5/dist/parser/open-element-stack.d.ts","../../../../node_modules/parse5/dist/parser/formatting-element-list.d.ts","../../../../node_modules/parse5/dist/parser/index.d.ts","../../../../node_modules/parse5/dist/tree-adapters/default.d.ts","../../../../node_modules/parse5/dist/serializer/index.d.ts","../../../../node_modules/parse5/dist/common/foreign-content.d.ts","../../../../node_modules/parse5/dist/index.d.ts","../../../../node_modules/@types/tough-cookie/index.d.ts","../../../../node_modules/@types/jsdom/base.d.ts","../../../../node_modules/@types/jsdom/index.d.ts","../../../../node_modules/@types/json5/index.d.ts","../../../../node_modules/@types/mdast/index.d.ts","../../../../node_modules/@types/mime/index.d.ts","../../../../node_modules/@types/minimist/index.d.ts","../../../../node_modules/@types/node-forge/index.d.ts","../../../../node_modules/@types/normalize-package-data/index.d.ts","../../../../node_modules/@types/parse-json/index.d.ts","../../../../node_modules/@types/prop-types/index.d.ts","../../../../node_modules/@types/react/global.d.ts","../../../../node_modules/csstype/index.d.ts","../../../../node_modules/@types/react/index.d.ts","../../../../node_modules/@types/react-dom/index.d.ts","../../../../node_modules/@types/retry/index.d.ts","../../../../node_modules/@types/serve-index/index.d.ts","../../../../node_modules/@types/sockjs/index.d.ts","../../../../node_modules/@types/stack-utils/index.d.ts","../../../../node_modules/@types/testing-library__jest-dom/matchers.d.ts","../../../../node_modules/@types/testing-library__jest-dom/index.d.ts","../../../../node_modules/@types/ws/index.d.ts","../../../../node_modules/@types/yargs-parser/index.d.ts","../../../../node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"44e584d4f6444f58791784f1d530875970993129442a847597db702a073ca68c","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4",{"version":"4af6b0c727b7a2896463d512fafd23634229adf69ac7c00e2ae15a09cb084fad","affectsGlobalScope":true},{"version":"9c00a480825408b6a24c63c1b71362232927247595d7c97659bc24dc68ae0757","affectsGlobalScope":true},{"version":"6920e1448680767498a0b77c6a00a8e77d14d62c3da8967b171f1ddffa3c18e4","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true},{"version":"ae37d6ccd1560b0203ab88d46987393adaaa78c919e51acf32fb82c86502e98c","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"479553e3779be7d4f68e9f40cdb82d038e5ef7592010100410723ceced22a0f7","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"51c956a7c738d7f4fd20eec47a375a8cb710ea54f82fb0ad03d787fb12657d92","68c52be545faa567bbb3568f7bdfe6cce70e2715c9c13a61849f86aea5a9ebbd","e9a73f3b07707e735d5a85fc8edd642c907efe342e9ce6f1e96102965dc3ba89","b34f125d24f666b3146a2aa7075fb5c75248fe05bb035be9c3acf408c084790e","de495af61b69bc716de329ae92128b85d1adb1a412ec2b18bdc09e1e2408c3d7","fe0d90c26b19d8f79ccc69c68f0facfd3dc808c3dc19fcd452cf30cb199a7a8e","6257871c4fc4701fb42d4136f5bc86529c97a9abb1d0fc7babbef91b6f1942f2","910f330ba93ef8eb90baabbc6ed0b12ad8d9b27dc841aa95dfb2799643c41045","874a1013a9dab7c69706b58b35e85658ab0b284b834b2dc3af8906f534ad79ae",{"version":"6349b914e11d35e0838992e22a0d5a91f45cbfeb571cb258efa226fe3c4dc70d","signature":"9d84cdf64851b02a22b32f27b4b6fc80070be07433427d8d68f1400257e5bd9d"},{"version":"849251b4ef64a785515ce9117df1c5a5786ff46e1b6c9a4f57e525c61a553447","signature":"4b89c87ec616b0e3b467d2a3da543888142af07e2cfd46b7cf52ee685341ff04"},{"version":"bb11d6e02857ebea041f90fc2fbd1a7c455ca41aad407c91718ef685d8408ef4","signature":"adfbddda72c24b22754e0e37019c4f5554883f7ebf42bf3e857eb954c6054ad1"},{"version":"5b54cb1f553615f10ae0b109cd2db8105d230990d533a471b9a557950e748bf5","signature":"9877369dae0eb6372d38869e30e385c44f99de7cefc41b38e851c9428b7bd22e"},{"version":"56bfbd9f72d74aeb06d59e8ec4b17eb75aedf11ad5d097a4101a06083e1df5c9","signature":"0e906d5f05e64af0be85ff811ed8a9a1077abe71fa2b5c2458cc083bde933406"},{"version":"66acaaa1d369f8beb3eeb99ecda57f318b28005caee5405fe8da1cbca2727e26","signature":"7b311aa1193ba30b6beb6bca85a137af8410bbab82bee6d78b58397e0a64f728"},"d85da46b692d6705d368ae658e036853c55d4a3900067744f572a73d8b7a6bd0","d505dd3248a004e125aedacd78ac294598ac676ff103c532d35de6355ebf2786","7fc64678c4e3e69edf0add713b86c4f2ae254ea12ded16a99366142b29dda7b3","4967529644e391115ca5592184d4b63980569adf60ee685f968fd59ab1557188","5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","7180c03fd3cb6e22f911ce9ba0f8a7008b1a6ddbe88ccf16a9c8140ef9ac1686",{"version":"6c7176368037af28cb72f2392010fa1cef295d6d6744bca8cfb54985f3a18c3e","affectsGlobalScope":true},{"version":"ab41ef1f2cdafb8df48be20cd969d875602483859dc194e9c97c8a576892c052","affectsGlobalScope":true},{"version":"437e20f2ba32abaeb7985e0afe0002de1917bc74e949ba585e49feba65da6ca1","affectsGlobalScope":true},"21d819c173c0cf7cc3ce57c3276e77fd9a8a01d35a06ad87158781515c9a438a",{"version":"613b21ccdf3be6329d56e6caa13b258c842edf8377be7bc9f014ed14cdcfc308","affectsGlobalScope":true},{"version":"d2662405c15ec112ebc0c3ec787edb82d58d6acb1a9d109317d7bf9cff9d09a7","affectsGlobalScope":true},{"version":"1a2e588ce04b57f262959afb54933563431bf75304cfda6165703fe08f4018c5","affectsGlobalScope":true},"c775b106d611ae2c068ed8429a132608d10007918941311214892dcd4a571ad7","7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","75eb536b960b85f75e21490beeab53ea616646a995ad203e1af532d67a774fb6",{"version":"36d0976d3dad74078f707af107b5082dbe42ffcadb3442ff140c36c8a33b4887","affectsGlobalScope":true},"51bb58ef3a22fdc49a2d338a852050855d1507f918d4d7fa77a68d72fee9f780","7646ad748a9ca15bf43d4c88f83cc851c67f8ec9c1186295605b59ba6bb36dcb",{"version":"cef8931bc129687165253f0642427c2a72705a4613b3ac461b9fa78c7cdaef32","affectsGlobalScope":true},"5524481e56c48ff486f42926778c0a3cce1cc85dc46683b92b1271865bcf015a","47b62c294beb69daa5879f052e416b02e6518f3e4541ae98adbfb27805dd6711","f8375506002c556ec412c7e2a5a9ece401079ee5d9eb2c1372e9f5377fac56c7","8edd6482bd72eca772f9df15d05c838dd688cdbd4d62690891fca6578cfda6fe","07ba29a1a495b710aea48a4cf19ae12b3cbda2a8e9ac62192af477027a99e8de","6dead64c944504250dd2fc9095231f36887cfc1534f1ff57737c19f92d165c91","b9a4824bb83f25d6d227394db2ed99985308cf2a3a35f0d6d39aa72b15473982",{"version":"6e57c0b7b3d2716fbc0ca28aa23f62bc997ad534d1369f3853dcb9d453d1fb91","affectsGlobalScope":true},{"version":"b84f34005e497dbc0c1948833818cdb38e8c01ff4f88d810b4d70aa2e6c52916","affectsGlobalScope":true},"8e8e284b3832911aeede987e4d74cf0a00f2b03896b2fd3bf924344cc0f96b3c","37d37474a969ab1b91fc332eb6a375885dfd25279624dfa84dea48c9aedf4472","957905d33a09ce85efd84a65819cdd22eefdd64959afacbdcfe5f36b0d7a7bbe","f1a79b6047d006548185e55478837dfbcdd234d6fe51532783f5dffd401cfb2b","565fda33feca88f4b5db23ba8e605da1fd28b6d63292d276bdbd2afe6cd4c490","e822320b448edce0c7ede9cbeada034c72e1f1c8c8281974817030564c63dcb1",{"version":"9d65568cba17c9db40251023406668695ad698ea4a34542364af3e78edd37811","affectsGlobalScope":true},"f23e3d484de54d235bf702072100b541553a1df2550bad691fe84995e15cf7be","821c79b046e40d54a447bebd9307e70b86399a89980a87bbc98114411169e274","17bc38afc78d40b2f54af216c0cc31a4bd0c6897a5945fa39945dfc43260be2c",{"version":"d201b44ff390c220a94fb0ff6a534fe9fa15b44f8a86d0470009cdde3a3e62ab","affectsGlobalScope":true},{"version":"d44445141f204d5672c502a39c1124bcf1df225eba05df0d2957f79122be87b5","affectsGlobalScope":true},"de905bc5f7e7a81cb420e212b95ab5e3ab840f93e0cfa8ce879f6e7fa465d4a2","bc2ff43214898bc6d53cab92fb41b5309efec9cbb59a0650525980aee994de2b","bede3143eeddca3b8ec3592b09d7eb02042f9e195251040c5146eac09b173236","64a40cf4ec8a7a29db2b4bc35f042e5be8537c4be316e5221f40f30ca8ed7051","294c082d609e6523520290db4f1d54114ebc83643fb42abd965be5bcc5d9416b","cf7d740e39bd8adbdc7840ee91bef0af489052f6467edfcefb7197921757ec3b","37ba7b45141a45ce6e80e66f2a96c8a5ab1bcef0fc2d0f56bb58df96ec67e972","125d792ec6c0c0f657d758055c494301cc5fdb327d9d9d5960b3f129aff76093",{"version":"b9f0681c4d2cb00a5cfe08a7be9662627b912de562926819ebddfe2ef6a9b5ee","affectsGlobalScope":true},"b85151402164ab7cb665e58df5c1a29aa25ea4ed3a367f84a15589e7d7a9c8ca","89eb8abe2b5c146fbb8f3bf72f4e91de3541f2fb559ad5fed4ad5bf223a3dedb",{"version":"bc6cb10764a82f3025c0f4822b8ad711c16d1a5c75789be2d188d553b69b2d48","affectsGlobalScope":true},"41d510caf7ed692923cb6ef5932dc9cf1ed0f57de8eb518c5bab8358a21af674","2751c5a6b9054b61c9b03b3770b2d39b1327564672b63e3485ac03ffeb28b4f6","dc058956a93388aab38307b7b3b9b6379e1021e73a244aab6ac9427dc3a252a7","f33302cf240672359992c356f2005d395b559e176196d03f31a28cc7b01e69bc",{"version":"3ce25041ff6ae06c08fcaccd5fcd9baf4ca6e80e6cb5a922773a1985672e74c2","affectsGlobalScope":true},{"version":"652c0de14329a834ff06af6ad44670fac35849654a464fd9ae36edb92a362c12","affectsGlobalScope":true},"3b1e178016d3fc554505ae087c249b205b1c50624d482c542be9d4682bab81fc","5db7c5bb02ef47aaaec6d262d50c4e9355c80937d649365c343fa5e84569621d","cf45d0510b661f1da461479851ff902f188edb111777c37055eff12fa986a23a",{"version":"ec9a5f06328f61e09f44d6781d1bd862475f9900c16cef82621a46305def3c4d","affectsGlobalScope":true},"37bef1064b7d015aeaa7c0716fe23a0b3844abe2c0a3df7144153ca8445fe0da","75bd411256302c183207051fd198b4e0dbab45d28a6daf04d3ad61f70a2c8e90","25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","54cb85a47d760da1c13c00add10d26b5118280d44d58e6908d8e89abbd9d7725","3e4825171442666d31c845aeb47fcd34b62e14041bb353ae2b874285d78482aa","c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","a967bfe3ad4e62243eb604bf956101e4c740f5921277c60debaf325c1320bf88","e9775e97ac4877aebf963a0289c81abe76d1ec9a2a7778dbe637e5151f25c5f3","471e1da5a78350bc55ef8cef24eb3aca6174143c281b8b214ca2beda51f5e04a","cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","db3435f3525cd785bf21ec6769bf8da7e8a776be1a99e2e7efb5f244a2ef5fee","c3b170c45fc031db31f782e612adf7314b167e60439d304b49e704010e7bafe5","40383ebef22b943d503c6ce2cb2e060282936b952a01bea5f9f493d5fb487cc7","4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","3a84b7cb891141824bd00ef8a50b6a44596aded4075da937f180c90e362fe5f6","13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","33203609eba548914dc83ddf6cadbc0bcb6e8ef89f6d648ca0908ae887f9fcc5","0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","9f0a92164925aa37d4a5d9dd3e0134cff8177208dba55fd2310cd74beea40ee2","8bfdb79bf1a9d435ec48d9372dc93291161f152c0865b81fc0b2694aedb4578d","2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","d32275be3546f252e3ad33976caf8c5e842c09cb87d468cb40d5f4cf092d1acc","4a0c3504813a3289f7fb1115db13967c8e004aa8e4f8a9021b95285502221bd1",{"version":"065abdf835a1f02c09c61784b9fe28a0896ad1cafb5d522a05c229dffc87fb68","affectsGlobalScope":true},"9d6d1979f27b9e189b8ea90f553b345617eebf94b0fa6bfe4162f25ba6571a10","f2071e0794d585da33e5012483c573508a512b6182ace2117563b3bd85c05aac","013b7fcfa5f1dcc7038cf9287de6d558ed0b76fd20b633f936c10d6764767ed9","2089ccdcdfb5b2ffe365a797387a024cd69146c4ea271fa6d2b6e2079ca5c8e9","b1e2ccc111f0f8313f9f50bbc637564299ac19a1f76b60e51ec07e3d7d9d3792",{"version":"4fd5357366c4bfe2dd8f3d91b2e494664d97af113f31c06ed16ac76be3068e61","affectsGlobalScope":true},"c3de319ca5807d77da32720161f4f6d4d73bafe3336ba64d4018ec598d0e10fe",{"version":"7caed84a09eae11ca7d226cbbc5f5a2e2e13d63246a01689134afeefb9a34b22","affectsGlobalScope":true},"21e5d6be35f291ba44c60285104664cd5a5212d36ccbcd8e975956c63f78288d","c37491db3d2b7ecec7e833ba6505b965b7bdc1dfbad1528d9c9f22095fe66f86","ffd344731abee98a0a85a735b19052817afd2156d97d1410819cd9bcd1bd575e","475e07c959f4766f90678425b45cf58ac9b95e50de78367759c1e5118e85d5c3","a524ae401b30a1b0814f1bbcdae459da97fa30ae6e22476e506bb3f82e3d9456","7375e803c033425e27cb33bae21917c106cb37b508fd242cccd978ef2ee244c7","eeb890c7e9218afdad2f30ad8a76b0b0b5161d11ce13b6723879de408e6bc47a","66cdd559b95aa1df7ba823b45b9a0a028c49430a829c5da495865dd49c54a782",{"version":"8fedbe5fb23749a10cbbd027edaa2f0a166fb802fcd65569a2119946199defbe","affectsGlobalScope":true},{"version":"c2d7a7dfeccad92ee791fb3d8529f523ebd387b368e7f1e35cb9f4e64de0add9","affectsGlobalScope":true},{"version":"49692ced244928bc4b99fbf26845355090500e5269fd26961f21c75eb36703c1","affectsGlobalScope":true},"6b7cfa9f3344d855361d9ef05b2b6a4ae3f782afb68eaeaf63151d6169a43704","610a869934b3c2cab2878309cf9e2d9ca1307af2f543c7b6e3bb8b868f76a149","902c11d8c36e16a0e7db09db0c2112731055595800977c9370042cdf646a0e7b","9ae72ea9b6e33001dbe932bc3b8c6566601eb0b5f7c262998c9c68f4c121986e","2148d39e8c3743a569fbbd30ac76dabac2c74d0da98cf6e4fef43d3ecbbe7da9","e2d2bec3a0414b0be4b9fc3c8d072e77f3950556988fa1e4095092a351f18eeb",{"version":"c8109fe76467db6e801d0edfbc50e6826934686467c9418ce6b246232ce7f109","affectsGlobalScope":true},{"version":"e6f803e4e45915d58e721c04ec17830c6e6678d1e3e00e28edf3d52720909cea","affectsGlobalScope":true},"37be812b06e518320ba82e2aff3ac2ca37370a9df917db708f081b9043fa3315","ae77d81a5541a8abb938a0efedf9ac4bea36fb3a24cc28cfa11c598863aba571","a28ac3e717907284b3910b8e9b3f9844a4e0b0a861bea7b923e5adf90f620330","b6d03c9cfe2cf0ba4c673c209fcd7c46c815b2619fd2aad59fc4229aaef2ed43","82e5a50e17833a10eb091923b7e429dc846d42f1c6161eb6beeb964288d98a15","670a76db379b27c8ff42f1ba927828a22862e2ab0b0908e38b671f0e912cc5ed","13b77ab19ef7aadd86a1e54f2f08ea23a6d74e102909e3c00d31f231ed040f62","069bebfee29864e3955378107e243508b163e77ab10de6a5ee03ae06939f0bb9","104c67f0da1bdf0d94865419247e20eded83ce7f9911a1aa75fc675c077ca66e","cc0d0b339f31ce0ab3b7a5b714d8e578ce698f1e13d7f8c60bfb766baeb1d35c","f9e22729fa06ed20f8b1fe60670b7c74933fdfd44d869ddfb1919c15a5cf12fb","c0e5b4df115963b8a8dcd5b56ff9dc046ddec110de138dba29b00e2b02fa03a9","0ae65c3e977c81f6e46ae9028ae97fc75c78c70f4d6d5f961a8af60301145af6","b1a6683b821c624d63d887dbdd9f34aebb9de586acf87bbf50cb16f5ec2c36c7","b78cd10245a90e27e62d0558564f5d9a16576294eee724a59ae21b91f9269e4a","baac9896d29bcc55391d769e408ff400d61273d832dd500f21de766205255acb","2f5747b1508ccf83fad0c251ba1e5da2f5a30b78b09ffa1cfaf633045160afed",{"version":"a8932b7a5ef936687cc5b2492b525e2ad5e7ed321becfea4a17d5a6c80f49e92","affectsGlobalScope":true},"689be50b735f145624c6f391042155ae2ff6b90a93bac11ca5712bc866f6010c","bc222163edcb8df6ba9b506d053d6c5afcae50e85695151cf4636a3107deaba9","151ff381ef9ff8da2da9b9663ebf657eac35c4c9a19183420c05728f31a6761d","f3d8c757e148ad968f0d98697987db363070abada5f503da3c06aefd9d4248c1","a4a39b5714adfcadd3bbea6698ca2e942606d833bde62ad5fb6ec55f5e438ff8","bbc1d029093135d7d9bfa4b38cbf8761db505026cc458b5e9c8b74f4000e5e75","851fe8b694793c8e4c48c154847712e940694e960e33ac68b73e94557d6aff8d","8a190298d0ff502ad1c7294ba6b0abb3a290fc905b3a00603016a97c363a4c7a","ed1441df2b8bbbd907f603490cb207f44141fe191b20be2f270e8de69bfa194a","1f68ab0e055994eb337b67aa87d2a15e0200951e9664959b3866ee6f6b11a0fe","b71c603a539078a5e3a039b20f2b0a0d1708967530cf97dec8850a9ca45baa2b","0e13570a7e86c6d83dd92e81758a930f63747483e2cd34ef36fcdb47d1f9726a",{"version":"a45c25e77c911c1f2a04cade78f6f42b4d7d896a3882d4e226efd3a3fcd5f2c4","affectsGlobalScope":true},"5c45abf1e13e4463eacfd5dedda06855da8748a6a6cb3334f582b52e219acc04","8841e2aa774b89bd23302dede20663306dc1b9902431ac64b24be8b8d0e3f649","fd326577c62145816fe1acc306c734c2396487f76719d3785d4e825b34540b33","afe73051ff6a03a9565cbd8ebb0e956ee3df5e913ad5c1ded64218aabfa3dcb5","89121c1bf2990f5219bfd802a3e7fc557de447c62058d6af68d6b6348d64499a","79b4369233a12c6fa4a07301ecb7085802c98f3a77cf9ab97eee27e1656f82e6","ee65fe452abe1309389c5f50710f24114e08a302d40708101c4aa950a2a7d044","63786b6f821dee19eb898afb385bd58f1846e6cba593a35edcf9631ace09ba25","035a5df183489c2e22f3cf59fc1ed2b043d27f357eecc0eb8d8e840059d44245","a4809f4d92317535e6b22b01019437030077a76fec1d93b9881c9ed4738fcc54","5f53fa0bd22096d2a78533f94e02c899143b8f0f9891a46965294ee8b91a9434","763e521cf114b80e0dd0e21ca49b9f8ae62e8999555a5e7bade8ce36b33001c2","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","3054ef91b855e005b9c4681399e9d64d2a7b07a22d539314d794f09e53b876a7","ffcc5500e77223169833fc6eb59b3a507944a1f89574e0a1276b0ea7fc22c4a4","22f13de9e2fe5f0f4724797abd3d34a1cdd6e47ef81fc4933fea3b8bf4ad524b","e3ba509d3dce019b3190ceb2f3fc88e2610ab717122dabd91a9efaa37804040d","cda0cb09b995489b7f4c57f168cd31b83dcbaa7aad49612734fb3c9c73f6e4f2","f72f8428f3c1caa22e9c247d046603b85b442c0dae7b77a7a0bc092c18867cb7",{"version":"195f63105abc03e72b6a176e3e34dfb5ac932b55db378fdc7874b1617e24b465","affectsGlobalScope":true},"19990350fca066265b2c190c9b6cde1229f35002ea2d4df8c9e397e9942f6c89","8fb8fdda477cd7382477ffda92c2bb7d9f7ef583b1aa531eb6b2dc2f0a206c10","66995b0c991b5c5d42eff1d950733f85482c7419f7296ab8952e03718169e379","9863f888da357e35e013ca3465b794a490a198226bd8232c2f81fb44e16ff323","84bc2d80326a83ee4a6e7cba2fd480b86502660770c0e24da96535af597c9f1e","ea27768379b866ee3f5da2419650acdb01125479f7af73580a4bceb25b79e372","598931eeb4362542cae5845f95c5f0e45ac668925a40ce201e244d7fe808e965","da9ef88cde9f715756da642ad80c4cd87a987f465d325462d6bc2a0b11d202c8","9462ab013df86c16a2a69ca0a3b6f31d4fd86dd29a947e14b590eb20806f220b","b4c6184d78303b0816e779a48bef779b15aea4a66028eb819aac0abee8407dea","db085d2171d48938a99e851dafe0e486dce9859e5dfa73c21de5ed3d4d6fb0c5","62a3ad1ddd1f5974b3bf105680b3e09420f2230711d6520a521fab2be1a32838","a77be6fc44c876bc10c897107f84eaba10790913ebdcad40fcda7e47469b2160","06cf55b6da5cef54eaaf51cdc3d4e5ebf16adfdd9ebd20cec7fe719be9ced017","91f5dbcdb25d145a56cffe957ec665256827892d779ef108eb2f3864faff523b","052ba354bab8fb943e0bc05a0769f7b81d7c3b3c6cd0f5cfa53c7b2da2a525c5","927955a3de5857e0a1c575ced5a4245e74e6821d720ed213141347dd1870197f","fec804d54cd97dd77e956232fc37dc13f53e160d4bbeeb5489e86eeaa91f7ebd","03c258e060b7da220973f84b89615e4e9850e9b5d30b3a8e4840b3e3268ae8eb","fd0589ca571ad090b531d8c095e26caa53d4825c64d3ff2b2b1ab95d72294175",{"version":"669843ecafb89ae1e944df06360e8966219e4c1c34c0d28aa2503272cdd444a7","affectsGlobalScope":true},"96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538","d4a22007b481fe2a2e6bfd3a42c00cd62d41edb36d30fc4697df2692e9891fc8","d3f2d715f57df3f04bf7b16dde01dec10366f64fce44503c92b8f78f614c1769","fbca5ffaebf282ec3cdac47b0d1d4a138a8b0bb32105251a38acb235087d3318","a39f2a304ccc39e70914e9db08f971d23b862b6f0e34753fad86b895fe566533","22293bd6fa12747929f8dfca3ec1684a3fe08638aa18023dd286ab337e88a592","916be7d770b0ae0406be9486ac12eb9825f21514961dd050594c4b250617d5a8","87d9d29dbc745f182683f63187bf3d53fd8673e5fca38ad5eaab69798ed29fbc",{"version":"eb5b19b86227ace1d29ea4cf81387279d04bb34051e944bc53df69f58914b788","affectsGlobalScope":true},"8a8eb4ebffd85e589a1cc7c178e291626c359543403d58c9cd22b81fab5b1fb9",{"version":"472f5aab7edc498a0a761096e8e254c5bc3323d07a1e7f5f8b8ec0d6395b60a0","affectsGlobalScope":true},"17ed71200119e86ccef2d96b73b02ce8854b76ad6bd21b5021d4269bec527b5f","199f9ead0daf25ae4c5632e3d1f42570af59685294a38123eef457407e13f365","ddef25f825320de051dcb0e62ffce621b41c67712b5b4105740c32fd83f4c449","1b3dffaa4ca8e38ac434856843505af767a614d187fb3a5ef4fcebb023c355aa","ab82804a14454734010dcdcd43f564ff7b0389bee4c5692eec76ff5b30d4cf66","3f36c0c7508302f3dca3dc5ab0a66d822b2222f70c24bb1796ddb5c9d1168a05",{"version":"b23d5b89c465872587e130f427b39458b8e3ad16385f98446e9e86151ba6eb15","affectsGlobalScope":true},"1ba59c8bbeed2cb75b239bb12041582fa3e8ef32f8d0bd0ec802e38442d3f317","bae8d023ef6b23df7da26f51cea44321f95817c190342a36882e93b80d07a960","26a770cec4bd2e7dbba95c6e536390fffe83c6268b78974a93727903b515c4e7"],"root":[63,64],"options":{"allowJs":false,"allowSyntheticDefaultImports":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":99,"outDir":"./","skipLibCheck":true,"strict":true,"target":7},"fileIdsList":[[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,187],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,206],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,229],[47,49,50,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[51,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[47,50,51,52,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[54,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[48,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,187,188,189,190,191],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,187,189],[73,78,93,126,157,158,159,161,163,174,175,176,177,178,179,180,181,193],[73,78,84,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,119,126,157,158,159,161,163,174,175,176,177,178,179,180,181,202],[73,78,93,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,205,211],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,205,206,207],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,208],[73,78,90,93,126,157,158,159,161,163,174,175,176,177,178,179,180,181,199,200,201],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,194,200,202,214,215],[73,78,90,91,126,157,158,159,161,163,174,175,176,177,178,179,180,181,217],[73,78,91,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,220],[73,78,90,93,95,98,108,119,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,224],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,225],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,231,234,274],[73,78,90,122,126,157,158,159,161,163,174,175,176,177,178,179,180,181,253,254,256],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,255],[73,75,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,77,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,83,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,79,90,91,98,108,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,79,80,90,98,157,158,159,161,163,174,175,176,177,178,179,180,181],[68,69,70,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,81,120,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,82,83,91,99,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,83,108,116,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,84,86,90,98,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,77,78,85,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,86,87,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,88,90,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,77,78,90,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,91,92,108,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,91,92,105,108,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,156,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,86,90,93,98,108,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,91,93,94,98,108,116,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,93,95,108,116,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,96,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,97,119,124,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,86,90,98,108,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,99,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,100,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,77,78,101,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,102,118,124,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,103,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,104,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,105,106,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,105,107,120,122,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,108,109,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,110,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,109,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,112,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,113,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,114,115,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,114,115,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,83,98,108,116,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,117,157,158,159,161,163,174,175,176,177,178,179,180,181],[78,157,158,159,161,163,174,175,176,177,178,179,180,181],[71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,98,118,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,93,104,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,83,120,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,121,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,97,122,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,123,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,92,101,108,111,119,122,124,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,125,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,267],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,264,265,266],[73,78,91,108,126,157,158,159,161,163,174,175,176,177,178,179,180,181,198],[73,78,91,157,158,159,161,163,174,175,176,177,178,179,180,181,216],[73,78,93,126,157,158,159,161,163,174,175,176,177,178,179,180,181,199,213],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,234,235,273],[73,78,90,93,95,98,108,116,119,125,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,276],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,205,206,209,210],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,211],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,227,233],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,228,232],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,231],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,197],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,237],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,237],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,237,238,245,246,249,250,251,252],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,237,246],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,237,238,245,246,247,248],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,246],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,246,250],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,237,238,239,244],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,238],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,237,246],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,243],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,240,241,242],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,230],[73,78,119,133,137,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,119,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,128,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,116,119,130,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,98,116,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,128,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,98,119,130,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[66,67,73,78,90,108,119,129,132,157,158,159,161,163,174,175,176,177,178,179,180,181],[66,73,78,131,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,111,119,126,129,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,149,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,127,128,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,127,128,129,130,131,132,133,134,135,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,133,140,141,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,131,133,141,142,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,132,157,158,159,161,163,174,175,176,177,178,179,180,181],[66,73,78,128,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,133,137,141,142,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,137,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,119,131,133,136,157,158,159,161,163,174,175,176,177,178,179,180,181],[66,73,78,130,131,133,137,140,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,124,126,128,133,149,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,184],[73,78,83,91,93,116,120,124,156,157,158,159,160,163,164,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,177,178,179,180,181],[73,78,157,158,159,161,174,175,176,177,178,179,180,181],[73,78,83,101,108,111,116,120,124,156,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,157,158,159,161,162,163,164,165,166,167,173,174,175,176,177,178,179,180,181,182,183],[8,73,74,78,81,83,91,92,99,111,116,119,125,157,158,159,161,163,174,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,178,179,180,181],[73,78,91,157,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180],[73,78,157,158,159,161,163,174,175,176,177,178,180,181],[73,78,157,158,159,161,163,174,175,176,177,179,180,181],[73,78,157,158,159,161,163,167,174,175,176,177,178,179,181],[73,78,157,158,159,161,163,172,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,168,169,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,168,169,170,171,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,168,170,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,168,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,175,176,177,178,179,180,181],[62,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[49,53,56,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[49,53,55,62,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[49,53,62,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[49,53,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[56,57,58,59,60,61,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[63,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181]],"referencedMap":[[189,1],[187,2],[209,3],[227,2],[230,4],[229,2],[47,2],[51,5],[50,6],[52,6],[53,7],[54,2],[55,8],[48,2],[49,9],[186,2],[192,10],[188,1],[190,11],[191,1],[194,12],[195,13],[196,14],[203,15],[193,16],[204,17],[212,18],[208,19],[207,20],[205,2],[202,21],[216,22],[215,21],[218,23],[219,24],[221,25],[222,2],[213,2],[223,26],[224,2],[225,27],[226,28],[235,29],[255,30],[256,31],[206,2],[257,2],[258,25],[259,2],[217,2],[260,2],[261,17],[75,32],[76,32],[77,33],[78,34],[79,35],[80,36],[68,2],[71,37],[69,2],[70,2],[81,38],[82,39],[83,40],[84,41],[85,42],[86,43],[87,43],[89,2],[88,44],[90,45],[91,46],[92,47],[74,48],[93,49],[94,50],[95,51],[96,52],[97,53],[98,54],[99,55],[100,56],[101,57],[102,58],[103,59],[104,60],[105,61],[106,61],[107,62],[108,63],[110,64],[109,65],[111,66],[112,67],[113,68],[114,69],[115,70],[116,71],[117,72],[73,73],[72,2],[126,74],[118,75],[119,76],[120,77],[121,78],[122,79],[123,80],[124,81],[125,82],[262,2],[263,2],[264,2],[200,2],[201,2],[268,83],[265,2],[267,84],[269,2],[199,85],[270,86],[214,87],[271,16],[272,2],[274,88],[273,2],[254,2],[220,2],[275,89],[276,2],[277,90],[65,2],[228,2],[266,2],[211,91],[210,92],[234,93],[233,94],[232,95],[197,2],[198,96],[238,97],[252,98],[236,2],[237,99],[253,100],[248,101],[249,102],[247,103],[251,104],[245,105],[239,106],[250,107],[246,98],[244,108],[242,2],[243,109],[240,2],[241,2],[231,110],[45,2],[46,2],[8,2],[9,2],[11,2],[10,2],[2,2],[12,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[3,2],[20,2],[4,2],[21,2],[25,2],[22,2],[23,2],[24,2],[26,2],[27,2],[28,2],[5,2],[29,2],[30,2],[31,2],[32,2],[6,2],[36,2],[33,2],[34,2],[35,2],[37,2],[7,2],[38,2],[43,2],[44,2],[39,2],[40,2],[41,2],[42,2],[1,2],[140,111],[147,112],[139,111],[154,113],[131,114],[130,115],[153,17],[148,116],[151,117],[133,118],[132,119],[128,120],[127,17],[150,121],[129,122],[134,123],[135,2],[138,123],[66,2],[156,124],[155,123],[142,125],[143,126],[145,127],[141,128],[144,129],[149,17],[136,130],[137,131],[146,132],[67,133],[152,134],[185,135],[161,136],[183,2],[182,2],[176,137],[163,138],[162,2],[159,48],[164,2],[157,139],[165,2],[184,140],[166,2],[160,2],[175,141],[177,142],[158,143],[181,144],[179,145],[178,146],[180,147],[167,2],[173,148],[170,149],[172,150],[171,151],[169,152],[168,2],[174,153],[63,154],[57,155],[56,156],[58,157],[61,158],[59,157],[60,157],[62,159],[64,160]]},"version":"5.5.4"}
|
|
1
|
+
{"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/Asset.d.ts","../../../../node_modules/@sundaeswap/fraction/dist/types/Fraction.d.ts","../../../../node_modules/@sundaeswap/fraction/dist/types/index.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/AssetRatio.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/AssetAmount.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/TokenBundle.d.ts","../../../../node_modules/@sundaeswap/asset/dist/types/index.d.ts","../../../../node_modules/@sundaeswap/bigint-math/dist/types/BigIntMath.d.ts","../../../../node_modules/@sundaeswap/bigint-math/dist/types/index.d.ts","../../src/PoolMath/ConstantProductPool.ts","../../src/PoolMath/ConcentratedLiquidityPool.ts","../../src/PoolMath/ConstantSumPool.ts","../../src/PoolMath/StableSwapsPool.ts","../../src/PoolMath/V4StableswapPool.ts","../../src/PoolMath/SharedPoolMath.ts","../../src/PoolMath/index.ts","../../src/@types/index.ts","../../src/index.ts","../../../../node_modules/buffer/index.d.ts","../../../../node_modules/undici-types/header.d.ts","../../../../node_modules/undici-types/readable.d.ts","../../../../node_modules/@types/node/compatibility/disposable.d.ts","../../../../node_modules/@types/node/compatibility/indexable.d.ts","../../../../node_modules/@types/node/compatibility/iterators.d.ts","../../../../node_modules/@types/node/compatibility/index.d.ts","../../../../node_modules/@types/node/ts5.6/globals.typedarray.d.ts","../../../../node_modules/@types/node/ts5.6/buffer.buffer.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/dom-events.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/readline/promises.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/stream/consumers.d.ts","../../../../node_modules/@types/node/stream/web.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/test.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/ts5.6/index.d.ts","../../../../node_modules/undici-types/file.d.ts","../../../../node_modules/undici-types/fetch.d.ts","../../../../node_modules/undici-types/formdata.d.ts","../../../../node_modules/undici-types/connector.d.ts","../../../../node_modules/undici-types/client.d.ts","../../../../node_modules/undici-types/errors.d.ts","../../../../node_modules/undici-types/dispatcher.d.ts","../../../../node_modules/undici-types/global-dispatcher.d.ts","../../../../node_modules/undici-types/global-origin.d.ts","../../../../node_modules/undici-types/pool-stats.d.ts","../../../../node_modules/undici-types/pool.d.ts","../../../../node_modules/undici-types/handlers.d.ts","../../../../node_modules/undici-types/balanced-pool.d.ts","../../../../node_modules/undici-types/agent.d.ts","../../../../node_modules/undici-types/mock-interceptor.d.ts","../../../../node_modules/undici-types/mock-agent.d.ts","../../../../node_modules/undici-types/mock-client.d.ts","../../../../node_modules/undici-types/mock-pool.d.ts","../../../../node_modules/undici-types/mock-errors.d.ts","../../../../node_modules/undici-types/proxy-agent.d.ts","../../../../node_modules/undici-types/api.d.ts","../../../../node_modules/undici-types/cookies.d.ts","../../../../node_modules/undici-types/patch.d.ts","../../../../node_modules/undici-types/filereader.d.ts","../../../../node_modules/undici-types/diagnostics-channel.d.ts","../../../../node_modules/undici-types/websocket.d.ts","../../../../node_modules/undici-types/content-type.d.ts","../../../../node_modules/undici-types/cache.d.ts","../../../../node_modules/undici-types/interceptors.d.ts","../../../../node_modules/undici-types/index.d.ts","../../node_modules/@types/bun/node_modules/bun-types/globals.d.ts","../../node_modules/@types/bun/node_modules/bun-types/s3.d.ts","../../node_modules/@types/bun/node_modules/bun-types/fetch.d.ts","../../node_modules/@types/bun/node_modules/bun-types/jsx.d.ts","../../node_modules/@types/bun/node_modules/bun-types/bun.d.ts","../../node_modules/@types/bun/node_modules/bun-types/extensions.d.ts","../../node_modules/@types/bun/node_modules/bun-types/devserver.d.ts","../../node_modules/@types/bun/node_modules/bun-types/ffi.d.ts","../../node_modules/@types/bun/node_modules/bun-types/html-rewriter.d.ts","../../node_modules/@types/bun/node_modules/bun-types/jsc.d.ts","../../node_modules/@types/bun/node_modules/bun-types/sqlite.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/utils.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/overloads.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/branding.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/messages.d.ts","../../node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/index.d.ts","../../node_modules/@types/bun/node_modules/bun-types/test.d.ts","../../node_modules/@types/bun/node_modules/bun-types/wasm.d.ts","../../node_modules/@types/bun/node_modules/bun-types/overrides.d.ts","../../node_modules/@types/bun/node_modules/bun-types/deprecated.d.ts","../../node_modules/@types/bun/node_modules/bun-types/redis.d.ts","../../node_modules/@types/bun/node_modules/bun-types/shell.d.ts","../../node_modules/@types/bun/node_modules/bun-types/serve.d.ts","../../node_modules/@types/bun/node_modules/bun-types/sql.d.ts","../../node_modules/@types/bun/node_modules/bun-types/security.d.ts","../../node_modules/@types/bun/node_modules/bun-types/bundle.d.ts","../../node_modules/@types/bun/node_modules/bun-types/bun.ns.d.ts","../../node_modules/@types/bun/node_modules/bun-types/index.d.ts","../../node_modules/@types/bun/index.d.ts","../../../../node_modules/@types/aria-query/index.d.ts","../../../../node_modules/@babel/types/lib/index.d.ts","../../../../node_modules/@types/babel__generator/index.d.ts","../../../../node_modules/@babel/parser/typings/babel-parser.d.ts","../../../../node_modules/@types/babel__template/index.d.ts","../../../../node_modules/@types/babel__traverse/index.d.ts","../../../../node_modules/@types/babel__core/index.d.ts","../../../../node_modules/@types/connect/index.d.ts","../../../../node_modules/@types/body-parser/index.d.ts","../../../../node_modules/@types/bonjour/index.d.ts","../../../../node_modules/@types/cli-progress/index.d.ts","../../../../node_modules/mime/dist/src/Mime.d.ts","../../../../node_modules/mime/dist/src/index.d.ts","../../../../node_modules/@types/send/index.d.ts","../../../../node_modules/@types/qs/index.d.ts","../../../../node_modules/@types/range-parser/index.d.ts","../../../../node_modules/@types/express-serve-static-core/index.d.ts","../../../../node_modules/@types/connect-history-api-fallback/index.d.ts","../../../../node_modules/@types/dns-packet/index.d.ts","../../../../node_modules/@types/estree/index.d.ts","../../../../node_modules/@types/json-schema/index.d.ts","../../../../node_modules/@types/eslint/use-at-your-own-risk.d.ts","../../../../node_modules/@types/eslint/index.d.ts","../../../../node_modules/@eslint/core/dist/esm/types.d.ts","../../../../node_modules/eslint/lib/types/use-at-your-own-risk.d.ts","../../../../node_modules/eslint/lib/types/index.d.ts","../../../../node_modules/@types/eslint-scope/index.d.ts","../../../../node_modules/@types/http-errors/index.d.ts","../../../../node_modules/@types/serve-static/index.d.ts","../../../../node_modules/@types/express/node_modules/@types/express-serve-static-core/index.d.ts","../../../../node_modules/@types/express/index.d.ts","../../../../node_modules/@types/minimatch/index.d.ts","../../../../node_modules/@types/glob/index.d.ts","../../../../node_modules/@types/graceful-fs/index.d.ts","../../../../node_modules/@types/unist/index.d.ts","../../../../node_modules/@types/hast/index.d.ts","../../../../node_modules/@types/html-minifier-terser/index.d.ts","../../../../node_modules/@types/http-proxy/index.d.ts","../../../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../../../node_modules/@types/istanbul-lib-report/index.d.ts","../../../../node_modules/@types/istanbul-reports/index.d.ts","../../../../node_modules/@jest/expect-utils/build/index.d.ts","../../../../node_modules/chalk/index.d.ts","../../../../node_modules/@jest/schemas/node_modules/@sinclair/typebox/typebox.d.ts","../../../../node_modules/@jest/schemas/build/index.d.ts","../../../../node_modules/pretty-format/build/index.d.ts","../../../../node_modules/jest-matcher-utils/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/jest-matcher-utils/build/index.d.ts","../../../../node_modules/expect/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts","../../../../node_modules/parse5/dist/common/html.d.ts","../../../../node_modules/parse5/dist/common/token.d.ts","../../../../node_modules/parse5/dist/common/error-codes.d.ts","../../../../node_modules/parse5/dist/tokenizer/preprocessor.d.ts","../../../../node_modules/parse5/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts","../../../../node_modules/parse5/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts","../../../../node_modules/parse5/node_modules/entities/dist/commonjs/decode-codepoint.d.ts","../../../../node_modules/parse5/node_modules/entities/dist/commonjs/decode.d.ts","../../../../node_modules/parse5/node_modules/entities/decode.d.ts","../../../../node_modules/parse5/dist/tokenizer/index.d.ts","../../../../node_modules/parse5/dist/tree-adapters/interface.d.ts","../../../../node_modules/parse5/dist/parser/open-element-stack.d.ts","../../../../node_modules/parse5/dist/parser/formatting-element-list.d.ts","../../../../node_modules/parse5/dist/parser/index.d.ts","../../../../node_modules/parse5/dist/tree-adapters/default.d.ts","../../../../node_modules/parse5/dist/serializer/index.d.ts","../../../../node_modules/parse5/dist/common/foreign-content.d.ts","../../../../node_modules/parse5/dist/index.d.ts","../../../../node_modules/@types/tough-cookie/index.d.ts","../../../../node_modules/@types/jsdom/base.d.ts","../../../../node_modules/@types/jsdom/index.d.ts","../../../../node_modules/@types/json5/index.d.ts","../../../../node_modules/@types/mdast/index.d.ts","../../../../node_modules/@types/mime/index.d.ts","../../../../node_modules/@types/minimist/index.d.ts","../../../../node_modules/@types/node-forge/index.d.ts","../../../../node_modules/@types/normalize-package-data/index.d.ts","../../../../node_modules/@types/parse-json/index.d.ts","../../../../node_modules/@types/prop-types/index.d.ts","../../../../node_modules/@types/react/global.d.ts","../../../../node_modules/csstype/index.d.ts","../../../../node_modules/@types/react/index.d.ts","../../../../node_modules/@types/react-dom/index.d.ts","../../../../node_modules/@types/retry/index.d.ts","../../../../node_modules/@types/serve-index/index.d.ts","../../../../node_modules/@types/sockjs/index.d.ts","../../../../node_modules/@types/stack-utils/index.d.ts","../../../../node_modules/@types/testing-library__jest-dom/matchers.d.ts","../../../../node_modules/@types/testing-library__jest-dom/index.d.ts","../../../../node_modules/@types/ws/index.d.ts","../../../../node_modules/@types/yargs-parser/index.d.ts","../../../../node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"44e584d4f6444f58791784f1d530875970993129442a847597db702a073ca68c","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4",{"version":"4af6b0c727b7a2896463d512fafd23634229adf69ac7c00e2ae15a09cb084fad","affectsGlobalScope":true},{"version":"9c00a480825408b6a24c63c1b71362232927247595d7c97659bc24dc68ae0757","affectsGlobalScope":true},{"version":"6920e1448680767498a0b77c6a00a8e77d14d62c3da8967b171f1ddffa3c18e4","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true},{"version":"ae37d6ccd1560b0203ab88d46987393adaaa78c919e51acf32fb82c86502e98c","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"479553e3779be7d4f68e9f40cdb82d038e5ef7592010100410723ceced22a0f7","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"51c956a7c738d7f4fd20eec47a375a8cb710ea54f82fb0ad03d787fb12657d92","68c52be545faa567bbb3568f7bdfe6cce70e2715c9c13a61849f86aea5a9ebbd","e9a73f3b07707e735d5a85fc8edd642c907efe342e9ce6f1e96102965dc3ba89","b34f125d24f666b3146a2aa7075fb5c75248fe05bb035be9c3acf408c084790e","de495af61b69bc716de329ae92128b85d1adb1a412ec2b18bdc09e1e2408c3d7","fe0d90c26b19d8f79ccc69c68f0facfd3dc808c3dc19fcd452cf30cb199a7a8e","6257871c4fc4701fb42d4136f5bc86529c97a9abb1d0fc7babbef91b6f1942f2","910f330ba93ef8eb90baabbc6ed0b12ad8d9b27dc841aa95dfb2799643c41045","874a1013a9dab7c69706b58b35e85658ab0b284b834b2dc3af8906f534ad79ae",{"version":"6349b914e11d35e0838992e22a0d5a91f45cbfeb571cb258efa226fe3c4dc70d","signature":"9d84cdf64851b02a22b32f27b4b6fc80070be07433427d8d68f1400257e5bd9d"},{"version":"849251b4ef64a785515ce9117df1c5a5786ff46e1b6c9a4f57e525c61a553447","signature":"4b89c87ec616b0e3b467d2a3da543888142af07e2cfd46b7cf52ee685341ff04"},{"version":"bb11d6e02857ebea041f90fc2fbd1a7c455ca41aad407c91718ef685d8408ef4","signature":"adfbddda72c24b22754e0e37019c4f5554883f7ebf42bf3e857eb954c6054ad1"},{"version":"1ba6f71642976f30985558ca17b25fc061ba78457ad8e214abb496734901c533","signature":"4e71cf665be23fcf29713ce4404b9f866b8ed74fdbfdf2cac77db2f6092885ee"},{"version":"56bfbd9f72d74aeb06d59e8ec4b17eb75aedf11ad5d097a4101a06083e1df5c9","signature":"0e906d5f05e64af0be85ff811ed8a9a1077abe71fa2b5c2458cc083bde933406"},{"version":"66acaaa1d369f8beb3eeb99ecda57f318b28005caee5405fe8da1cbca2727e26","signature":"7b311aa1193ba30b6beb6bca85a137af8410bbab82bee6d78b58397e0a64f728"},"d85da46b692d6705d368ae658e036853c55d4a3900067744f572a73d8b7a6bd0","d505dd3248a004e125aedacd78ac294598ac676ff103c532d35de6355ebf2786","7fc64678c4e3e69edf0add713b86c4f2ae254ea12ded16a99366142b29dda7b3","4967529644e391115ca5592184d4b63980569adf60ee685f968fd59ab1557188","5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","7180c03fd3cb6e22f911ce9ba0f8a7008b1a6ddbe88ccf16a9c8140ef9ac1686",{"version":"6c7176368037af28cb72f2392010fa1cef295d6d6744bca8cfb54985f3a18c3e","affectsGlobalScope":true},{"version":"ab41ef1f2cdafb8df48be20cd969d875602483859dc194e9c97c8a576892c052","affectsGlobalScope":true},{"version":"437e20f2ba32abaeb7985e0afe0002de1917bc74e949ba585e49feba65da6ca1","affectsGlobalScope":true},"21d819c173c0cf7cc3ce57c3276e77fd9a8a01d35a06ad87158781515c9a438a",{"version":"613b21ccdf3be6329d56e6caa13b258c842edf8377be7bc9f014ed14cdcfc308","affectsGlobalScope":true},{"version":"d2662405c15ec112ebc0c3ec787edb82d58d6acb1a9d109317d7bf9cff9d09a7","affectsGlobalScope":true},{"version":"1a2e588ce04b57f262959afb54933563431bf75304cfda6165703fe08f4018c5","affectsGlobalScope":true},"c775b106d611ae2c068ed8429a132608d10007918941311214892dcd4a571ad7","7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","75eb536b960b85f75e21490beeab53ea616646a995ad203e1af532d67a774fb6",{"version":"36d0976d3dad74078f707af107b5082dbe42ffcadb3442ff140c36c8a33b4887","affectsGlobalScope":true},"51bb58ef3a22fdc49a2d338a852050855d1507f918d4d7fa77a68d72fee9f780","7646ad748a9ca15bf43d4c88f83cc851c67f8ec9c1186295605b59ba6bb36dcb",{"version":"cef8931bc129687165253f0642427c2a72705a4613b3ac461b9fa78c7cdaef32","affectsGlobalScope":true},"5524481e56c48ff486f42926778c0a3cce1cc85dc46683b92b1271865bcf015a","47b62c294beb69daa5879f052e416b02e6518f3e4541ae98adbfb27805dd6711","f8375506002c556ec412c7e2a5a9ece401079ee5d9eb2c1372e9f5377fac56c7","8edd6482bd72eca772f9df15d05c838dd688cdbd4d62690891fca6578cfda6fe","07ba29a1a495b710aea48a4cf19ae12b3cbda2a8e9ac62192af477027a99e8de","6dead64c944504250dd2fc9095231f36887cfc1534f1ff57737c19f92d165c91","b9a4824bb83f25d6d227394db2ed99985308cf2a3a35f0d6d39aa72b15473982",{"version":"6e57c0b7b3d2716fbc0ca28aa23f62bc997ad534d1369f3853dcb9d453d1fb91","affectsGlobalScope":true},{"version":"b84f34005e497dbc0c1948833818cdb38e8c01ff4f88d810b4d70aa2e6c52916","affectsGlobalScope":true},"8e8e284b3832911aeede987e4d74cf0a00f2b03896b2fd3bf924344cc0f96b3c","37d37474a969ab1b91fc332eb6a375885dfd25279624dfa84dea48c9aedf4472","957905d33a09ce85efd84a65819cdd22eefdd64959afacbdcfe5f36b0d7a7bbe","f1a79b6047d006548185e55478837dfbcdd234d6fe51532783f5dffd401cfb2b","565fda33feca88f4b5db23ba8e605da1fd28b6d63292d276bdbd2afe6cd4c490","e822320b448edce0c7ede9cbeada034c72e1f1c8c8281974817030564c63dcb1",{"version":"9d65568cba17c9db40251023406668695ad698ea4a34542364af3e78edd37811","affectsGlobalScope":true},"f23e3d484de54d235bf702072100b541553a1df2550bad691fe84995e15cf7be","821c79b046e40d54a447bebd9307e70b86399a89980a87bbc98114411169e274","17bc38afc78d40b2f54af216c0cc31a4bd0c6897a5945fa39945dfc43260be2c",{"version":"d201b44ff390c220a94fb0ff6a534fe9fa15b44f8a86d0470009cdde3a3e62ab","affectsGlobalScope":true},{"version":"d44445141f204d5672c502a39c1124bcf1df225eba05df0d2957f79122be87b5","affectsGlobalScope":true},"de905bc5f7e7a81cb420e212b95ab5e3ab840f93e0cfa8ce879f6e7fa465d4a2","bc2ff43214898bc6d53cab92fb41b5309efec9cbb59a0650525980aee994de2b","bede3143eeddca3b8ec3592b09d7eb02042f9e195251040c5146eac09b173236","64a40cf4ec8a7a29db2b4bc35f042e5be8537c4be316e5221f40f30ca8ed7051","294c082d609e6523520290db4f1d54114ebc83643fb42abd965be5bcc5d9416b","cf7d740e39bd8adbdc7840ee91bef0af489052f6467edfcefb7197921757ec3b","37ba7b45141a45ce6e80e66f2a96c8a5ab1bcef0fc2d0f56bb58df96ec67e972","125d792ec6c0c0f657d758055c494301cc5fdb327d9d9d5960b3f129aff76093",{"version":"b9f0681c4d2cb00a5cfe08a7be9662627b912de562926819ebddfe2ef6a9b5ee","affectsGlobalScope":true},"b85151402164ab7cb665e58df5c1a29aa25ea4ed3a367f84a15589e7d7a9c8ca","89eb8abe2b5c146fbb8f3bf72f4e91de3541f2fb559ad5fed4ad5bf223a3dedb",{"version":"bc6cb10764a82f3025c0f4822b8ad711c16d1a5c75789be2d188d553b69b2d48","affectsGlobalScope":true},"41d510caf7ed692923cb6ef5932dc9cf1ed0f57de8eb518c5bab8358a21af674","2751c5a6b9054b61c9b03b3770b2d39b1327564672b63e3485ac03ffeb28b4f6","dc058956a93388aab38307b7b3b9b6379e1021e73a244aab6ac9427dc3a252a7","f33302cf240672359992c356f2005d395b559e176196d03f31a28cc7b01e69bc",{"version":"3ce25041ff6ae06c08fcaccd5fcd9baf4ca6e80e6cb5a922773a1985672e74c2","affectsGlobalScope":true},{"version":"652c0de14329a834ff06af6ad44670fac35849654a464fd9ae36edb92a362c12","affectsGlobalScope":true},"3b1e178016d3fc554505ae087c249b205b1c50624d482c542be9d4682bab81fc","5db7c5bb02ef47aaaec6d262d50c4e9355c80937d649365c343fa5e84569621d","cf45d0510b661f1da461479851ff902f188edb111777c37055eff12fa986a23a",{"version":"ec9a5f06328f61e09f44d6781d1bd862475f9900c16cef82621a46305def3c4d","affectsGlobalScope":true},"37bef1064b7d015aeaa7c0716fe23a0b3844abe2c0a3df7144153ca8445fe0da","75bd411256302c183207051fd198b4e0dbab45d28a6daf04d3ad61f70a2c8e90","25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","54cb85a47d760da1c13c00add10d26b5118280d44d58e6908d8e89abbd9d7725","3e4825171442666d31c845aeb47fcd34b62e14041bb353ae2b874285d78482aa","c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","a967bfe3ad4e62243eb604bf956101e4c740f5921277c60debaf325c1320bf88","e9775e97ac4877aebf963a0289c81abe76d1ec9a2a7778dbe637e5151f25c5f3","471e1da5a78350bc55ef8cef24eb3aca6174143c281b8b214ca2beda51f5e04a","cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","db3435f3525cd785bf21ec6769bf8da7e8a776be1a99e2e7efb5f244a2ef5fee","c3b170c45fc031db31f782e612adf7314b167e60439d304b49e704010e7bafe5","40383ebef22b943d503c6ce2cb2e060282936b952a01bea5f9f493d5fb487cc7","4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","3a84b7cb891141824bd00ef8a50b6a44596aded4075da937f180c90e362fe5f6","13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","33203609eba548914dc83ddf6cadbc0bcb6e8ef89f6d648ca0908ae887f9fcc5","0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","9f0a92164925aa37d4a5d9dd3e0134cff8177208dba55fd2310cd74beea40ee2","8bfdb79bf1a9d435ec48d9372dc93291161f152c0865b81fc0b2694aedb4578d","2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","d32275be3546f252e3ad33976caf8c5e842c09cb87d468cb40d5f4cf092d1acc","4a0c3504813a3289f7fb1115db13967c8e004aa8e4f8a9021b95285502221bd1",{"version":"065abdf835a1f02c09c61784b9fe28a0896ad1cafb5d522a05c229dffc87fb68","affectsGlobalScope":true},"9d6d1979f27b9e189b8ea90f553b345617eebf94b0fa6bfe4162f25ba6571a10","f2071e0794d585da33e5012483c573508a512b6182ace2117563b3bd85c05aac","013b7fcfa5f1dcc7038cf9287de6d558ed0b76fd20b633f936c10d6764767ed9","2089ccdcdfb5b2ffe365a797387a024cd69146c4ea271fa6d2b6e2079ca5c8e9","b1e2ccc111f0f8313f9f50bbc637564299ac19a1f76b60e51ec07e3d7d9d3792",{"version":"4fd5357366c4bfe2dd8f3d91b2e494664d97af113f31c06ed16ac76be3068e61","affectsGlobalScope":true},"c3de319ca5807d77da32720161f4f6d4d73bafe3336ba64d4018ec598d0e10fe",{"version":"7caed84a09eae11ca7d226cbbc5f5a2e2e13d63246a01689134afeefb9a34b22","affectsGlobalScope":true},"21e5d6be35f291ba44c60285104664cd5a5212d36ccbcd8e975956c63f78288d","c37491db3d2b7ecec7e833ba6505b965b7bdc1dfbad1528d9c9f22095fe66f86","ffd344731abee98a0a85a735b19052817afd2156d97d1410819cd9bcd1bd575e","475e07c959f4766f90678425b45cf58ac9b95e50de78367759c1e5118e85d5c3","a524ae401b30a1b0814f1bbcdae459da97fa30ae6e22476e506bb3f82e3d9456","7375e803c033425e27cb33bae21917c106cb37b508fd242cccd978ef2ee244c7","eeb890c7e9218afdad2f30ad8a76b0b0b5161d11ce13b6723879de408e6bc47a","66cdd559b95aa1df7ba823b45b9a0a028c49430a829c5da495865dd49c54a782",{"version":"8fedbe5fb23749a10cbbd027edaa2f0a166fb802fcd65569a2119946199defbe","affectsGlobalScope":true},{"version":"c2d7a7dfeccad92ee791fb3d8529f523ebd387b368e7f1e35cb9f4e64de0add9","affectsGlobalScope":true},{"version":"49692ced244928bc4b99fbf26845355090500e5269fd26961f21c75eb36703c1","affectsGlobalScope":true},"6b7cfa9f3344d855361d9ef05b2b6a4ae3f782afb68eaeaf63151d6169a43704","610a869934b3c2cab2878309cf9e2d9ca1307af2f543c7b6e3bb8b868f76a149","902c11d8c36e16a0e7db09db0c2112731055595800977c9370042cdf646a0e7b","9ae72ea9b6e33001dbe932bc3b8c6566601eb0b5f7c262998c9c68f4c121986e","2148d39e8c3743a569fbbd30ac76dabac2c74d0da98cf6e4fef43d3ecbbe7da9","e2d2bec3a0414b0be4b9fc3c8d072e77f3950556988fa1e4095092a351f18eeb",{"version":"c8109fe76467db6e801d0edfbc50e6826934686467c9418ce6b246232ce7f109","affectsGlobalScope":true},{"version":"e6f803e4e45915d58e721c04ec17830c6e6678d1e3e00e28edf3d52720909cea","affectsGlobalScope":true},"37be812b06e518320ba82e2aff3ac2ca37370a9df917db708f081b9043fa3315","ae77d81a5541a8abb938a0efedf9ac4bea36fb3a24cc28cfa11c598863aba571","a28ac3e717907284b3910b8e9b3f9844a4e0b0a861bea7b923e5adf90f620330","b6d03c9cfe2cf0ba4c673c209fcd7c46c815b2619fd2aad59fc4229aaef2ed43","82e5a50e17833a10eb091923b7e429dc846d42f1c6161eb6beeb964288d98a15","670a76db379b27c8ff42f1ba927828a22862e2ab0b0908e38b671f0e912cc5ed","13b77ab19ef7aadd86a1e54f2f08ea23a6d74e102909e3c00d31f231ed040f62","069bebfee29864e3955378107e243508b163e77ab10de6a5ee03ae06939f0bb9","104c67f0da1bdf0d94865419247e20eded83ce7f9911a1aa75fc675c077ca66e","cc0d0b339f31ce0ab3b7a5b714d8e578ce698f1e13d7f8c60bfb766baeb1d35c","f9e22729fa06ed20f8b1fe60670b7c74933fdfd44d869ddfb1919c15a5cf12fb","c0e5b4df115963b8a8dcd5b56ff9dc046ddec110de138dba29b00e2b02fa03a9","0ae65c3e977c81f6e46ae9028ae97fc75c78c70f4d6d5f961a8af60301145af6","b1a6683b821c624d63d887dbdd9f34aebb9de586acf87bbf50cb16f5ec2c36c7","b78cd10245a90e27e62d0558564f5d9a16576294eee724a59ae21b91f9269e4a","baac9896d29bcc55391d769e408ff400d61273d832dd500f21de766205255acb","2f5747b1508ccf83fad0c251ba1e5da2f5a30b78b09ffa1cfaf633045160afed",{"version":"a8932b7a5ef936687cc5b2492b525e2ad5e7ed321becfea4a17d5a6c80f49e92","affectsGlobalScope":true},"689be50b735f145624c6f391042155ae2ff6b90a93bac11ca5712bc866f6010c","bc222163edcb8df6ba9b506d053d6c5afcae50e85695151cf4636a3107deaba9","151ff381ef9ff8da2da9b9663ebf657eac35c4c9a19183420c05728f31a6761d","f3d8c757e148ad968f0d98697987db363070abada5f503da3c06aefd9d4248c1","a4a39b5714adfcadd3bbea6698ca2e942606d833bde62ad5fb6ec55f5e438ff8","bbc1d029093135d7d9bfa4b38cbf8761db505026cc458b5e9c8b74f4000e5e75","851fe8b694793c8e4c48c154847712e940694e960e33ac68b73e94557d6aff8d","8a190298d0ff502ad1c7294ba6b0abb3a290fc905b3a00603016a97c363a4c7a","ed1441df2b8bbbd907f603490cb207f44141fe191b20be2f270e8de69bfa194a","1f68ab0e055994eb337b67aa87d2a15e0200951e9664959b3866ee6f6b11a0fe","b71c603a539078a5e3a039b20f2b0a0d1708967530cf97dec8850a9ca45baa2b","0e13570a7e86c6d83dd92e81758a930f63747483e2cd34ef36fcdb47d1f9726a",{"version":"a45c25e77c911c1f2a04cade78f6f42b4d7d896a3882d4e226efd3a3fcd5f2c4","affectsGlobalScope":true},"5c45abf1e13e4463eacfd5dedda06855da8748a6a6cb3334f582b52e219acc04","8841e2aa774b89bd23302dede20663306dc1b9902431ac64b24be8b8d0e3f649","fd326577c62145816fe1acc306c734c2396487f76719d3785d4e825b34540b33","afe73051ff6a03a9565cbd8ebb0e956ee3df5e913ad5c1ded64218aabfa3dcb5","89121c1bf2990f5219bfd802a3e7fc557de447c62058d6af68d6b6348d64499a","79b4369233a12c6fa4a07301ecb7085802c98f3a77cf9ab97eee27e1656f82e6","ee65fe452abe1309389c5f50710f24114e08a302d40708101c4aa950a2a7d044","63786b6f821dee19eb898afb385bd58f1846e6cba593a35edcf9631ace09ba25","035a5df183489c2e22f3cf59fc1ed2b043d27f357eecc0eb8d8e840059d44245","a4809f4d92317535e6b22b01019437030077a76fec1d93b9881c9ed4738fcc54","5f53fa0bd22096d2a78533f94e02c899143b8f0f9891a46965294ee8b91a9434","763e521cf114b80e0dd0e21ca49b9f8ae62e8999555a5e7bade8ce36b33001c2","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","3054ef91b855e005b9c4681399e9d64d2a7b07a22d539314d794f09e53b876a7","ffcc5500e77223169833fc6eb59b3a507944a1f89574e0a1276b0ea7fc22c4a4","22f13de9e2fe5f0f4724797abd3d34a1cdd6e47ef81fc4933fea3b8bf4ad524b","e3ba509d3dce019b3190ceb2f3fc88e2610ab717122dabd91a9efaa37804040d","cda0cb09b995489b7f4c57f168cd31b83dcbaa7aad49612734fb3c9c73f6e4f2","f72f8428f3c1caa22e9c247d046603b85b442c0dae7b77a7a0bc092c18867cb7",{"version":"195f63105abc03e72b6a176e3e34dfb5ac932b55db378fdc7874b1617e24b465","affectsGlobalScope":true},"19990350fca066265b2c190c9b6cde1229f35002ea2d4df8c9e397e9942f6c89","8fb8fdda477cd7382477ffda92c2bb7d9f7ef583b1aa531eb6b2dc2f0a206c10","66995b0c991b5c5d42eff1d950733f85482c7419f7296ab8952e03718169e379","9863f888da357e35e013ca3465b794a490a198226bd8232c2f81fb44e16ff323","84bc2d80326a83ee4a6e7cba2fd480b86502660770c0e24da96535af597c9f1e","ea27768379b866ee3f5da2419650acdb01125479f7af73580a4bceb25b79e372","598931eeb4362542cae5845f95c5f0e45ac668925a40ce201e244d7fe808e965","da9ef88cde9f715756da642ad80c4cd87a987f465d325462d6bc2a0b11d202c8","9462ab013df86c16a2a69ca0a3b6f31d4fd86dd29a947e14b590eb20806f220b","b4c6184d78303b0816e779a48bef779b15aea4a66028eb819aac0abee8407dea","db085d2171d48938a99e851dafe0e486dce9859e5dfa73c21de5ed3d4d6fb0c5","62a3ad1ddd1f5974b3bf105680b3e09420f2230711d6520a521fab2be1a32838","a77be6fc44c876bc10c897107f84eaba10790913ebdcad40fcda7e47469b2160","06cf55b6da5cef54eaaf51cdc3d4e5ebf16adfdd9ebd20cec7fe719be9ced017","91f5dbcdb25d145a56cffe957ec665256827892d779ef108eb2f3864faff523b","052ba354bab8fb943e0bc05a0769f7b81d7c3b3c6cd0f5cfa53c7b2da2a525c5","927955a3de5857e0a1c575ced5a4245e74e6821d720ed213141347dd1870197f","fec804d54cd97dd77e956232fc37dc13f53e160d4bbeeb5489e86eeaa91f7ebd","03c258e060b7da220973f84b89615e4e9850e9b5d30b3a8e4840b3e3268ae8eb","fd0589ca571ad090b531d8c095e26caa53d4825c64d3ff2b2b1ab95d72294175",{"version":"669843ecafb89ae1e944df06360e8966219e4c1c34c0d28aa2503272cdd444a7","affectsGlobalScope":true},"96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538","d4a22007b481fe2a2e6bfd3a42c00cd62d41edb36d30fc4697df2692e9891fc8","d3f2d715f57df3f04bf7b16dde01dec10366f64fce44503c92b8f78f614c1769","fbca5ffaebf282ec3cdac47b0d1d4a138a8b0bb32105251a38acb235087d3318","a39f2a304ccc39e70914e9db08f971d23b862b6f0e34753fad86b895fe566533","22293bd6fa12747929f8dfca3ec1684a3fe08638aa18023dd286ab337e88a592","916be7d770b0ae0406be9486ac12eb9825f21514961dd050594c4b250617d5a8","87d9d29dbc745f182683f63187bf3d53fd8673e5fca38ad5eaab69798ed29fbc",{"version":"eb5b19b86227ace1d29ea4cf81387279d04bb34051e944bc53df69f58914b788","affectsGlobalScope":true},"8a8eb4ebffd85e589a1cc7c178e291626c359543403d58c9cd22b81fab5b1fb9",{"version":"472f5aab7edc498a0a761096e8e254c5bc3323d07a1e7f5f8b8ec0d6395b60a0","affectsGlobalScope":true},"17ed71200119e86ccef2d96b73b02ce8854b76ad6bd21b5021d4269bec527b5f","199f9ead0daf25ae4c5632e3d1f42570af59685294a38123eef457407e13f365","ddef25f825320de051dcb0e62ffce621b41c67712b5b4105740c32fd83f4c449","1b3dffaa4ca8e38ac434856843505af767a614d187fb3a5ef4fcebb023c355aa","ab82804a14454734010dcdcd43f564ff7b0389bee4c5692eec76ff5b30d4cf66","3f36c0c7508302f3dca3dc5ab0a66d822b2222f70c24bb1796ddb5c9d1168a05",{"version":"b23d5b89c465872587e130f427b39458b8e3ad16385f98446e9e86151ba6eb15","affectsGlobalScope":true},"1ba59c8bbeed2cb75b239bb12041582fa3e8ef32f8d0bd0ec802e38442d3f317","bae8d023ef6b23df7da26f51cea44321f95817c190342a36882e93b80d07a960","26a770cec4bd2e7dbba95c6e536390fffe83c6268b78974a93727903b515c4e7"],"root":[63,64],"options":{"allowJs":false,"allowSyntheticDefaultImports":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":99,"outDir":"./","skipLibCheck":true,"strict":true,"target":7},"fileIdsList":[[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,187],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,206],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,229],[47,49,50,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[51,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[47,50,51,52,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[54,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[48,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,187,188,189,190,191],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,187,189],[73,78,93,126,157,158,159,161,163,174,175,176,177,178,179,180,181,193],[73,78,84,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,119,126,157,158,159,161,163,174,175,176,177,178,179,180,181,202],[73,78,93,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,205,211],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,205,206,207],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,208],[73,78,90,93,126,157,158,159,161,163,174,175,176,177,178,179,180,181,199,200,201],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,194,200,202,214,215],[73,78,90,91,126,157,158,159,161,163,174,175,176,177,178,179,180,181,217],[73,78,91,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,220],[73,78,90,93,95,98,108,119,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,224],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,225],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,231,234,274],[73,78,90,122,126,157,158,159,161,163,174,175,176,177,178,179,180,181,253,254,256],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,255],[73,75,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,77,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,83,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,79,90,91,98,108,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,79,80,90,98,157,158,159,161,163,174,175,176,177,178,179,180,181],[68,69,70,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,81,120,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,82,83,91,99,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,83,108,116,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,84,86,90,98,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,77,78,85,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,86,87,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,88,90,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,77,78,90,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,91,92,108,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,91,92,105,108,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,156,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,86,90,93,98,108,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,91,93,94,98,108,116,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,93,95,108,116,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,96,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,97,119,124,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,86,90,98,108,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,99,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,100,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,77,78,101,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,102,118,124,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,103,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,104,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,105,106,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,105,107,120,122,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,108,109,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,110,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,109,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,111,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,112,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,113,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,114,115,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,114,115,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,83,98,108,116,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,117,157,158,159,161,163,174,175,176,177,178,179,180,181],[78,157,158,159,161,163,174,175,176,177,178,179,180,181],[71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,98,118,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,93,104,119,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,83,120,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,121,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,97,122,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,123,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,90,92,101,108,111,119,122,124,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,125,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,267],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,264,265,266],[73,78,91,108,126,157,158,159,161,163,174,175,176,177,178,179,180,181,198],[73,78,91,157,158,159,161,163,174,175,176,177,178,179,180,181,216],[73,78,93,126,157,158,159,161,163,174,175,176,177,178,179,180,181,199,213],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,234,235,273],[73,78,90,93,95,98,108,116,119,125,126,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,276],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,205,206,209,210],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,211],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,227,233],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,228,232],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,231],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,197],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,237],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,237],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,237,238,245,246,249,250,251,252],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,237,246],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,237,238,245,246,247,248],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,246],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,246,250],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,237,238,239,244],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,238],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,236,237,246],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,243],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,240,241,242],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,230],[73,78,119,133,137,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,119,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,128,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,116,119,130,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,98,116,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,128,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,98,119,130,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[66,67,73,78,90,108,119,129,132,157,158,159,161,163,174,175,176,177,178,179,180,181],[66,73,78,131,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,111,119,126,129,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,149,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,127,128,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,127,128,129,130,131,132,133,134,135,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,133,140,141,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,131,133,141,142,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,132,157,158,159,161,163,174,175,176,177,178,179,180,181],[66,73,78,128,133,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,133,137,141,142,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,137,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,119,131,133,136,157,158,159,161,163,174,175,176,177,178,179,180,181],[66,73,78,130,131,133,137,140,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,108,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,124,126,128,133,149,157,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180,181,184],[73,78,83,91,93,116,120,124,156,157,158,159,160,163,164,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,177,178,179,180,181],[73,78,157,158,159,161,174,175,176,177,178,179,180,181],[73,78,83,101,108,111,116,120,124,156,158,159,161,163,174,175,176,177,178,179,180,181],[73,78,126,157,158,159,161,162,163,164,165,166,167,173,174,175,176,177,178,179,180,181,182,183],[8,73,74,78,81,83,91,92,99,111,116,119,125,157,158,159,161,163,174,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,178,179,180,181],[73,78,91,157,159,161,163,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,174,175,176,177,178,179,180],[73,78,157,158,159,161,163,174,175,176,177,178,180,181],[73,78,157,158,159,161,163,174,175,176,177,179,180,181],[73,78,157,158,159,161,163,167,174,175,176,177,178,179,181],[73,78,157,158,159,161,163,172,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,168,169,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,168,169,170,171,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,168,170,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,168,174,175,176,177,178,179,180,181],[73,78,157,158,159,161,163,175,176,177,178,179,180,181],[62,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[49,53,56,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[49,53,55,62,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[49,53,62,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[49,53,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[56,57,58,59,60,61,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181],[63,73,78,157,158,159,161,163,174,175,176,177,178,179,180,181]],"referencedMap":[[189,1],[187,2],[209,3],[227,2],[230,4],[229,2],[47,2],[51,5],[50,6],[52,6],[53,7],[54,2],[55,8],[48,2],[49,9],[186,2],[192,10],[188,1],[190,11],[191,1],[194,12],[195,13],[196,14],[203,15],[193,16],[204,17],[212,18],[208,19],[207,20],[205,2],[202,21],[216,22],[215,21],[218,23],[219,24],[221,25],[222,2],[213,2],[223,26],[224,2],[225,27],[226,28],[235,29],[255,30],[256,31],[206,2],[257,2],[258,25],[259,2],[217,2],[260,2],[261,17],[75,32],[76,32],[77,33],[78,34],[79,35],[80,36],[68,2],[71,37],[69,2],[70,2],[81,38],[82,39],[83,40],[84,41],[85,42],[86,43],[87,43],[89,2],[88,44],[90,45],[91,46],[92,47],[74,48],[93,49],[94,50],[95,51],[96,52],[97,53],[98,54],[99,55],[100,56],[101,57],[102,58],[103,59],[104,60],[105,61],[106,61],[107,62],[108,63],[110,64],[109,65],[111,66],[112,67],[113,68],[114,69],[115,70],[116,71],[117,72],[73,73],[72,2],[126,74],[118,75],[119,76],[120,77],[121,78],[122,79],[123,80],[124,81],[125,82],[262,2],[263,2],[264,2],[200,2],[201,2],[268,83],[265,2],[267,84],[269,2],[199,85],[270,86],[214,87],[271,16],[272,2],[274,88],[273,2],[254,2],[220,2],[275,89],[276,2],[277,90],[65,2],[228,2],[266,2],[211,91],[210,92],[234,93],[233,94],[232,95],[197,2],[198,96],[238,97],[252,98],[236,2],[237,99],[253,100],[248,101],[249,102],[247,103],[251,104],[245,105],[239,106],[250,107],[246,98],[244,108],[242,2],[243,109],[240,2],[241,2],[231,110],[45,2],[46,2],[8,2],[9,2],[11,2],[10,2],[2,2],[12,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[3,2],[20,2],[4,2],[21,2],[25,2],[22,2],[23,2],[24,2],[26,2],[27,2],[28,2],[5,2],[29,2],[30,2],[31,2],[32,2],[6,2],[36,2],[33,2],[34,2],[35,2],[37,2],[7,2],[38,2],[43,2],[44,2],[39,2],[40,2],[41,2],[42,2],[1,2],[140,111],[147,112],[139,111],[154,113],[131,114],[130,115],[153,17],[148,116],[151,117],[133,118],[132,119],[128,120],[127,17],[150,121],[129,122],[134,123],[135,2],[138,123],[66,2],[156,124],[155,123],[142,125],[143,126],[145,127],[141,128],[144,129],[149,17],[136,130],[137,131],[146,132],[67,133],[152,134],[185,135],[161,136],[183,2],[182,2],[176,137],[163,138],[162,2],[159,48],[164,2],[157,139],[165,2],[184,140],[166,2],[160,2],[175,141],[177,142],[158,143],[181,144],[179,145],[178,146],[180,147],[167,2],[173,148],[170,149],[172,150],[171,151],[169,152],[168,2],[174,153],[63,154],[57,155],[56,156],[58,157],[61,158],[59,157],[60,157],[62,159],[64,160]]},"version":"5.5.4"}
|
package/package.json
CHANGED
|
@@ -396,32 +396,32 @@ export const getSwapOutput = (
|
|
|
396
396
|
};
|
|
397
397
|
|
|
398
398
|
/**
|
|
399
|
-
*
|
|
400
|
-
*
|
|
399
|
+
* The pool's marginal price as raw units of asset A per raw unit of asset B,
|
|
400
|
+
* |dx/dy| at the current reserves. This is the "ideal" price that swap price
|
|
401
|
+
* impact is measured against.
|
|
401
402
|
*
|
|
402
|
-
*
|
|
403
|
+
* Derived from the Stableswaps invariant 4A(x + y) + D = 4AD + D^3 / (4xy):
|
|
403
404
|
* price = (xpA + (dR * aReserve) / bReserve) / (xpA + dR)
|
|
404
|
-
* where xpA =
|
|
405
|
+
* where xpA = 4 * laf * aReserve and dR = D^3 / (4 * aReserve * bReserve)
|
|
405
406
|
*
|
|
406
407
|
* @param {bigint} aReserve - The current reserve amount of asset A in the pool.
|
|
407
408
|
* @param {bigint} bReserve - The current reserve amount of asset B in the pool.
|
|
408
409
|
* @param {bigint} laf - The linear amplification factor of the pool.
|
|
409
|
-
* @returns {Fraction}
|
|
410
|
+
* @returns {Fraction} Raw A per raw B at the current reserves.
|
|
410
411
|
*/
|
|
411
412
|
export function getPrice(
|
|
412
413
|
aReserve: bigint,
|
|
413
414
|
bReserve: bigint,
|
|
414
415
|
laf: bigint,
|
|
415
416
|
): Fraction {
|
|
416
|
-
// dx_0 / dx_1 only, however can have any number of coins in pool
|
|
417
|
-
const ann = laf * 2n * A_PRECISION;
|
|
418
417
|
const sumInvariant =
|
|
419
418
|
getSumInvariant(laf, aReserve, bReserve) / RESERVE_PRECISION;
|
|
420
419
|
// D / n^n with n = 2
|
|
421
420
|
let dR = sumInvariant / 4n;
|
|
422
421
|
dR = (dR * sumInvariant) / aReserve;
|
|
423
422
|
dR = (dR * sumInvariant) / bReserve;
|
|
424
|
-
|
|
423
|
+
// 4A is the amplification term of the on-chain invariant, A = laf.
|
|
424
|
+
const xpA = 4n * laf * aReserve;
|
|
425
425
|
const p = new Fraction(xpA + (dR * aReserve) / bReserve, xpA + dR);
|
|
426
426
|
return p;
|
|
427
427
|
}
|
|
@@ -103,6 +103,59 @@ describe("getPrice()", () => {
|
|
|
103
103
|
Math.abs(normalCppPrice.toNumber() - 1.0),
|
|
104
104
|
);
|
|
105
105
|
});
|
|
106
|
+
|
|
107
|
+
// |dx/dy| of the on-chain invariant 4A(x + y) + D = 4AD + D^3/(4xy), as an
|
|
108
|
+
// exact rational on the scaled reserves. Independent of getPrice's integer
|
|
109
|
+
// arithmetic, so it pins both the amplification term and the orientation.
|
|
110
|
+
const exactSpot = (aReserve: bigint, bReserve: bigint, laf: bigint) => {
|
|
111
|
+
const d = getSumInvariant(laf, aReserve, bReserve);
|
|
112
|
+
const x = aReserve * RESERVE_PRECISION;
|
|
113
|
+
const y = bReserve * RESERVE_PRECISION;
|
|
114
|
+
const dCubed = d * d * d;
|
|
115
|
+
return new Fraction(
|
|
116
|
+
x * (16n * laf * x * y * y + dCubed),
|
|
117
|
+
y * (16n * laf * x * x * y + dCubed),
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
const relativeError = (actual: Fraction, expected: Fraction) =>
|
|
121
|
+
Math.abs(actual.toNumber() / expected.toNumber() - 1);
|
|
122
|
+
|
|
123
|
+
const offParPools: [bigint, bigint, bigint][] = [
|
|
124
|
+
[250275094796n, 250515678047n, 500n],
|
|
125
|
+
[1_000_000_000n, 1_100_000_000n, 100n],
|
|
126
|
+
[2_000_000_000n, 1_000_000_000n, 50n],
|
|
127
|
+
[5_000_000_000n, 1_000_000_000n, 10n],
|
|
128
|
+
[1_010_000_000n, 990_000_250n, 200n],
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
test.each(offParPools)(
|
|
132
|
+
"matches the derivative of the on-chain invariant (a=%s, b=%s, laf=%s)",
|
|
133
|
+
(aReserve, bReserve, laf) => {
|
|
134
|
+
const price = getPrice(aReserve, bReserve, laf);
|
|
135
|
+
expect(
|
|
136
|
+
relativeError(price, exactSpot(aReserve, bReserve, laf)),
|
|
137
|
+
).toBeLessThan(1e-9);
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
test.each(offParPools)(
|
|
142
|
+
"agrees with a central finite difference of getNewY (a=%s, b=%s, laf=%s)",
|
|
143
|
+
(aReserve, bReserve, laf) => {
|
|
144
|
+
const dA = 1000n;
|
|
145
|
+
const d = getSumInvariant(laf, aReserve, bReserve);
|
|
146
|
+
const lowY = getNewY(aReserve + dA, laf, d);
|
|
147
|
+
const highY = getNewY(aReserve - dA, laf, d);
|
|
148
|
+
const slope = new Fraction(dA * 2n * RESERVE_PRECISION, highY - lowY);
|
|
149
|
+
expect(
|
|
150
|
+
relativeError(getPrice(aReserve, bReserve, laf), slope),
|
|
151
|
+
).toBeLessThan(1e-9);
|
|
152
|
+
},
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
test("issue #172: preview pool 488fe776 at laf 500", () => {
|
|
156
|
+
const price = getPrice(250275094796n, 250515678047n, 500n);
|
|
157
|
+
expect(price.toNumber()).toBeCloseTo(0.999999040146, 11);
|
|
158
|
+
});
|
|
106
159
|
});
|
|
107
160
|
|
|
108
161
|
describe("getSwapOutput(usdc,)", () => {
|
|
@@ -199,7 +252,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
199
252
|
out: 0n,
|
|
200
253
|
outReserve: [3n, 2n],
|
|
201
254
|
lpFee: 0n,
|
|
202
|
-
impact: new Fraction(0n,
|
|
255
|
+
impact: new Fraction(0n, 1n),
|
|
203
256
|
},
|
|
204
257
|
{
|
|
205
258
|
id: 2,
|
|
@@ -209,7 +262,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
209
262
|
out: 1n,
|
|
210
263
|
outReserve: [3n, 2n],
|
|
211
264
|
lpFee: 0n,
|
|
212
|
-
impact: new Fraction(
|
|
265
|
+
impact: new Fraction(31n, 250000n),
|
|
213
266
|
},
|
|
214
267
|
{
|
|
215
268
|
id: 3,
|
|
@@ -219,7 +272,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
219
272
|
out: 2n,
|
|
220
273
|
outReserve: [102n, 1n],
|
|
221
274
|
lpFee: 0n,
|
|
222
|
-
impact: new Fraction(
|
|
275
|
+
impact: new Fraction(490001n, 500000n),
|
|
223
276
|
},
|
|
224
277
|
{
|
|
225
278
|
id: 4,
|
|
@@ -229,7 +282,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
229
282
|
out: 99n,
|
|
230
283
|
outReserve: [102n, 1n],
|
|
231
284
|
lpFee: 0n,
|
|
232
|
-
impact: new Fraction(
|
|
285
|
+
impact: new Fraction(14333n, 100000n),
|
|
233
286
|
},
|
|
234
287
|
{
|
|
235
288
|
id: 5,
|
|
@@ -260,7 +313,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
260
313
|
out: 0n,
|
|
261
314
|
outReserve: [3n, 2n],
|
|
262
315
|
lpFee: 0n,
|
|
263
|
-
impact: new Fraction(0n,
|
|
316
|
+
impact: new Fraction(0n, 1n),
|
|
264
317
|
},
|
|
265
318
|
{
|
|
266
319
|
id: 8,
|
|
@@ -270,7 +323,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
270
323
|
out: 0n,
|
|
271
324
|
outReserve: [3n, 3n],
|
|
272
325
|
lpFee: 1n,
|
|
273
|
-
impact: new Fraction(
|
|
326
|
+
impact: new Fraction(31n, 250000n),
|
|
274
327
|
},
|
|
275
328
|
{
|
|
276
329
|
id: 9,
|
|
@@ -280,7 +333,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
280
333
|
out: 0n,
|
|
281
334
|
outReserve: [3n, 6n],
|
|
282
335
|
lpFee: 1n,
|
|
283
|
-
impact: new Fraction(
|
|
336
|
+
impact: new Fraction(249n, 1000000n),
|
|
284
337
|
},
|
|
285
338
|
{
|
|
286
339
|
id: 10,
|
|
@@ -290,7 +343,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
290
343
|
out: 1n,
|
|
291
344
|
outReserve: [102n, 2n],
|
|
292
345
|
lpFee: 1n,
|
|
293
|
-
impact: new Fraction(
|
|
346
|
+
impact: new Fraction(990001n, 1000000n),
|
|
294
347
|
},
|
|
295
348
|
{
|
|
296
349
|
id: 11,
|
|
@@ -300,7 +353,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
300
353
|
out: 196n,
|
|
301
354
|
outReserve: [202n, 3n],
|
|
302
355
|
lpFee: 1n,
|
|
303
|
-
impact: new Fraction(
|
|
356
|
+
impact: new Fraction(393153n, 1000000n),
|
|
304
357
|
},
|
|
305
358
|
{
|
|
306
359
|
id: 12,
|
|
@@ -332,7 +385,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
332
385
|
out: 2139306697n,
|
|
333
386
|
outReserve: [7044962984n, 670265463643n],
|
|
334
387
|
lpFee: 21829661n,
|
|
335
|
-
impact: new Fraction(
|
|
388
|
+
impact: new Fraction(101761n, 1000000n),
|
|
336
389
|
},
|
|
337
390
|
{
|
|
338
391
|
id: 15,
|
|
@@ -342,7 +395,7 @@ describe("getSwapOutput(usdc,)", () => {
|
|
|
342
395
|
out: 1024031n,
|
|
343
396
|
outReserve: [3696261028076n, 77871392800159n],
|
|
344
397
|
lpFee: 3091n,
|
|
345
|
-
impact: new Fraction(
|
|
398
|
+
impact: new Fraction(6001n, 1000000n),
|
|
346
399
|
},
|
|
347
400
|
] as {
|
|
348
401
|
input: bigint;
|
|
@@ -466,31 +519,31 @@ describe("getSwapInput", () => {
|
|
|
466
519
|
input: 1n,
|
|
467
520
|
reserves: [1n, 2n],
|
|
468
521
|
fee: zeroPct,
|
|
469
|
-
impact: new Fraction(0n,
|
|
522
|
+
impact: new Fraction(0n, 4000n),
|
|
470
523
|
},
|
|
471
524
|
{
|
|
472
525
|
input: 100n,
|
|
473
526
|
reserves: [1n, 2n],
|
|
474
527
|
fee: zeroPct,
|
|
475
|
-
impact: new Fraction(0n,
|
|
528
|
+
impact: new Fraction(0n, 4000n),
|
|
476
529
|
},
|
|
477
530
|
{
|
|
478
531
|
input: 100n,
|
|
479
532
|
reserves: [1n, 100n],
|
|
480
533
|
fee: zeroPct,
|
|
481
|
-
impact: new Fraction(245025n,
|
|
534
|
+
impact: new Fraction(245025n, 643500n),
|
|
482
535
|
},
|
|
483
536
|
{
|
|
484
537
|
input: 100n,
|
|
485
538
|
reserves: [100n, 100n],
|
|
486
539
|
fee: zeroPct,
|
|
487
|
-
impact: new Fraction(
|
|
540
|
+
impact: new Fraction(800400n, 40020000n),
|
|
488
541
|
},
|
|
489
542
|
{
|
|
490
543
|
input: 50n,
|
|
491
544
|
reserves: [100n, 100n],
|
|
492
545
|
fee: zeroPct,
|
|
493
|
-
impact: new Fraction(
|
|
546
|
+
impact: new Fraction(400200n, 20010000n),
|
|
494
547
|
},
|
|
495
548
|
|
|
496
549
|
// Simple boundary cases
|
|
@@ -498,25 +551,25 @@ describe("getSwapInput", () => {
|
|
|
498
551
|
input: 10n,
|
|
499
552
|
reserves: [10n, 30n],
|
|
500
553
|
fee: threePct,
|
|
501
|
-
impact: new Fraction(
|
|
554
|
+
impact: new Fraction(40315n, 400450n),
|
|
502
555
|
},
|
|
503
556
|
{
|
|
504
557
|
input: 100n,
|
|
505
558
|
reserves: [1n, 100n],
|
|
506
559
|
fee: threePct,
|
|
507
|
-
impact: new Fraction(
|
|
560
|
+
impact: new Fraction(257100n, 643500n),
|
|
508
561
|
},
|
|
509
562
|
{
|
|
510
563
|
input: 100n,
|
|
511
564
|
reserves: [100n, 100n],
|
|
512
565
|
fee: threePct,
|
|
513
|
-
impact: new Fraction(
|
|
566
|
+
impact: new Fraction(2001000n, 40020000n),
|
|
514
567
|
},
|
|
515
568
|
{
|
|
516
569
|
input: 50n,
|
|
517
570
|
reserves: [100n, 100n],
|
|
518
571
|
fee: threePct,
|
|
519
|
-
impact: new Fraction(
|
|
572
|
+
impact: new Fraction(1200600n, 20010000n),
|
|
520
573
|
},
|
|
521
574
|
|
|
522
575
|
// // Real world examples
|
|
@@ -524,19 +577,19 @@ describe("getSwapInput", () => {
|
|
|
524
577
|
input: 5n,
|
|
525
578
|
reserves: [84159832107n, 123172010729n],
|
|
526
579
|
fee: fivePct,
|
|
527
|
-
impact: new Fraction(
|
|
580
|
+
impact: new Fraction(337126570533235n, 1684271322211955n),
|
|
528
581
|
},
|
|
529
582
|
{
|
|
530
583
|
input: 100n,
|
|
531
584
|
reserves: [84159832107n, 123172010729n],
|
|
532
585
|
fee: fivePct,
|
|
533
|
-
impact: new Fraction(
|
|
586
|
+
impact: new Fraction(1690738591869500n, 33685426444239100n),
|
|
534
587
|
},
|
|
535
588
|
{
|
|
536
589
|
input: 1291591603n,
|
|
537
590
|
reserves: [5753371381n, 672426600000n],
|
|
538
591
|
fee: onePct,
|
|
539
|
-
impact: new Fraction(
|
|
592
|
+
impact: new Fraction(5112429850089508046677n, 55212615531111655078080n),
|
|
540
593
|
},
|
|
541
594
|
] as {
|
|
542
595
|
input: bigint;
|