@panoptic-eng/sdk 1.0.68 → 1.0.69
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/cow/index.d.ts.map +1 -1
- package/dist/cow/index.js +47 -2
- package/dist/cow/index.js.map +1 -1
- package/dist/{cow-CGgPXhY6.js → cow-BBPknr5W.js} +1 -1
- package/dist/{greeks-CGtgLUyh.js → greeks-DNPP24KL.js} +115 -9
- package/dist/index.d.ts +103 -61
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +161 -62
- package/dist/index.js.map +1 -1
- package/dist/{irm-BDxwCFDm.js → irm-DurYJ0ht.js} +3 -3
- package/dist/panoptic/v2/greeks/index.d.ts +7 -4
- package/dist/panoptic/v2/greeks/index.d.ts.map +1 -1
- package/dist/panoptic/v2/greeks/index.js +74 -7
- package/dist/panoptic/v2/greeks/index.js.map +1 -1
- package/dist/panoptic/v2/index.d.ts +89 -5
- package/dist/panoptic/v2/index.d.ts.map +1 -1
- package/dist/panoptic/v2/index.js +675 -49
- package/dist/panoptic/v2/index.js.map +1 -1
- package/dist/panoptic/v2/react-public.d.ts +80 -6
- package/dist/panoptic/v2/react-public.d.ts.map +1 -1
- package/dist/panoptic/v2/react-public.js +2693 -2457
- package/dist/panoptic/v2/react-public.js.map +1 -1
- package/dist/{rates-BHS-Qiu7.js → rates-B-eRYOTS.js} +39 -3
- package/dist/{router-BW6TqwOO.js → router-ChMhfTqT.js} +969 -39
- package/dist/rpc/index.d.ts +3 -0
- package/dist/rpc/index.d.ts.map +1 -1
- package/dist/rpc/index.js +31 -3
- package/dist/rpc/index.js.map +1 -1
- package/dist/uniswap/index.js +53 -13
- package/dist/uniswap/index.js.map +1 -1
- package/dist/{v2-Dgh6JxG_.js → v2-Bo1vZXvR.js} +150 -10
- package/dist/{writes-CG612Vuk.js → writes-D53wWDT-.js} +2 -2
- package/dist/zodiac/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/router-IDtCENST.js +0 -942
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseError, ContractFunctionExecutionError, ContractFunctionRevertedError, ExecutionRevertedError, decodeAbiParameters, decodeErrorResult, decodeEventLog, decodeFunctionData, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, erc20Abi, getAbiItem, getAddress, hexToString, keccak256, parseAbi, parseEventLogs, toFunctionSelector, toHex, trim, zeroAddress } from "viem";
|
|
1
|
+
import { BaseError, ContractFunctionExecutionError, ContractFunctionRevertedError, ExecutionRevertedError, decodeAbiParameters, decodeErrorResult, decodeEventLog, decodeFunctionData, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, erc20Abi, getAbiItem, getAddress, hexToString, isAddress, isAddressEqual, isHex, keccak256, parseAbi, parseEventLogs, toFunctionSelector, toHex, trim, zeroAddress } from "viem";
|
|
2
2
|
import { call, multicall } from "viem/actions";
|
|
3
3
|
import Decimal from "decimal.js";
|
|
4
4
|
|
|
@@ -94,7 +94,7 @@ const UTILIZATION_DENOMINATOR = 10000n;
|
|
|
94
94
|
|
|
95
95
|
//#endregion
|
|
96
96
|
//#region src/panoptic/v2/formatters/tick.ts
|
|
97
|
-
const Q192$
|
|
97
|
+
const Q192$7 = 1n << 192n;
|
|
98
98
|
const RAW_PRICE_PRECISION = 40n;
|
|
99
99
|
function pow10$2(exponent) {
|
|
100
100
|
if (exponent < 0n) throw new RangeError("Exponent must be non-negative");
|
|
@@ -184,7 +184,7 @@ const MAX_SQRT_PRICE_X96 = tickToSqrtPriceX96(MAX_TICK);
|
|
|
184
184
|
function getPriceRatioFromSqrtPriceX96(sqrtPriceX96) {
|
|
185
185
|
return {
|
|
186
186
|
numerator: sqrtPriceX96 * sqrtPriceX96,
|
|
187
|
-
denominator: Q192$
|
|
187
|
+
denominator: Q192$7
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
190
|
function getRawPriceRatio(tick) {
|
|
@@ -586,6 +586,9 @@ var NotMarginCalledError = class extends PanopticError {
|
|
|
586
586
|
*/
|
|
587
587
|
var NotEnoughTokensError = class extends PanopticError {
|
|
588
588
|
name = "NotEnoughTokensError";
|
|
589
|
+
get deficit() {
|
|
590
|
+
return this.assetsRequested > this.assetBalance ? this.assetsRequested - this.assetBalance : 0n;
|
|
591
|
+
}
|
|
589
592
|
constructor(tokenAddress, assetsRequested, assetBalance, cause) {
|
|
590
593
|
super(`Not enough tokens: requested=${assetsRequested}, balance=${assetBalance}, token=${tokenAddress}`, cause);
|
|
591
594
|
this.tokenAddress = tokenAddress;
|
|
@@ -9079,6 +9082,39 @@ const panopticErrorsAbi = [
|
|
|
9079
9082
|
}
|
|
9080
9083
|
]
|
|
9081
9084
|
},
|
|
9085
|
+
{
|
|
9086
|
+
type: "error",
|
|
9087
|
+
name: "NotEnoughTokens",
|
|
9088
|
+
inputs: [
|
|
9089
|
+
{
|
|
9090
|
+
name: "tokenAddress",
|
|
9091
|
+
type: "address"
|
|
9092
|
+
},
|
|
9093
|
+
{
|
|
9094
|
+
name: "account",
|
|
9095
|
+
type: "address"
|
|
9096
|
+
},
|
|
9097
|
+
{
|
|
9098
|
+
name: "assetsRequested",
|
|
9099
|
+
type: "uint256"
|
|
9100
|
+
},
|
|
9101
|
+
{
|
|
9102
|
+
name: "assetBalance",
|
|
9103
|
+
type: "uint256"
|
|
9104
|
+
}
|
|
9105
|
+
]
|
|
9106
|
+
},
|
|
9107
|
+
{
|
|
9108
|
+
type: "error",
|
|
9109
|
+
name: "ExecuteError",
|
|
9110
|
+
inputs: [{
|
|
9111
|
+
name: "callIndex",
|
|
9112
|
+
type: "uint256"
|
|
9113
|
+
}, {
|
|
9114
|
+
name: "revertData",
|
|
9115
|
+
type: "bytes"
|
|
9116
|
+
}]
|
|
9117
|
+
},
|
|
9082
9118
|
{
|
|
9083
9119
|
type: "error",
|
|
9084
9120
|
name: "NotGuardian",
|
|
@@ -9220,7 +9256,7 @@ const errorConstructors = {
|
|
|
9220
9256
|
AccountInsolvent: (args, cause) => new AccountInsolventError(args[0], args[1], cause),
|
|
9221
9257
|
NotMarginCalled: (_args, cause) => new NotMarginCalledError(cause),
|
|
9222
9258
|
CreateFail: (_args, cause) => new CreateFailError(cause),
|
|
9223
|
-
NotEnoughTokens: (args, cause) => new NotEnoughTokensError(args[0], args[1], args[2], cause),
|
|
9259
|
+
NotEnoughTokens: (args, cause) => new NotEnoughTokensError(args[0], args[args.length === 4 ? 2 : 1], args[args.length === 4 ? 3 : 2], cause),
|
|
9224
9260
|
NotEnoughLiquidityInChunk: (_args, cause) => new NotEnoughLiquidityInChunkError(cause),
|
|
9225
9261
|
InsufficientCreditLiquidity: (_args, cause) => new InsufficientCreditLiquidityError(cause),
|
|
9226
9262
|
DepositTooLarge: (_args, cause) => new DepositTooLargeError(cause),
|
|
@@ -10032,7 +10068,7 @@ function hasLoanOrCredit(tokenId) {
|
|
|
10032
10068
|
const POOL_ID_MASK$4 = (1n << 64n) - 1n;
|
|
10033
10069
|
const MAX_LEGS = TOKEN_ID_BITS.MAX_LEGS;
|
|
10034
10070
|
const MAX_OPTION_RATIO = LEG_LIMITS.MAX_RATIO;
|
|
10035
|
-
const Q192$
|
|
10071
|
+
const Q192$6 = 1n << 192n;
|
|
10036
10072
|
/**
|
|
10037
10073
|
* Floor integer square root for bigints (Newton's method). Mirrors the isqrt
|
|
10038
10074
|
* used in reads/collateralEstimate.ts (buildNeutralLeg).
|
|
@@ -10079,7 +10115,7 @@ function computeTinyCreditSignedStrike(positionSize, tickSpacing) {
|
|
|
10079
10115
|
const maxSafe = MAX_TICK - tickSpacing - 1n;
|
|
10080
10116
|
let signedStrike;
|
|
10081
10117
|
try {
|
|
10082
|
-
const sqrtKrawX96 = isqrt$1(TINY_CREDIT_TARGET_NOTIONAL_WEI * Q192$
|
|
10118
|
+
const sqrtKrawX96 = isqrt$1(TINY_CREDIT_TARGET_NOTIONAL_WEI * Q192$6 / positionSize);
|
|
10083
10119
|
signedStrike = sqrtPriceX96ToTick(sqrtKrawX96);
|
|
10084
10120
|
} catch {
|
|
10085
10121
|
signedStrike = minSafe;
|
|
@@ -10951,7 +10987,7 @@ function formatGwei(wei, precision) {
|
|
|
10951
10987
|
//#region src/panoptic/v2/tokenId/generateOverlapping.ts
|
|
10952
10988
|
const MAX_UINT64$2 = (1n << 64n) - 1n;
|
|
10953
10989
|
const MAX_UINT128$4 = (1n << 128n) - 1n;
|
|
10954
|
-
const Q192$
|
|
10990
|
+
const Q192$5 = 1n << 192n;
|
|
10955
10991
|
const MAX_TOKEN_DECIMALS = 255n;
|
|
10956
10992
|
const MAX_DECIMAL_EXPONENT = 512n;
|
|
10957
10993
|
function invalid$1(message) {
|
|
@@ -10997,7 +11033,7 @@ function quotePriceAtTick(tick, asset, assetDecimals, quoteDecimals) {
|
|
|
10997
11033
|
const orientedTick = asset === 0n ? tick : -tick;
|
|
10998
11034
|
const sqrtPriceX96 = tickToSqrtPriceX96(orientedTick);
|
|
10999
11035
|
let numerator = sqrtPriceX96 * sqrtPriceX96;
|
|
11000
|
-
let denominator = Q192$
|
|
11036
|
+
let denominator = Q192$5;
|
|
11001
11037
|
const decimalDifference = assetDecimals - quoteDecimals;
|
|
11002
11038
|
if (decimalDifference > 0n) numerator *= pow10$1(decimalDifference);
|
|
11003
11039
|
else if (decimalDifference < 0n) denominator *= pow10$1(-decimalDifference);
|
|
@@ -11274,7 +11310,7 @@ function splitTokenIdByTimescale(tokenId, positionSize, targetTimescale) {
|
|
|
11274
11310
|
|
|
11275
11311
|
//#endregion
|
|
11276
11312
|
//#region src/uniswap/lpDeposit.ts
|
|
11277
|
-
const Q96$
|
|
11313
|
+
const Q96$5 = 1n << 96n;
|
|
11278
11314
|
const ceilDiv$4 = (n, d) => (n + d - 1n) / d;
|
|
11279
11315
|
/** Principal and separately identified funding headroom, in native token units. */
|
|
11280
11316
|
function getLpDepositBreakdown(ranges, sqrtPriceX96) {
|
|
@@ -11286,8 +11322,8 @@ function getLpDepositBreakdown(ranges, sqrtPriceX96) {
|
|
|
11286
11322
|
const lower = tickToSqrtPriceX96(BigInt(tickLower));
|
|
11287
11323
|
const upper = tickToSqrtPriceX96(BigInt(tickUpper));
|
|
11288
11324
|
const price = sqrtPriceX96 < lower ? lower : sqrtPriceX96 > upper ? upper : sqrtPriceX96;
|
|
11289
|
-
amount0 += ceilDiv$4(liquidity * Q96$
|
|
11290
|
-
amount1 += ceilDiv$4(liquidity * (price - lower), Q96$
|
|
11325
|
+
amount0 += ceilDiv$4(liquidity * Q96$5 * (upper - price), upper * price);
|
|
11326
|
+
amount1 += ceilDiv$4(liquidity * (price - lower), Q96$5);
|
|
11291
11327
|
}
|
|
11292
11328
|
const buffer = {
|
|
11293
11329
|
amount0: ceilDiv$4(amount0 * 5n, 100n),
|
|
@@ -11315,7 +11351,7 @@ function getUnhedgedLpRanges({ tokenId, positionSize, tickSpacing }) {
|
|
|
11315
11351
|
const lower = tickToSqrtPriceX96(tickLower);
|
|
11316
11352
|
const upper = tickToSqrtPriceX96(tickUpper);
|
|
11317
11353
|
const amount = positionSize * leg.optionRatio;
|
|
11318
|
-
const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96$
|
|
11354
|
+
const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96$5) / (upper - lower) : amount * Q96$5 / (upper - lower);
|
|
11319
11355
|
return liquidity <= 0n ? [] : [{
|
|
11320
11356
|
tickLower: Number(tickLower),
|
|
11321
11357
|
tickUpper: Number(tickUpper),
|
|
@@ -11336,7 +11372,7 @@ function getLpPositionFunding(params) {
|
|
|
11336
11372
|
});
|
|
11337
11373
|
const breakdown = getLpDepositBreakdown(ranges, sqrtPriceX96);
|
|
11338
11374
|
const priceSquared = valuationSqrtPriceX96 * valuationSqrtPriceX96;
|
|
11339
|
-
const value = ({ amount0, amount1 }) => quoteTokenIndex === 0 ? amount0 + ceilDiv$4(amount1 * Q96$
|
|
11375
|
+
const value = ({ amount0, amount1 }) => quoteTokenIndex === 0 ? amount0 + ceilDiv$4(amount1 * Q96$5 * Q96$5, priceSquared) : amount1 + ceilDiv$4(amount0 * priceSquared, Q96$5 * Q96$5);
|
|
11340
11376
|
const principalInQuote = value(breakdown.principal);
|
|
11341
11377
|
const totalInQuote = value(breakdown.total);
|
|
11342
11378
|
return {
|
|
@@ -14547,6 +14583,71 @@ async function assertLpPositionFunded(params) {
|
|
|
14547
14583
|
return funding;
|
|
14548
14584
|
}
|
|
14549
14585
|
|
|
14586
|
+
//#endregion
|
|
14587
|
+
//#region src/uniswap/lpGreeks.ts
|
|
14588
|
+
const Q96$4 = 1n << 96n;
|
|
14589
|
+
const Q192$4 = 1n << 192n;
|
|
14590
|
+
/**
|
|
14591
|
+
* Compute the token0/token1 amounts backing `liquidity` over `[sqrtA, sqrtB]`
|
|
14592
|
+
* at the current price `sqrtP`, mirroring Uniswap's `LiquidityAmounts`
|
|
14593
|
+
* (`getAmountsForLiquidity`). All sqrt prices are X96. The current price is
|
|
14594
|
+
* clamped into the range, so out-of-range positions collapse to a single token.
|
|
14595
|
+
*/
|
|
14596
|
+
function getAmountsForLiquidity(sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, liquidity) {
|
|
14597
|
+
const [sqrtA, sqrtB] = sqrtRatioAX96 <= sqrtRatioBX96 ? [sqrtRatioAX96, sqrtRatioBX96] : [sqrtRatioBX96, sqrtRatioAX96];
|
|
14598
|
+
const sqrtC = sqrtPriceX96 < sqrtA ? sqrtA : sqrtPriceX96 > sqrtB ? sqrtB : sqrtPriceX96;
|
|
14599
|
+
const amount0 = sqrtC < sqrtB ? liquidity * (sqrtB - sqrtC) * Q96$4 / (sqrtC * sqrtB) : 0n;
|
|
14600
|
+
const amount1 = sqrtC > sqrtA ? liquidity * (sqrtC - sqrtA) / Q96$4 : 0n;
|
|
14601
|
+
return {
|
|
14602
|
+
amount0,
|
|
14603
|
+
amount1
|
|
14604
|
+
};
|
|
14605
|
+
}
|
|
14606
|
+
|
|
14607
|
+
//#endregion
|
|
14608
|
+
//#region src/panoptic/v2/greeks/legLiquidity.ts
|
|
14609
|
+
const Q96$3 = 1n << 96n;
|
|
14610
|
+
function divCeil(numerator, denominator) {
|
|
14611
|
+
return (numerator + denominator - 1n) / denominator;
|
|
14612
|
+
}
|
|
14613
|
+
/** The Uniswap range and liquidity backing one option leg, with the contract's rounding. */
|
|
14614
|
+
function getLegLiquidityRange(leg, positionSize, tickSpacing) {
|
|
14615
|
+
const width = leg.width * tickSpacing;
|
|
14616
|
+
const lowerTick = leg.strike - width / 2n;
|
|
14617
|
+
const upperTick = leg.strike + (width + 1n) / 2n;
|
|
14618
|
+
if (lowerTick < -887272n || upperTick > 887272n || lowerTick >= upperTick) throw new RangeError("Invalid position range");
|
|
14619
|
+
const sqrtLower = tickToSqrtPriceX96(lowerTick);
|
|
14620
|
+
const sqrtUpper = tickToSqrtPriceX96(upperTick);
|
|
14621
|
+
const amount = positionSize * leg.optionRatio;
|
|
14622
|
+
const liquidity = leg.asset === 0n ? amount * (sqrtLower * sqrtUpper / Q96$3) / (sqrtUpper - sqrtLower) : amount * Q96$3 / (sqrtUpper - sqrtLower);
|
|
14623
|
+
return {
|
|
14624
|
+
lowerTick,
|
|
14625
|
+
upperTick,
|
|
14626
|
+
sqrtLower,
|
|
14627
|
+
sqrtUpper,
|
|
14628
|
+
liquidity
|
|
14629
|
+
};
|
|
14630
|
+
}
|
|
14631
|
+
/**
|
|
14632
|
+
* One option leg's signed holding of `tokenIndex` at `currentTick`: the amount
|
|
14633
|
+
* its liquidity holds minus the amount the leg moved, positive for short legs.
|
|
14634
|
+
*/
|
|
14635
|
+
function getLegTokenInventory(leg, currentTick, positionSize, tickSpacing, tokenIndex) {
|
|
14636
|
+
const { sqrtLower, sqrtUpper, liquidity } = getLegLiquidityRange(leg, positionSize, tickSpacing);
|
|
14637
|
+
const held = getAmountsForLiquidity(tickToSqrtPriceX96(currentTick), sqrtLower, sqrtUpper, liquidity);
|
|
14638
|
+
const heldAmount = tokenIndex === 0n ? held.amount0 : held.amount1;
|
|
14639
|
+
let movedAmount = 0n;
|
|
14640
|
+
if (leg.tokenType === tokenIndex) {
|
|
14641
|
+
const span = sqrtUpper - sqrtLower;
|
|
14642
|
+
if (tokenIndex === 0n) {
|
|
14643
|
+
const scaled = (liquidity << 96n) * span;
|
|
14644
|
+
movedAmount = leg.isLong ? scaled / sqrtUpper / sqrtLower : divCeil(divCeil(scaled, sqrtUpper), sqrtLower);
|
|
14645
|
+
} else movedAmount = leg.isLong ? liquidity * span / Q96$3 : divCeil(liquidity * span, Q96$3);
|
|
14646
|
+
}
|
|
14647
|
+
const net = heldAmount - movedAmount;
|
|
14648
|
+
return leg.isLong ? -net : net;
|
|
14649
|
+
}
|
|
14650
|
+
|
|
14550
14651
|
//#endregion
|
|
14551
14652
|
//#region src/panoptic/v2/greeks/index.ts
|
|
14552
14653
|
/** Fixed-point scale constants for sqrtPriceX96 arithmetic */
|
|
@@ -14897,12 +14998,14 @@ function toVaultFrameAtTick(delta, fromAsset, vaultAssetIndex, currentTick, flip
|
|
|
14897
14998
|
* Calculate one leg's wallet-aware delta in the vault asset frame.
|
|
14898
14999
|
*
|
|
14899
15000
|
* Width-zero loans and credits must be evaluated directly in the vault frame.
|
|
14900
|
-
*
|
|
15001
|
+
* An option leg is measured as its current holding of the vault token, so
|
|
15002
|
+
* `mintTick` and `definedRisk` do not affect it. Tokens swapped at mint belong
|
|
15003
|
+
* to the account's collateral balance, not to the position: a per-position
|
|
15004
|
+
* display omits them by design, and a whole-account delta adds the balance.
|
|
14901
15005
|
*/
|
|
14902
15006
|
function getLegDeltaInVaultFrame(leg, currentTick, positionSize, poolTickSpacing, mintTick, definedRisk, vaultAssetIndex) {
|
|
14903
15007
|
if (leg.width === 0n) return getLegDelta(leg, currentTick, positionSize, poolTickSpacing, mintTick, definedRisk, vaultAssetIndex);
|
|
14904
|
-
|
|
14905
|
-
return toVaultFrameAtTick(legDelta, leg.asset, vaultAssetIndex, currentTick, true);
|
|
15008
|
+
return getLegTokenInventory(leg, currentTick, positionSize, poolTickSpacing, vaultAssetIndex);
|
|
14906
15009
|
}
|
|
14907
15010
|
/**
|
|
14908
15011
|
* Calculate the gamma (dollar gamma) of a single leg.
|
|
@@ -15001,9 +15104,9 @@ function calculatePositionDelta(input) {
|
|
|
15001
15104
|
/**
|
|
15002
15105
|
* Calculate debt-only position delta in a single target asset frame.
|
|
15003
15106
|
*
|
|
15004
|
-
* Option legs
|
|
15005
|
-
*
|
|
15006
|
-
*
|
|
15107
|
+
* Option legs contribute their current holding of the `assetIndex` token,
|
|
15108
|
+
* without any mint-time adjustment. Width-zero legs are evaluated directly in
|
|
15109
|
+
* the target frame.
|
|
15007
15110
|
*
|
|
15008
15111
|
* Width=0 loan/credit legs include only their debt obligation. The held-token
|
|
15009
15112
|
* side must be added separately from account collateral balances, preventing a
|
|
@@ -17515,7 +17618,7 @@ function buildCreditWrappedDispatch(params) {
|
|
|
17515
17618
|
|
|
17516
17619
|
//#endregion
|
|
17517
17620
|
//#region src/panoptic/v2/simulations/tokenShortfallRecovery.ts
|
|
17518
|
-
const BPS_DENOMINATOR$
|
|
17621
|
+
const BPS_DENOMINATOR$5 = 10000n;
|
|
17519
17622
|
const MAX_RECOVERY_QUOTE_ATTEMPTS = 8;
|
|
17520
17623
|
/**
|
|
17521
17624
|
* Wrap a dispatch with a temporary credit leg that sources the shortfall.
|
|
@@ -17553,19 +17656,21 @@ function getNotEnoughTokensError(error) {
|
|
|
17553
17656
|
let current = error;
|
|
17554
17657
|
while (current !== void 0 && current !== null && !visited.has(current)) {
|
|
17555
17658
|
visited.add(current);
|
|
17556
|
-
const
|
|
17659
|
+
const decoded = parsePanopticError(current);
|
|
17660
|
+
const parsed = current instanceof NotEnoughTokensError ? current : decoded?.error;
|
|
17557
17661
|
const candidate = parsed instanceof NotEnoughTokensError ? parsed : null;
|
|
17558
17662
|
if (candidate !== null) {
|
|
17559
17663
|
const args = candidate;
|
|
17560
|
-
if (args.tokenAddress
|
|
17664
|
+
if (typeof args.tokenAddress === "string" && isAddress(args.tokenAddress) && typeof args.assetsRequested === "bigint" && typeof args.assetBalance === "bigint") return candidate;
|
|
17561
17665
|
}
|
|
17562
|
-
|
|
17666
|
+
const innerData = decoded?.errorName === "ExecuteError" ? decoded.args[1] : void 0;
|
|
17667
|
+
current = typeof innerData === "string" && isHex(innerData) ? { data: innerData } : current instanceof Error && "cause" in current ? current.cause : void 0;
|
|
17563
17668
|
}
|
|
17564
17669
|
return null;
|
|
17565
17670
|
}
|
|
17566
17671
|
function maximumAmountIn(estimatedAmountIn, slippageBps) {
|
|
17567
17672
|
if (slippageBps < 0n) throw new PanopticError("slippageBps must be non-negative");
|
|
17568
|
-
return (estimatedAmountIn * (BPS_DENOMINATOR$
|
|
17673
|
+
return (estimatedAmountIn * (BPS_DENOMINATOR$5 + slippageBps) + BPS_DENOMINATOR$5 - 1n) / BPS_DENOMINATOR$5;
|
|
17569
17674
|
}
|
|
17570
17675
|
function ceilDiv$3(numerator, denominator) {
|
|
17571
17676
|
return (numerator + denominator - 1n) / denominator;
|
|
@@ -17590,10 +17695,10 @@ async function quoteTokenShortfallRecovery(params) {
|
|
|
17590
17695
|
reason: "invalid-shortfall",
|
|
17591
17696
|
detail: `requested=${shortfallError.assetsRequested} <= balance=${shortfallError.assetBalance}`
|
|
17592
17697
|
};
|
|
17593
|
-
if (params.slippageBps < 0n || params.slippageBps > BPS_DENOMINATOR$
|
|
17698
|
+
if (params.slippageBps < 0n || params.slippageBps > BPS_DENOMINATOR$5) return {
|
|
17594
17699
|
available: false,
|
|
17595
17700
|
reason: "invalid-slippage",
|
|
17596
|
-
detail: `slippageBps=${params.slippageBps} is outside [0, ${BPS_DENOMINATOR$
|
|
17701
|
+
detail: `slippageBps=${params.slippageBps} is outside [0, ${BPS_DENOMINATOR$5}]`
|
|
17597
17702
|
};
|
|
17598
17703
|
const targetBlockNumber = params.blockNumber ?? await params.client.getBlockNumber();
|
|
17599
17704
|
const pool = await getPool({
|
|
@@ -18366,10 +18471,32 @@ var UnsupportedChainError = class extends PanopticError {
|
|
|
18366
18471
|
this.chainId = chainId;
|
|
18367
18472
|
}
|
|
18368
18473
|
};
|
|
18474
|
+
/**
|
|
18475
|
+
* `tokenIn` is neither `currency0` nor `currency1` of the resolved pool.
|
|
18476
|
+
*/
|
|
18477
|
+
var InvalidSwapTokenError = class extends PanopticError {
|
|
18478
|
+
name = "InvalidSwapTokenError";
|
|
18479
|
+
constructor(token, currency0, currency1, cause) {
|
|
18480
|
+
super(`Token ${token} is not part of the pool (currency0=${currency0}, currency1=${currency1})`, cause);
|
|
18481
|
+
this.token = token;
|
|
18482
|
+
this.currency0 = currency0;
|
|
18483
|
+
this.currency1 = currency1;
|
|
18484
|
+
}
|
|
18485
|
+
};
|
|
18486
|
+
/**
|
|
18487
|
+
* The V4Quoter is not available for the chain (no fallback in v1).
|
|
18488
|
+
*/
|
|
18489
|
+
var QuoterUnavailableError = class extends PanopticError {
|
|
18490
|
+
name = "QuoterUnavailableError";
|
|
18491
|
+
constructor(chainId, cause) {
|
|
18492
|
+
super(`V4Quoter unavailable for chain ${chainId}`, cause);
|
|
18493
|
+
this.chainId = chainId;
|
|
18494
|
+
}
|
|
18495
|
+
};
|
|
18369
18496
|
|
|
18370
18497
|
//#endregion
|
|
18371
18498
|
//#region src/uniswap/v3/router/encodeSwap.ts
|
|
18372
|
-
const UINT128_MAX$
|
|
18499
|
+
const UINT128_MAX$4 = (1n << 128n) - 1n;
|
|
18373
18500
|
|
|
18374
18501
|
//#endregion
|
|
18375
18502
|
//#region src/uniswap/v3/abis/quoterV2.ts
|
|
@@ -18513,8 +18640,8 @@ function getUniswapV3Addresses(chainId, overrides) {
|
|
|
18513
18640
|
|
|
18514
18641
|
//#endregion
|
|
18515
18642
|
//#region src/uniswap/v3/router/quote.ts
|
|
18516
|
-
const BPS_DENOMINATOR$
|
|
18517
|
-
const UINT128_MAX = (1n << 128n) - 1n;
|
|
18643
|
+
const BPS_DENOMINATOR$4 = 10000n;
|
|
18644
|
+
const UINT128_MAX$3 = (1n << 128n) - 1n;
|
|
18518
18645
|
/**
|
|
18519
18646
|
* Quote an exact-in v3 swap. Returns `null` when the quote reverts (e.g. the
|
|
18520
18647
|
* pool does not exist / has no liquidity) so callers can skip that pool when
|
|
@@ -18522,8 +18649,8 @@ const UINT128_MAX = (1n << 128n) - 1n;
|
|
|
18522
18649
|
*/
|
|
18523
18650
|
async function quoteV3ExactIn(params) {
|
|
18524
18651
|
const { client, chainId, tokenIn, tokenOut, fee, amountIn, slippageBps, blockNumber } = params;
|
|
18525
|
-
if (amountIn < 0n || amountIn > UINT128_MAX) throw new PanopticError(`amountIn ${amountIn} exceeds uint128 maximum`);
|
|
18526
|
-
assertSlippageBps(slippageBps);
|
|
18652
|
+
if (amountIn < 0n || amountIn > UINT128_MAX$3) throw new PanopticError(`amountIn ${amountIn} exceeds uint128 maximum`);
|
|
18653
|
+
assertSlippageBps$1(slippageBps);
|
|
18527
18654
|
const { quoterV2 } = getUniswapV3Addresses(chainId, params.addresses);
|
|
18528
18655
|
try {
|
|
18529
18656
|
const { result } = await client.simulateContract({
|
|
@@ -18540,7 +18667,7 @@ async function quoteV3ExactIn(params) {
|
|
|
18540
18667
|
}]
|
|
18541
18668
|
});
|
|
18542
18669
|
const [amountOut, , , gasEstimate] = result;
|
|
18543
|
-
const amountOutMinimum = amountOut * (BPS_DENOMINATOR$
|
|
18670
|
+
const amountOutMinimum = amountOut * (BPS_DENOMINATOR$4 - slippageBps) / BPS_DENOMINATOR$4;
|
|
18544
18671
|
return {
|
|
18545
18672
|
amountOut,
|
|
18546
18673
|
amountOutMinimum,
|
|
@@ -18551,13 +18678,172 @@ async function quoteV3ExactIn(params) {
|
|
|
18551
18678
|
throw err;
|
|
18552
18679
|
}
|
|
18553
18680
|
}
|
|
18554
|
-
|
|
18555
|
-
|
|
18681
|
+
/**
|
|
18682
|
+
* Quote an exact-out v3 swap. Returns `null` on revert (no pool / no liquidity).
|
|
18683
|
+
*/
|
|
18684
|
+
async function quoteV3ExactOut(params) {
|
|
18685
|
+
const { client, chainId, tokenIn, tokenOut, fee, amountOut, slippageBps, blockNumber } = params;
|
|
18686
|
+
if (amountOut < 0n || amountOut > UINT128_MAX$3) throw new PanopticError(`amountOut ${amountOut} exceeds uint128 maximum`);
|
|
18687
|
+
assertSlippageBps$1(slippageBps);
|
|
18688
|
+
const { quoterV2 } = getUniswapV3Addresses(chainId, params.addresses);
|
|
18689
|
+
try {
|
|
18690
|
+
const { result } = await client.simulateContract({
|
|
18691
|
+
address: quoterV2,
|
|
18692
|
+
abi: quoterV2Abi,
|
|
18693
|
+
functionName: "quoteExactOutputSingle",
|
|
18694
|
+
blockNumber,
|
|
18695
|
+
args: [{
|
|
18696
|
+
tokenIn,
|
|
18697
|
+
tokenOut,
|
|
18698
|
+
amount: amountOut,
|
|
18699
|
+
fee: Number(fee),
|
|
18700
|
+
sqrtPriceLimitX96: 0n
|
|
18701
|
+
}]
|
|
18702
|
+
});
|
|
18703
|
+
const [amountIn, , , gasEstimate] = result;
|
|
18704
|
+
const amountInMaximum = (amountIn * (BPS_DENOMINATOR$4 + slippageBps) + BPS_DENOMINATOR$4 - 1n) / BPS_DENOMINATOR$4;
|
|
18705
|
+
return {
|
|
18706
|
+
amountIn,
|
|
18707
|
+
amountInMaximum,
|
|
18708
|
+
gasEstimate
|
|
18709
|
+
};
|
|
18710
|
+
} catch (err) {
|
|
18711
|
+
if (isRevert(err)) return null;
|
|
18712
|
+
throw err;
|
|
18713
|
+
}
|
|
18714
|
+
}
|
|
18715
|
+
function assertSlippageBps$1(slippageBps) {
|
|
18716
|
+
if (slippageBps < 0n || slippageBps > BPS_DENOMINATOR$4) throw new PanopticError(`invalid slippageBps ${slippageBps}, must be 0..10000`);
|
|
18556
18717
|
}
|
|
18557
18718
|
function isRevert(err) {
|
|
18558
18719
|
return err instanceof BaseError && err.walk((e) => e instanceof ContractFunctionRevertedError) instanceof ContractFunctionRevertedError;
|
|
18559
18720
|
}
|
|
18560
18721
|
|
|
18722
|
+
//#endregion
|
|
18723
|
+
//#region src/uniswap/v3/router/resolveRoute.ts
|
|
18724
|
+
async function resolveV3SwapRoute(params) {
|
|
18725
|
+
const { client, poolAddress, tokenIn } = params;
|
|
18726
|
+
const meta = await getPoolMetadata({
|
|
18727
|
+
client,
|
|
18728
|
+
poolAddress
|
|
18729
|
+
});
|
|
18730
|
+
if (meta.isV4) throw new PanopticError("resolveV3SwapRoute called on a v4 pool");
|
|
18731
|
+
const isToken0 = isAddressEqual(tokenIn, meta.token0Asset);
|
|
18732
|
+
const isToken1 = isAddressEqual(tokenIn, meta.token1Asset);
|
|
18733
|
+
if (!isToken0 && !isToken1) throw new InvalidSwapTokenError(tokenIn, meta.token0Asset, meta.token1Asset);
|
|
18734
|
+
const zeroForOne = isToken0;
|
|
18735
|
+
return {
|
|
18736
|
+
tokenIn,
|
|
18737
|
+
tokenOut: zeroForOne ? meta.token1Asset : meta.token0Asset,
|
|
18738
|
+
fee: meta.fee,
|
|
18739
|
+
zeroForOne
|
|
18740
|
+
};
|
|
18741
|
+
}
|
|
18742
|
+
|
|
18743
|
+
//#endregion
|
|
18744
|
+
//#region src/uniswap/v3/router/quoteViaRouter.ts
|
|
18745
|
+
const FALLBACK_META$1 = {
|
|
18746
|
+
blockNumber: 0n,
|
|
18747
|
+
blockTimestamp: 0n,
|
|
18748
|
+
blockHash: "0x0"
|
|
18749
|
+
};
|
|
18750
|
+
async function quoteSwapExactOutViaV3Router(params) {
|
|
18751
|
+
const { client, poolAddress, chainId, tokenIn, amountOut, slippageBps, blockNumber, addresses } = params;
|
|
18752
|
+
try {
|
|
18753
|
+
const targetBlockNumber = blockNumber ?? await client.getBlockNumber();
|
|
18754
|
+
const metaPromise = getBlockMeta({
|
|
18755
|
+
client,
|
|
18756
|
+
blockNumber: targetBlockNumber
|
|
18757
|
+
});
|
|
18758
|
+
metaPromise.catch(() => void 0);
|
|
18759
|
+
const route = await resolveV3SwapRoute({
|
|
18760
|
+
client,
|
|
18761
|
+
poolAddress,
|
|
18762
|
+
tokenIn
|
|
18763
|
+
});
|
|
18764
|
+
const quote = await quoteV3ExactOut({
|
|
18765
|
+
client,
|
|
18766
|
+
chainId,
|
|
18767
|
+
tokenIn: route.tokenIn,
|
|
18768
|
+
tokenOut: route.tokenOut,
|
|
18769
|
+
fee: route.fee,
|
|
18770
|
+
amountOut,
|
|
18771
|
+
slippageBps,
|
|
18772
|
+
blockNumber: targetBlockNumber,
|
|
18773
|
+
addresses
|
|
18774
|
+
});
|
|
18775
|
+
if (!quote) throw new PanopticError("v3 quote returned no result (pool may have no liquidity)");
|
|
18776
|
+
const _meta = await metaPromise;
|
|
18777
|
+
return {
|
|
18778
|
+
success: true,
|
|
18779
|
+
data: {
|
|
18780
|
+
amountIn: quote.amountIn,
|
|
18781
|
+
amountInMaximum: quote.amountInMaximum,
|
|
18782
|
+
zeroForOne: route.zeroForOne,
|
|
18783
|
+
tokenOut: route.tokenOut,
|
|
18784
|
+
gasEstimate: quote.gasEstimate
|
|
18785
|
+
},
|
|
18786
|
+
gasEstimate: quote.gasEstimate,
|
|
18787
|
+
_meta
|
|
18788
|
+
};
|
|
18789
|
+
} catch (error) {
|
|
18790
|
+
return {
|
|
18791
|
+
success: false,
|
|
18792
|
+
error: error instanceof PanopticError ? error : new PanopticError(error instanceof Error ? error.message : "Quote failed", error instanceof Error ? error : void 0),
|
|
18793
|
+
_meta: FALLBACK_META$1
|
|
18794
|
+
};
|
|
18795
|
+
}
|
|
18796
|
+
}
|
|
18797
|
+
|
|
18798
|
+
//#endregion
|
|
18799
|
+
//#region src/uniswap/v4/addresses.ts
|
|
18800
|
+
/**
|
|
18801
|
+
* Canonical Permit2, identical across all chains.
|
|
18802
|
+
*/
|
|
18803
|
+
const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
18804
|
+
/**
|
|
18805
|
+
* Verified Uniswap v4 deployment addresses keyed by chainId.
|
|
18806
|
+
*
|
|
18807
|
+
* Sourced from the official Uniswap v4 deployments. Add a chain here only after
|
|
18808
|
+
* verifying each address against the canonical Uniswap deployment listing —
|
|
18809
|
+
* Universal Router in particular is NOT the same address across chains.
|
|
18810
|
+
*/
|
|
18811
|
+
const UNISWAP_V4_ADDRESSES = {
|
|
18812
|
+
1: {
|
|
18813
|
+
universalRouter: "0x66a9893cC07D91D95644AEDD05D03f95e1dBA8Af",
|
|
18814
|
+
v4Quoter: "0x52F0E24D1c21C8A0cB1e5a5dD6198556BD9E1203",
|
|
18815
|
+
poolManager: "0x000000000004444c5dc75cB358380D2e3dE08A90",
|
|
18816
|
+
positionManager: "0xbD216513d74C8cf14cf4747E6AaA6420FF64ee9e",
|
|
18817
|
+
permit2: PERMIT2_ADDRESS
|
|
18818
|
+
},
|
|
18819
|
+
4663: {
|
|
18820
|
+
universalRouter: "0x8876789976decbfcbbbe364623c63652db8c0904",
|
|
18821
|
+
v4Quoter: "0x8dc178efb8111bb0973dd9d722ebeff267c98f94",
|
|
18822
|
+
poolManager: "0x8366a39cc670b4001a1121b8f6a443a643e40951",
|
|
18823
|
+
positionManager: "0x58daec3116aae6d93017baaea7749052e8a04fa7",
|
|
18824
|
+
permit2: PERMIT2_ADDRESS
|
|
18825
|
+
}
|
|
18826
|
+
};
|
|
18827
|
+
/**
|
|
18828
|
+
* Resolve the Uniswap v4 addresses for a chain, applying optional overrides.
|
|
18829
|
+
*
|
|
18830
|
+
* @param chainId - Target chain ID.
|
|
18831
|
+
* @param overrides - Partial override of any address (e.g. for fork tests).
|
|
18832
|
+
* @returns Fully-resolved {@link UniswapV4Addresses}.
|
|
18833
|
+
* @throws {UnsupportedChainError} when the chain is not listed and the
|
|
18834
|
+
* overrides do not supply every required address.
|
|
18835
|
+
*/
|
|
18836
|
+
function getUniswapV4Addresses(chainId, overrides) {
|
|
18837
|
+
const base = UNISWAP_V4_ADDRESSES[Number(chainId)];
|
|
18838
|
+
const merged = {
|
|
18839
|
+
...base,
|
|
18840
|
+
...overrides,
|
|
18841
|
+
permit2: overrides?.permit2 ?? base?.permit2 ?? PERMIT2_ADDRESS
|
|
18842
|
+
};
|
|
18843
|
+
if (merged.universalRouter === void 0 || merged.v4Quoter === void 0 || merged.poolManager === void 0 || merged.positionManager === void 0 || merged.permit2 === void 0) throw new UnsupportedChainError(chainId);
|
|
18844
|
+
return merged;
|
|
18845
|
+
}
|
|
18846
|
+
|
|
18561
18847
|
//#endregion
|
|
18562
18848
|
//#region src/panoptic/v2/reads/sfpm.ts
|
|
18563
18849
|
/**
|
|
@@ -28405,6 +28691,108 @@ async function simulateClosePosition(params) {
|
|
|
28405
28691
|
}
|
|
28406
28692
|
}
|
|
28407
28693
|
|
|
28694
|
+
//#endregion
|
|
28695
|
+
//#region src/panoptic/v2/simulations/simulateClosePremiumProtection.ts
|
|
28696
|
+
/** Estimate unfunded short premium after buyer settlement and collection of chunk fees. */
|
|
28697
|
+
async function simulateClosePremiumProtection(params) {
|
|
28698
|
+
const { client, poolAddress, account, positionIdList, closingTokenIds, targets } = params;
|
|
28699
|
+
let metaPromise;
|
|
28700
|
+
try {
|
|
28701
|
+
const blockNumber = params.blockNumber ?? await client.getBlockNumber();
|
|
28702
|
+
metaPromise = getBlockMeta({
|
|
28703
|
+
client,
|
|
28704
|
+
blockNumber
|
|
28705
|
+
});
|
|
28706
|
+
metaPromise.catch(() => {});
|
|
28707
|
+
if (closingTokenIds.length === 0 || closingTokenIds.some((id) => !positionIdList.includes(id))) throw new PanopticError("Premium protection requires currently held positions to close");
|
|
28708
|
+
const positionSizes = await getCurrentPositionSizes({
|
|
28709
|
+
client,
|
|
28710
|
+
poolAddress,
|
|
28711
|
+
account,
|
|
28712
|
+
positionIdList: closingTokenIds,
|
|
28713
|
+
blockNumber
|
|
28714
|
+
});
|
|
28715
|
+
const { collectionDispatch } = buildProtectedSettlePlan({
|
|
28716
|
+
positionIdList: closingTokenIds,
|
|
28717
|
+
finalPositionIdList: positionIdList,
|
|
28718
|
+
positionSizes,
|
|
28719
|
+
builderCode: params.builderCode
|
|
28720
|
+
});
|
|
28721
|
+
const calls = (targets.length ? buildSettleSequenceCalls({
|
|
28722
|
+
positionIdListFrom: params.signerPositionIdList,
|
|
28723
|
+
targets
|
|
28724
|
+
}) : []).map((data) => ({
|
|
28725
|
+
to: poolAddress,
|
|
28726
|
+
data,
|
|
28727
|
+
account: params.signerAddress
|
|
28728
|
+
}));
|
|
28729
|
+
if (collectionDispatch !== void 0) {
|
|
28730
|
+
const [dispatchData] = buildSettleSequenceCalls({
|
|
28731
|
+
positionIdListFrom: positionIdList,
|
|
28732
|
+
targets: [],
|
|
28733
|
+
dispatch: collectionDispatch
|
|
28734
|
+
});
|
|
28735
|
+
if (dispatchData === void 0) throw new PanopticError("Premium protection collection dispatch is missing");
|
|
28736
|
+
calls.push({
|
|
28737
|
+
...params.buildCollectionCall(dispatchData),
|
|
28738
|
+
account: params.signerAddress
|
|
28739
|
+
});
|
|
28740
|
+
}
|
|
28741
|
+
for (const includePendingPremium of [true, false]) calls.push({
|
|
28742
|
+
to: poolAddress,
|
|
28743
|
+
account: params.signerAddress,
|
|
28744
|
+
data: encodeFunctionData({
|
|
28745
|
+
abi: panopticPoolV2Abi,
|
|
28746
|
+
functionName: "getFullPositionsData",
|
|
28747
|
+
args: [
|
|
28748
|
+
account,
|
|
28749
|
+
includePendingPremium,
|
|
28750
|
+
closingTokenIds
|
|
28751
|
+
]
|
|
28752
|
+
})
|
|
28753
|
+
});
|
|
28754
|
+
const blocks = await client.simulateBlocks({
|
|
28755
|
+
blocks: [{ calls }],
|
|
28756
|
+
blockNumber
|
|
28757
|
+
});
|
|
28758
|
+
const results = blocks[0]?.calls;
|
|
28759
|
+
if (results === void 0 || results.length !== calls.length) throw new PanopticError("Premium protection simulation returned incomplete results");
|
|
28760
|
+
for (const result$1 of results) if (result$1.status === "failure") throw result$1.error;
|
|
28761
|
+
const result = results.map((call$1) => call$1.data);
|
|
28762
|
+
const owedResult = result[result.length - 2];
|
|
28763
|
+
const availableResult = result[result.length - 1];
|
|
28764
|
+
if (owedResult === void 0 || availableResult === void 0) throw new PanopticError("Premium protection simulation returned incomplete results");
|
|
28765
|
+
const decodeShortPremium$1 = (data) => decodeLeftRightUnsigned(decodeFunctionResult({
|
|
28766
|
+
abi: panopticPoolV2Abi,
|
|
28767
|
+
functionName: "getFullPositionsData",
|
|
28768
|
+
data
|
|
28769
|
+
})[0]);
|
|
28770
|
+
const owed = decodeShortPremium$1(owedResult);
|
|
28771
|
+
const available = decodeShortPremium$1(availableResult);
|
|
28772
|
+
return {
|
|
28773
|
+
success: true,
|
|
28774
|
+
gasEstimate: 0n,
|
|
28775
|
+
data: {
|
|
28776
|
+
owed0: owed.right,
|
|
28777
|
+
owed1: owed.left,
|
|
28778
|
+
available0: available.right,
|
|
28779
|
+
available1: available.left,
|
|
28780
|
+
forfeit0: owed.right > available.right ? owed.right - available.right : 0n,
|
|
28781
|
+
forfeit1: owed.left > available.left ? owed.left - available.left : 0n
|
|
28782
|
+
},
|
|
28783
|
+
_meta: await metaPromise
|
|
28784
|
+
};
|
|
28785
|
+
} catch (error) {
|
|
28786
|
+
const simulationError = error instanceof PanopticError ? error : new PanopticError(String(error));
|
|
28787
|
+
if (metaPromise === void 0) throw simulationError;
|
|
28788
|
+
return {
|
|
28789
|
+
success: false,
|
|
28790
|
+
error: simulationError,
|
|
28791
|
+
_meta: await metaPromise
|
|
28792
|
+
};
|
|
28793
|
+
}
|
|
28794
|
+
}
|
|
28795
|
+
|
|
28408
28796
|
//#endregion
|
|
28409
28797
|
//#region src/panoptic/v2/simulations/simulateForceExercise.ts
|
|
28410
28798
|
/**
|
|
@@ -29060,7 +29448,7 @@ async function simulateSwapExactIn(params) {
|
|
|
29060
29448
|
|
|
29061
29449
|
//#endregion
|
|
29062
29450
|
//#region src/panoptic/v2/simulations/oneTokenFlow.ts
|
|
29063
|
-
const BPS_DENOMINATOR$
|
|
29451
|
+
const BPS_DENOMINATOR$3 = 10000n;
|
|
29064
29452
|
/**
|
|
29065
29453
|
* Default {@link OneTokenFlowQuoteParams.minSwapRatioBps}: 0.5%.
|
|
29066
29454
|
*
|
|
@@ -29077,7 +29465,7 @@ function abs(value) {
|
|
|
29077
29465
|
return value < 0n ? -value : value;
|
|
29078
29466
|
}
|
|
29079
29467
|
function padForSlippage(amount, slippageBps) {
|
|
29080
|
-
return (amount * (BPS_DENOMINATOR$
|
|
29468
|
+
return (amount * (BPS_DENOMINATOR$3 + slippageBps) + BPS_DENOMINATOR$3 - 1n) / BPS_DENOMINATOR$3;
|
|
29081
29469
|
}
|
|
29082
29470
|
/**
|
|
29083
29471
|
* Quote a dispatch wrapped so its net flow lands in `targetTokenIndex` only.
|
|
@@ -29097,10 +29485,10 @@ async function quoteOneTokenFlow(params) {
|
|
|
29097
29485
|
reason: "invalid-target-token",
|
|
29098
29486
|
detail: `targetTokenIndex=${targetTokenIndex} is neither 0 nor 1`
|
|
29099
29487
|
};
|
|
29100
|
-
if (params.slippageBps < 0n || params.slippageBps > BPS_DENOMINATOR$
|
|
29488
|
+
if (params.slippageBps < 0n || params.slippageBps > BPS_DENOMINATOR$3) return {
|
|
29101
29489
|
available: false,
|
|
29102
29490
|
reason: "invalid-slippage",
|
|
29103
|
-
detail: `slippageBps=${params.slippageBps} is outside [0, ${BPS_DENOMINATOR$
|
|
29491
|
+
detail: `slippageBps=${params.slippageBps} is outside [0, ${BPS_DENOMINATOR$3}]`
|
|
29104
29492
|
};
|
|
29105
29493
|
const tickLimitLow = params.tickLimitLow ?? MIN_TICK;
|
|
29106
29494
|
const tickLimitHigh = params.tickLimitHigh ?? MAX_TICK;
|
|
@@ -29190,7 +29578,7 @@ async function quoteOneTokenFlow(params) {
|
|
|
29190
29578
|
if (minSwapRatioBps > 0n) {
|
|
29191
29579
|
const residualInTargetTerms = convertToTokenIndex(abs(recovery.quote.netTokenOutChange), otherTokenIndex, targetTokenIndex, pool.sqrtPriceX96);
|
|
29192
29580
|
const settledInTargetTerms = abs(recovery.quote.netTokenInChange) + residualInTargetTerms;
|
|
29193
|
-
if (residualInTargetTerms * BPS_DENOMINATOR$
|
|
29581
|
+
if (residualInTargetTerms * BPS_DENOMINATOR$3 >= minSwapRatioBps * settledInTargetTerms) return {
|
|
29194
29582
|
available: false,
|
|
29195
29583
|
reason: "residual-not-single-token",
|
|
29196
29584
|
detail: `covering the shortfall leaves ${recovery.quote.netTokenOutChange} of the other token (${residualInTargetTerms} in target token terms) against a target flow of ${recovery.quote.netTokenInChange}`
|
|
@@ -29219,7 +29607,7 @@ async function quoteOneTokenFlow(params) {
|
|
|
29219
29607
|
}
|
|
29220
29608
|
if (baseTargetDelta !== null && minSwapRatioBps > 0n) {
|
|
29221
29609
|
const swapInTargetTerms = convertToTokenIndex(swapAmount, otherTokenIndex, targetTokenIndex, pool.sqrtPriceX96);
|
|
29222
|
-
if (swapInTargetTerms * BPS_DENOMINATOR$
|
|
29610
|
+
if (swapInTargetTerms * BPS_DENOMINATOR$3 < minSwapRatioBps * abs(baseTargetDelta)) return {
|
|
29223
29611
|
available: false,
|
|
29224
29612
|
reason: "below-threshold",
|
|
29225
29613
|
detail: `non-target flow ${swapInTargetTerms} (in target token terms) is below ${minSwapRatioBps}bps of the target flow ${abs(baseTargetDelta)}`
|
|
@@ -29305,6 +29693,251 @@ async function quoteOneTokenFlow(params) {
|
|
|
29305
29693
|
};
|
|
29306
29694
|
}
|
|
29307
29695
|
|
|
29696
|
+
//#endregion
|
|
29697
|
+
//#region src/uniswap/v4/router/encodeSwap.ts
|
|
29698
|
+
const UINT128_MAX$2 = (1n << 128n) - 1n;
|
|
29699
|
+
|
|
29700
|
+
//#endregion
|
|
29701
|
+
//#region src/uniswap/v4/router/permit2.ts
|
|
29702
|
+
/** uint160 max — the largest Permit2 allowance amount. */
|
|
29703
|
+
const UINT160_MAX = (1n << 160n) - 1n;
|
|
29704
|
+
/** uint48 max — the largest Permit2 expiration. */
|
|
29705
|
+
const UINT48_MAX = (1n << 48n) - 1n;
|
|
29706
|
+
|
|
29707
|
+
//#endregion
|
|
29708
|
+
//#region src/uniswap/v4/abis/v4Quoter.ts
|
|
29709
|
+
/**
|
|
29710
|
+
* Minimal V4Quoter ABI (`quoteExactInputSingle`, `quoteExactOutputSingle`).
|
|
29711
|
+
*
|
|
29712
|
+
* Note: neither function is `view` — they mutate state internally and are
|
|
29713
|
+
* intended to be called via `eth_call` / viem `simulateContract`, never
|
|
29714
|
+
* `readContract`.
|
|
29715
|
+
*
|
|
29716
|
+
* @module uniswap/v4/abis/v4Quoter
|
|
29717
|
+
*/
|
|
29718
|
+
const quoteExactSingleParams = {
|
|
29719
|
+
name: "params",
|
|
29720
|
+
type: "tuple",
|
|
29721
|
+
components: [
|
|
29722
|
+
{
|
|
29723
|
+
name: "poolKey",
|
|
29724
|
+
type: "tuple",
|
|
29725
|
+
components: [
|
|
29726
|
+
{
|
|
29727
|
+
name: "currency0",
|
|
29728
|
+
type: "address"
|
|
29729
|
+
},
|
|
29730
|
+
{
|
|
29731
|
+
name: "currency1",
|
|
29732
|
+
type: "address"
|
|
29733
|
+
},
|
|
29734
|
+
{
|
|
29735
|
+
name: "fee",
|
|
29736
|
+
type: "uint24"
|
|
29737
|
+
},
|
|
29738
|
+
{
|
|
29739
|
+
name: "tickSpacing",
|
|
29740
|
+
type: "int24"
|
|
29741
|
+
},
|
|
29742
|
+
{
|
|
29743
|
+
name: "hooks",
|
|
29744
|
+
type: "address"
|
|
29745
|
+
}
|
|
29746
|
+
]
|
|
29747
|
+
},
|
|
29748
|
+
{
|
|
29749
|
+
name: "zeroForOne",
|
|
29750
|
+
type: "bool"
|
|
29751
|
+
},
|
|
29752
|
+
{
|
|
29753
|
+
name: "exactAmount",
|
|
29754
|
+
type: "uint128"
|
|
29755
|
+
},
|
|
29756
|
+
{
|
|
29757
|
+
name: "hookData",
|
|
29758
|
+
type: "bytes"
|
|
29759
|
+
}
|
|
29760
|
+
]
|
|
29761
|
+
};
|
|
29762
|
+
const v4QuoterAbi = [{
|
|
29763
|
+
type: "function",
|
|
29764
|
+
name: "quoteExactInputSingle",
|
|
29765
|
+
stateMutability: "nonpayable",
|
|
29766
|
+
inputs: [quoteExactSingleParams],
|
|
29767
|
+
outputs: [{
|
|
29768
|
+
name: "amountOut",
|
|
29769
|
+
type: "uint256"
|
|
29770
|
+
}, {
|
|
29771
|
+
name: "gasEstimate",
|
|
29772
|
+
type: "uint256"
|
|
29773
|
+
}]
|
|
29774
|
+
}, {
|
|
29775
|
+
type: "function",
|
|
29776
|
+
name: "quoteExactOutputSingle",
|
|
29777
|
+
stateMutability: "nonpayable",
|
|
29778
|
+
inputs: [quoteExactSingleParams],
|
|
29779
|
+
outputs: [{
|
|
29780
|
+
name: "amountIn",
|
|
29781
|
+
type: "uint256"
|
|
29782
|
+
}, {
|
|
29783
|
+
name: "gasEstimate",
|
|
29784
|
+
type: "uint256"
|
|
29785
|
+
}]
|
|
29786
|
+
}];
|
|
29787
|
+
|
|
29788
|
+
//#endregion
|
|
29789
|
+
//#region src/uniswap/v4/router/resolvePoolKey.ts
|
|
29790
|
+
/**
|
|
29791
|
+
* Resolve the PoolKey, swap direction, and output token metadata for a swap.
|
|
29792
|
+
*
|
|
29793
|
+
* @throws {InvalidSwapTokenError} when `tokenIn` is not part of the pool.
|
|
29794
|
+
*/
|
|
29795
|
+
async function resolveSwapRoute(params) {
|
|
29796
|
+
const { client, poolAddress, chainId, tokenIn, blockNumber } = params;
|
|
29797
|
+
const pool = await getPool({
|
|
29798
|
+
client,
|
|
29799
|
+
poolAddress,
|
|
29800
|
+
chainId,
|
|
29801
|
+
blockNumber
|
|
29802
|
+
});
|
|
29803
|
+
const { poolKey } = pool;
|
|
29804
|
+
const isCurrency0 = isAddressEqual(tokenIn, poolKey.currency0);
|
|
29805
|
+
const isCurrency1 = isAddressEqual(tokenIn, poolKey.currency1);
|
|
29806
|
+
if (!isCurrency0 && !isCurrency1) throw new InvalidSwapTokenError(tokenIn, poolKey.currency0, poolKey.currency1);
|
|
29807
|
+
const zeroForOne = isCurrency0;
|
|
29808
|
+
const tokenOut = zeroForOne ? poolKey.currency1 : poolKey.currency0;
|
|
29809
|
+
const outTracker = zeroForOne ? pool.collateralTracker1 : pool.collateralTracker0;
|
|
29810
|
+
return {
|
|
29811
|
+
poolKey,
|
|
29812
|
+
zeroForOne,
|
|
29813
|
+
tokenOut,
|
|
29814
|
+
tokenOutDecimals: outTracker.decimals,
|
|
29815
|
+
tokenOutSymbol: outTracker.symbol
|
|
29816
|
+
};
|
|
29817
|
+
}
|
|
29818
|
+
|
|
29819
|
+
//#endregion
|
|
29820
|
+
//#region src/uniswap/v4/router/quote.ts
|
|
29821
|
+
const BPS_DENOMINATOR$2 = 10000n;
|
|
29822
|
+
const UINT128_MAX$1 = (1n << 128n) - 1n;
|
|
29823
|
+
/** Reject out-of-range slippage so the min/max amount math can't underflow/overflow. */
|
|
29824
|
+
function assertSlippageBps(slippageBps) {
|
|
29825
|
+
if (slippageBps < 0n || slippageBps > BPS_DENOMINATOR$2) throw new PanopticError(`invalid slippageBps ${slippageBps}, must be 0..10000`);
|
|
29826
|
+
}
|
|
29827
|
+
const FALLBACK_META = {
|
|
29828
|
+
blockNumber: 0n,
|
|
29829
|
+
blockTimestamp: 0n,
|
|
29830
|
+
blockHash: "0x0"
|
|
29831
|
+
};
|
|
29832
|
+
/**
|
|
29833
|
+
* Quote an exact-out spot swap against the underlying Uniswap v4 pool.
|
|
29834
|
+
*
|
|
29835
|
+
* Uses the V4Quoter `quoteExactOutputSingle` via `eth_call` (the quoter is
|
|
29836
|
+
* state-mutating / revert-based, so it must be simulated, not read). Returns a
|
|
29837
|
+
* `SimulationResult` so failures carry a structured error rather than throwing.
|
|
29838
|
+
*/
|
|
29839
|
+
async function quoteSwapExactOutViaRouter(params) {
|
|
29840
|
+
const { client, poolAddress, chainId, tokenIn, amountOut, slippageBps, blockNumber, addresses } = params;
|
|
29841
|
+
try {
|
|
29842
|
+
if (amountOut < 0n || amountOut > UINT128_MAX$1) throw new PanopticError(`amountOut ${amountOut} exceeds uint128 maximum`);
|
|
29843
|
+
assertSlippageBps(slippageBps);
|
|
29844
|
+
const targetBlockNumber = blockNumber ?? await client.getBlockNumber();
|
|
29845
|
+
const metaPromise = getBlockMeta({
|
|
29846
|
+
client,
|
|
29847
|
+
blockNumber: targetBlockNumber
|
|
29848
|
+
});
|
|
29849
|
+
const { v4Quoter } = getUniswapV4Addresses(chainId, addresses);
|
|
29850
|
+
if (v4Quoter === zeroAddress) throw new QuoterUnavailableError(chainId);
|
|
29851
|
+
const route = await resolveSwapRoute({
|
|
29852
|
+
client,
|
|
29853
|
+
poolAddress,
|
|
29854
|
+
chainId,
|
|
29855
|
+
tokenIn,
|
|
29856
|
+
blockNumber: targetBlockNumber
|
|
29857
|
+
});
|
|
29858
|
+
const { result } = await client.simulateContract({
|
|
29859
|
+
address: v4Quoter,
|
|
29860
|
+
abi: v4QuoterAbi,
|
|
29861
|
+
functionName: "quoteExactOutputSingle",
|
|
29862
|
+
blockNumber: targetBlockNumber,
|
|
29863
|
+
args: [{
|
|
29864
|
+
poolKey: {
|
|
29865
|
+
currency0: route.poolKey.currency0,
|
|
29866
|
+
currency1: route.poolKey.currency1,
|
|
29867
|
+
fee: Number(route.poolKey.fee),
|
|
29868
|
+
tickSpacing: Number(route.poolKey.tickSpacing),
|
|
29869
|
+
hooks: route.poolKey.hooks
|
|
29870
|
+
},
|
|
29871
|
+
zeroForOne: route.zeroForOne,
|
|
29872
|
+
exactAmount: amountOut,
|
|
29873
|
+
hookData: "0x"
|
|
29874
|
+
}]
|
|
29875
|
+
});
|
|
29876
|
+
const [amountIn, gasEstimate] = result;
|
|
29877
|
+
const amountInMaximum = (amountIn * (BPS_DENOMINATOR$2 + slippageBps) + BPS_DENOMINATOR$2 - 1n) / BPS_DENOMINATOR$2;
|
|
29878
|
+
const _meta = await metaPromise;
|
|
29879
|
+
return {
|
|
29880
|
+
success: true,
|
|
29881
|
+
data: {
|
|
29882
|
+
amountIn,
|
|
29883
|
+
amountInMaximum,
|
|
29884
|
+
zeroForOne: route.zeroForOne,
|
|
29885
|
+
tokenOut: route.tokenOut,
|
|
29886
|
+
poolKey: route.poolKey,
|
|
29887
|
+
gasEstimate
|
|
29888
|
+
},
|
|
29889
|
+
gasEstimate,
|
|
29890
|
+
_meta
|
|
29891
|
+
};
|
|
29892
|
+
} catch (error) {
|
|
29893
|
+
return {
|
|
29894
|
+
success: false,
|
|
29895
|
+
error: error instanceof PanopticError ? error : new PanopticError(error instanceof Error ? error.message : "Quote failed", error instanceof Error ? error : void 0),
|
|
29896
|
+
_meta: FALLBACK_META
|
|
29897
|
+
};
|
|
29898
|
+
}
|
|
29899
|
+
}
|
|
29900
|
+
|
|
29901
|
+
//#endregion
|
|
29902
|
+
//#region src/uniswap/v4/router/quoteByPoolKey.ts
|
|
29903
|
+
const UINT128_MAX = (1n << 128n) - 1n;
|
|
29904
|
+
|
|
29905
|
+
//#endregion
|
|
29906
|
+
//#region src/panoptic/v2/simulations/quoteTokenShortfallSwap.ts
|
|
29907
|
+
/** Quote the opposite pool token needed to buy the deficit in a NotEnoughTokens revert. */
|
|
29908
|
+
async function quoteTokenShortfallSwap({ client, chainId, poolAddress, error, slippageBps = 50n }) {
|
|
29909
|
+
const shortfall = getNotEnoughTokensError(error);
|
|
29910
|
+
if (shortfall === null || shortfall.deficit === 0n) return null;
|
|
29911
|
+
const metadata = await getPoolMetadata({
|
|
29912
|
+
client,
|
|
29913
|
+
poolAddress
|
|
29914
|
+
});
|
|
29915
|
+
const matches0 = [metadata.token0Asset, metadata.collateralToken0Address].some((address) => isAddressEqual(address, shortfall.tokenAddress));
|
|
29916
|
+
const matches1 = [metadata.token1Asset, metadata.collateralToken1Address].some((address) => isAddressEqual(address, shortfall.tokenAddress));
|
|
29917
|
+
if (matches0 === matches1) return null;
|
|
29918
|
+
const tokenIn = matches0 ? metadata.token1Asset : metadata.token0Asset;
|
|
29919
|
+
const quote = await (metadata.isV4 ? quoteSwapExactOutViaRouter : quoteSwapExactOutViaV3Router)({
|
|
29920
|
+
client,
|
|
29921
|
+
chainId,
|
|
29922
|
+
poolAddress,
|
|
29923
|
+
tokenIn,
|
|
29924
|
+
amountOut: shortfall.deficit,
|
|
29925
|
+
slippageBps
|
|
29926
|
+
});
|
|
29927
|
+
return {
|
|
29928
|
+
deficit: shortfall.deficit,
|
|
29929
|
+
outputSymbol: matches0 ? metadata.token0Symbol : metadata.token1Symbol,
|
|
29930
|
+
outputDecimals: matches0 ? metadata.token0Decimals : metadata.token1Decimals,
|
|
29931
|
+
inputSymbol: matches0 ? metadata.token1Symbol : metadata.token0Symbol,
|
|
29932
|
+
inputDecimals: matches0 ? metadata.token1Decimals : metadata.token0Decimals,
|
|
29933
|
+
tokenIn,
|
|
29934
|
+
slippageBps,
|
|
29935
|
+
poolFeePips: metadata.fee <= 1000000n ? metadata.fee : null,
|
|
29936
|
+
estimatedPoolFee: quote.success && metadata.fee <= 1000000n ? (quote.data.amountIn * metadata.fee + 999999n) / 1000000n : null,
|
|
29937
|
+
quote: quote.success ? quote.data : null
|
|
29938
|
+
};
|
|
29939
|
+
}
|
|
29940
|
+
|
|
29308
29941
|
//#endregion
|
|
29309
29942
|
//#region src/panoptic/v2/simulations/temporaryLoanRecovery.ts
|
|
29310
29943
|
const BPS_DENOMINATOR$1 = 10000n;
|
|
@@ -32055,14 +32688,7 @@ function preparePositionGamma({ tokenId, positionSize, quoteIsToken0, quoteDecim
|
|
|
32055
32688
|
const decoded = decodeTokenId(tokenId);
|
|
32056
32689
|
const chunks = decoded.legs.flatMap((leg) => {
|
|
32057
32690
|
if (leg.width === 0n) return [];
|
|
32058
|
-
const
|
|
32059
|
-
const lowerTick = leg.strike - width / 2n;
|
|
32060
|
-
const upperTick = leg.strike + (width + 1n) / 2n;
|
|
32061
|
-
if (lowerTick < -887272n || upperTick > 887272n || lowerTick >= upperTick) throw new RangeError("Invalid position range");
|
|
32062
|
-
const lower = tickToSqrtPriceX96(lowerTick);
|
|
32063
|
-
const upper = tickToSqrtPriceX96(upperTick);
|
|
32064
|
-
const amount = positionSize * leg.optionRatio;
|
|
32065
|
-
const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96) / (upper - lower) : amount * Q96 / (upper - lower);
|
|
32691
|
+
const { lowerTick, upperTick, liquidity } = getLegLiquidityRange(leg, positionSize, decoded.tickSpacing);
|
|
32066
32692
|
if (liquidity >= 1n << 128n) throw new RangeError("Liquidity exceeds uint128");
|
|
32067
32693
|
return [{
|
|
32068
32694
|
lowerTick: Number(lowerTick),
|
|
@@ -32587,5 +33213,5 @@ async function getPositionVolatilityHistory({ client, poolAddress, account, toke
|
|
|
32587
33213
|
}
|
|
32588
33214
|
|
|
32589
33215
|
//#endregion
|
|
32590
|
-
export { AccountInsolventError, AlreadyInitializedError, BORROW_INDEX_BITS, BPS_DENOMINATOR, BPS_SCALE, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MARKET_INDICATOR_PERIODS, MAX_TICK, MAX_TRACKED_CHUNKS, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MIN_TICK, MaxRetriesExceededError, MissingPositionIdsError, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, ORACLE_EPOCH_SECONDS, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, RATE_AT_TARGET_BITS, REORG_DEPTH, REQUIRED_BASE_ERROR_SENTINEL, ReentrancyError, RpcError, RpcResponseError, SCHEMA_VERSION, SECONDS_PER_YEAR, STANDARD_TICK_WIDTHS, STORAGE_PREFIX, STRIKE_LADDER_TARGET_STRIKES, SafeModeError, StaleDataError, StaleOracleError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UNREALIZED_INTEREST_BITS, UTILIZATION_DENOMINATOR, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, VARIANCE_RATIO_LAG, WAD, WrongPoolIdError, WrongUniswapPoolError, ZERO_COLLATERAL, ZERO_VALUATION, ZeroAddressError, ZeroCollateralRequirementError, addLegToTokenId, addPendingPosition, addTrackedChunks, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, apportion, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildCreditWrappedDispatch, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateAccountGreeksPure, calculateMarketIndicator, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, calculatePositionVolatilityMetrics, calculateResyncBlock, calculateSpreadWad, calculateVarianceProfile, cancelTransaction, checkApproval, checkCollateralAcrossTicks, classifyStrategyGroups, classifyStrike, cleanupStalePendingPositions, clearCheckpoint, clearPendingPositions, clearTrackedChunks, clearTrackedPositions, clearTradeHistory, closePosition, closePositionAndWait, collateralCurveTicks, collateralRuleKindFor, collateralTrackerV2Abi, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, countLegs, createEventPoller, createEventSubscription, createFileStorage, createFlowNeutralTokenId, createMemoryStorage, createNonceManager, createPoolFormatters, createTokenIdBuilder, decodeAllDispatchCalldata, decodeAllLegs, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeLeg, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePanopticTokenURI, decodePoolId, decodeTickSpacing, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, deriveSupplyRatePerSecWad, deriveUniqueTokenId, detectReorg, diagnoseOracleSafeMode, dispatch, dispatchAndWait, emptyLiquidateParams, encodeLeg, encodePoolId, encodePoolKeyBytes, encodeV3PoolKeyBytes, encodeV4PoolId, ensureSfpmV3PoolInitialized, estimateBlockNumbers, estimateCloseZapSwap, estimateCollateralBreakdown, estimateCollateralRequired, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, failPendingPosition, feeGrowthInsideX128, feesFromFeeGrowthDelta, fetchPoolId, fetchSfpmV3PoolId, fetchUniswapFeeData, forceExercise, forceExerciseAndWait, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatPoolIdHex, formatPriceRange, formatRateWad, formatRatioPercent, formatTick, formatTickRange, formatTimestamp, formatTimestampLocale, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWad, formatWadPercent, formatWadSigned, formatWei, generateOverlappingTokenIds, getAccountBuyingPower, getAccountCollateral, getAccountGreeks, getAccountHistory, getAccountPremia, getAccountSummaryBasic, getAccountSummaryRisk, getAssetIndex, getBlockMeta, getChainDeployment, getChunkLiquidities, getChunkSpreads, getClosePositionTransferEstimate, getClosedPositions, getClosedPositionsKey, getCollateralAddresses, getCollateralCurve, getCollateralCurveInputs, getCollateralData, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getCurrentRates, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getForfeitablePremium, getGuardianUnlockState, getHedgeLimits, getInterestState, getIrmCurrent, getIrmCurve, getItmAmounts, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLiquidationPrices, getMarginBuffer, getMaxPositionSize, getMaxRedeem, getMaxWithdrawable, getNativeTokenPrice, getNetLiquidationValue, getNetLiquidationValues, getNotEnoughTokensError, getOpenPositionIds, getOpenPositionPreview, getOracleRiskParameters, getOracleState, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPendingPositionsKey, getPool, getPoolCurrentTick, getPoolDeploymentBlock, getPoolDisplayId, getPoolLiquidities, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPortfolioValue, getPosition, getPositionChunkData, getPositionDeltaMetrics, getPositionEnrichmentData, getPositionGreeks, getPositionMetaKey, getPositionValueCurve, getPositionVolatilityHistory, getPositions, getPositionsKey, getPositionsWithPremia, getPriceHistory, getPricesAtTick, getRealizedPnL, getRequiredCreditForITM, getRiskParameters, getSafeMode, getSchemaVersionKey, getSimpleLoanTokenIndex, getStreamiaHistory, getSyncCheckpointKey, getSyncStatus, getTickSpacing, getTokenListId, getTrackedChunks, getTrackedChunksKey, getTrackedPositionIds, getTradeHistory, getUniswapFeeHistory, getUniswapV3LpPositionState, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4LpPositionState, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, getUtilization, hasLoanOrCredit, hasLongLeg, interpolateBlocks, isCall, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, prepareLiquidityGamma, preparePositionGamma, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewRepay, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, quoteV3ExactIn, ratePerSecWadToAprPct, realizedBeta, reconstructFromEvents, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, removeTrackedChunks, repay, repayAndWait, requireChainDeployment, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveTokenIndex, resolveUniswapV4PoolKey, riskEngineAbi, rollPosition, rollPositionAndWait, roundToTickSpacing, saveCheckpoint, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, selectDispatchForAccount, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, settlePremiumFrom, settlePremiumFromAndWait, simulateBatchDispatch, simulateClosePosition, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateOpenPosition, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateSwapExactIn, simulateSwapExactOut, simulateWithTokenFlow, simulateWithdraw, slippageBpsToTickDistance, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
|
|
33216
|
+
export { AccountInsolventError, AlreadyInitializedError, BORROW_INDEX_BITS, BPS_DENOMINATOR, BPS_SCALE, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MARKET_INDICATOR_PERIODS, MAX_TICK, MAX_TRACKED_CHUNKS, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MIN_TICK, MaxRetriesExceededError, MissingPositionIdsError, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, ORACLE_EPOCH_SECONDS, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, RATE_AT_TARGET_BITS, REORG_DEPTH, REQUIRED_BASE_ERROR_SENTINEL, ReentrancyError, RpcError, RpcResponseError, SCHEMA_VERSION, SECONDS_PER_YEAR, STANDARD_TICK_WIDTHS, STORAGE_PREFIX, STRIKE_LADDER_TARGET_STRIKES, SafeModeError, StaleDataError, StaleOracleError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UNREALIZED_INTEREST_BITS, UTILIZATION_DENOMINATOR, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, VARIANCE_RATIO_LAG, WAD, WrongPoolIdError, WrongUniswapPoolError, ZERO_COLLATERAL, ZERO_VALUATION, ZeroAddressError, ZeroCollateralRequirementError, addLegToTokenId, addPendingPosition, addTrackedChunks, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, apportion, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildCreditWrappedDispatch, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateAccountGreeksPure, calculateMarketIndicator, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, calculatePositionVolatilityMetrics, calculateResyncBlock, calculateSpreadWad, calculateVarianceProfile, cancelTransaction, checkApproval, checkCollateralAcrossTicks, classifyStrategyGroups, classifyStrike, cleanupStalePendingPositions, clearCheckpoint, clearPendingPositions, clearTrackedChunks, clearTrackedPositions, clearTradeHistory, closePosition, closePositionAndWait, collateralCurveTicks, collateralRuleKindFor, collateralTrackerV2Abi, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, countLegs, createEventPoller, createEventSubscription, createFileStorage, createFlowNeutralTokenId, createMemoryStorage, createNonceManager, createPoolFormatters, createTokenIdBuilder, decodeAllDispatchCalldata, decodeAllLegs, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeLeg, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePanopticTokenURI, decodePoolId, decodeTickSpacing, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, deriveSupplyRatePerSecWad, deriveUniqueTokenId, detectReorg, diagnoseOracleSafeMode, dispatch, dispatchAndWait, emptyLiquidateParams, encodeLeg, encodePoolId, encodePoolKeyBytes, encodeV3PoolKeyBytes, encodeV4PoolId, ensureSfpmV3PoolInitialized, estimateBlockNumbers, estimateCloseZapSwap, estimateCollateralBreakdown, estimateCollateralRequired, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, failPendingPosition, feeGrowthInsideX128, feesFromFeeGrowthDelta, fetchPoolId, fetchSfpmV3PoolId, fetchUniswapFeeData, forceExercise, forceExerciseAndWait, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatPoolIdHex, formatPriceRange, formatRateWad, formatRatioPercent, formatTick, formatTickRange, formatTimestamp, formatTimestampLocale, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWad, formatWadPercent, formatWadSigned, formatWei, generateOverlappingTokenIds, getAccountBuyingPower, getAccountCollateral, getAccountGreeks, getAccountHistory, getAccountPremia, getAccountSummaryBasic, getAccountSummaryRisk, getAssetIndex, getBlockMeta, getChainDeployment, getChunkLiquidities, getChunkSpreads, getClosePositionTransferEstimate, getClosedPositions, getClosedPositionsKey, getCollateralAddresses, getCollateralCurve, getCollateralCurveInputs, getCollateralData, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getCurrentRates, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getForfeitablePremium, getGuardianUnlockState, getHedgeLimits, getInterestState, getIrmCurrent, getIrmCurve, getItmAmounts, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLiquidationPrices, getMarginBuffer, getMaxPositionSize, getMaxRedeem, getMaxWithdrawable, getNativeTokenPrice, getNetLiquidationValue, getNetLiquidationValues, getNotEnoughTokensError, getOpenPositionIds, getOpenPositionPreview, getOracleRiskParameters, getOracleState, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPendingPositionsKey, getPool, getPoolCurrentTick, getPoolDeploymentBlock, getPoolDisplayId, getPoolLiquidities, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPortfolioValue, getPosition, getPositionChunkData, getPositionDeltaMetrics, getPositionEnrichmentData, getPositionGreeks, getPositionMetaKey, getPositionValueCurve, getPositionVolatilityHistory, getPositions, getPositionsKey, getPositionsWithPremia, getPriceHistory, getPricesAtTick, getRealizedPnL, getRequiredCreditForITM, getRiskParameters, getSafeMode, getSchemaVersionKey, getSimpleLoanTokenIndex, getStreamiaHistory, getSyncCheckpointKey, getSyncStatus, getTickSpacing, getTokenListId, getTrackedChunks, getTrackedChunksKey, getTrackedPositionIds, getTradeHistory, getUniswapFeeHistory, getUniswapV3LpPositionState, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4LpPositionState, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, getUtilization, hasLoanOrCredit, hasLongLeg, interpolateBlocks, isCall, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, prepareLiquidityGamma, preparePositionGamma, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewRepay, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, quoteTokenShortfallSwap, quoteV3ExactIn, ratePerSecWadToAprPct, realizedBeta, reconstructFromEvents, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, removeTrackedChunks, repay, repayAndWait, requireChainDeployment, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveTokenIndex, resolveUniswapV4PoolKey, riskEngineAbi, rollPosition, rollPositionAndWait, roundToTickSpacing, saveCheckpoint, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, selectDispatchForAccount, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, settlePremiumFrom, settlePremiumFromAndWait, simulateBatchDispatch, simulateClosePosition, simulateClosePremiumProtection, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateOpenPosition, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateSwapExactIn, simulateSwapExactOut, simulateWithTokenFlow, simulateWithdraw, slippageBpsToTickDistance, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
|
|
32591
33217
|
//# sourceMappingURL=index.js.map
|