@panoptic-eng/sdk 1.0.37 → 1.0.39

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.
Files changed (74) hide show
  1. package/dist/cow/index.d.ts +804 -6
  2. package/dist/cow/index.d.ts.map +1 -0
  3. package/dist/cow/index.js +5268 -5
  4. package/dist/cow/index.js.map +1 -0
  5. package/dist/{cow-aX6of9TS.js → cow-tRUtAUZy.js} +2 -3
  6. package/dist/deployments.d.ts +3 -2
  7. package/dist/deployments.d.ts.map +1 -1
  8. package/dist/deployments.js +4 -0
  9. package/dist/deployments.js.map +1 -1
  10. package/dist/{position-C8rkkKhi.js → getTrackedPositionIds-ms3W9dYB.js} +1085 -34
  11. package/dist/greeks-GysWXct-.js +1 -2
  12. package/dist/index.d.ts +5907 -39
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +12192 -2117
  15. package/dist/index.js.map +1 -1
  16. package/dist/{irm-DnM96-X4.js → irm-SPC2KxLA.js} +6 -3
  17. package/dist/panoptic/v2/greeks/index.d.ts +277 -3
  18. package/dist/panoptic/v2/greeks/index.d.ts.map +1 -0
  19. package/dist/panoptic/v2/greeks/index.js +620 -2
  20. package/dist/panoptic/v2/greeks/index.js.map +1 -0
  21. package/dist/panoptic/v2/index.d.ts +14633 -8
  22. package/dist/panoptic/v2/index.d.ts.map +1 -0
  23. package/dist/panoptic/v2/index.js +27875 -8
  24. package/dist/panoptic/v2/index.js.map +1 -0
  25. package/dist/panoptic/v2/react-public.d.ts +14797 -17
  26. package/dist/panoptic/v2/react-public.d.ts.map +1 -1
  27. package/dist/panoptic/v2/react-public.js +29503 -89
  28. package/dist/panoptic/v2/react-public.js.map +1 -1
  29. package/dist/{router-DcoU2KmV.js → router-BTfbaRfg.js} +2 -3
  30. package/dist/{router-CS86ptMu.js → router-mLWy0MD9.js} +3 -4
  31. package/dist/test/index.d.ts +1 -1
  32. package/dist/test/index.js +2 -2
  33. package/dist/transactionFees-C_Qx07mx.js +174 -0
  34. package/dist/uniswap/index.d.ts +813 -79
  35. package/dist/uniswap/index.d.ts.map +1 -1
  36. package/dist/uniswap/index.js +5884 -13
  37. package/dist/uniswap/index.js.map +1 -1
  38. package/dist/{v2-D0dEatKb.js → v2-DG7qG6di.js} +3266 -2675
  39. package/dist/vault-transaction-fees.d.ts +63 -0
  40. package/dist/vault-transaction-fees.d.ts.map +1 -0
  41. package/dist/vault-transaction-fees.js +175 -0
  42. package/dist/vault-transaction-fees.js.map +1 -0
  43. package/dist/{writes-AupZCK4M.js → writes-Xp9Wa8GQ.js} +325 -1292
  44. package/package.json +8 -3
  45. package/dist/cow/types.d.ts +0 -3
  46. package/dist/cow/types.js +0 -0
  47. package/dist/cow-aX6of9TS.js.map +0 -1
  48. package/dist/greeks-GysWXct-.js.map +0 -1
  49. package/dist/index-CURXeKNy.d.ts +0 -9706
  50. package/dist/index-CURXeKNy.d.ts.map +0 -1
  51. package/dist/index-Cp-nCeV2.d.ts +0 -276
  52. package/dist/index-Cp-nCeV2.d.ts.map +0 -1
  53. package/dist/index-Zvu-rJpV.d.ts +0 -261
  54. package/dist/index-Zvu-rJpV.d.ts.map +0 -1
  55. package/dist/irm-CmgC1Mqi.d.ts +0 -5694
  56. package/dist/irm-CmgC1Mqi.d.ts.map +0 -1
  57. package/dist/irm-DnM96-X4.js.map +0 -1
  58. package/dist/position-BqIgubs5.d.ts +0 -199
  59. package/dist/position-BqIgubs5.d.ts.map +0 -1
  60. package/dist/position-C8rkkKhi.js.map +0 -1
  61. package/dist/quote-BxQkPBRg.d.ts +0 -718
  62. package/dist/quote-BxQkPBRg.d.ts.map +0 -1
  63. package/dist/router-CS86ptMu.js.map +0 -1
  64. package/dist/router-DcoU2KmV.js.map +0 -1
  65. package/dist/simulation-zM6-YUaw.d.ts +0 -258
  66. package/dist/simulation-zM6-YUaw.d.ts.map +0 -1
  67. package/dist/tx-CbDQ58Io.d.ts +0 -367
  68. package/dist/tx-CbDQ58Io.d.ts.map +0 -1
  69. package/dist/types-BHdnurYr.d.ts +0 -128
  70. package/dist/types-BHdnurYr.d.ts.map +0 -1
  71. package/dist/types-D_jcYss-.d.ts +0 -248
  72. package/dist/types-D_jcYss-.d.ts.map +0 -1
  73. package/dist/v2-D0dEatKb.js.map +0 -1
  74. package/dist/writes-AupZCK4M.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { MulticallNoDataError, MulticallResultFailedError, MulticallResultMissingError, PanopticValidationError$1 as PanopticValidationError, collateralTrackerV2Abi, decodeLeftRightUnsigned$1 as decodeLeftRightUnsigned, getBlockMeta$1 as getBlockMeta, getPool, getPositions$1 as getPositions, panopticPoolV2Abi, riskEngineAbi } from "./position-C8rkkKhi.js";
1
+ import { MulticallNoDataError, MulticallResultFailedError, MulticallResultMissingError, PanopticValidationError, collateralTrackerV2Abi, decodeLeftRightUnsigned, getBlockMeta, getPool, getPositions, panopticPoolV2Abi, riskEngineAbi } from "./getTrackedPositionIds-ms3W9dYB.js";
2
2
  import { tickToSqrtPriceX96 } from "./greeks-GysWXct-.js";
3
3
  import { decodeFunctionResult, encodeFunctionData } from "viem";
4
4
  import { call } from "viem/actions";
@@ -2317,11 +2317,13 @@ var _1 = {
2317
2317
  },
2318
2318
  "panoptic": {
2319
2319
  "pool": {
2320
+ "version": "v4",
2320
2321
  "panopticPool": "0x00000000563b70d704f4c6675a5f6ac989fbae13",
2321
2322
  "collateralTracker0": "0x1e46b0289B7E0F710E2Db8Ab87800dd782D624f7",
2322
2323
  "collateralTracker1": "0x12bF31955522BAC337D93e1bC0a39F68D8BDa216"
2323
2324
  },
2324
2325
  "additionalPools": { "ethUsdc5bpsV3": {
2326
+ "version": "v3",
2325
2327
  "panopticPool": "0x00000000009C7B687e833559e34503f64d7ed7c4",
2326
2328
  "collateralTracker0": "0x3CCdA7d5E841d6543D90BcEc20b36a724C184DE9",
2327
2329
  "collateralTracker1": "0x69E9f9e44E5F52237493b980dd7306198C64A4E4"
@@ -2396,6 +2398,7 @@ var _8453 = {
2396
2398
  },
2397
2399
  "panoptic": {
2398
2400
  "pool": {
2401
+ "version": "v4",
2399
2402
  "panopticPool": "0xB50e8bb68f5855DA742f4579274902a20454174a",
2400
2403
  "collateralTracker0": "0x0d82b189c96EbB1f44A7207e6A9cfB1e490f2869",
2401
2404
  "collateralTracker1": "0x9ba1082Ab3cb9edEA988697A14BBe543A3dABEd2"
@@ -2458,6 +2461,7 @@ var _11155111 = {
2458
2461
  },
2459
2462
  "panoptic": {
2460
2463
  "pool": {
2464
+ "version": "v4",
2461
2465
  "panopticPool": "0x872b98C46b2062F663BEb2CC9D4cE046Da2a2918",
2462
2466
  "collateralTracker0": "0x09a60b78d06a03e5148faedd3bfee6f58b22012f",
2463
2467
  "collateralTracker1": "0x7365664c8101ff7e9422ae2b203822253c31e69c"
@@ -3001,5 +3005,4 @@ async function getIrmCurve(params) {
3001
3005
  }
3002
3006
 
3003
3007
  //#endregion
3004
- export { BASE_CHAIN_ID, BASE_DEPLOYMENT, BASE_ETH_USDC_5BPS_MARKET, BASE_HYPOVAULT_ADDRESSES, BASE_HYPOVAULT_CORE_ADDRESSES, BASE_HYPOVAULT_MANAGER_ADDRESSES, BASE_HYPOVAULT_MANAGER_TURNKEY_SIGNERS, BASE_PANOPTIC_POOL_ADDRESSES, BASE_PANOPTIC_V2_ADDRESSES, BORROW_INDEX_BITS, BPS_SCALE, CHAIN_DEPLOYMENTS, MAINNET_CHAIN_ID, MAINNET_DEPLOYMENT, MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES, MAINNET_PANOPTIC_V2_ADDRESSES, MAINNET_RISK_ENGINES, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, Multicall3Abi, RATE_AT_TARGET_BITS, SECONDS_PER_YEAR, SEPOLIA_CHAIN_ID, SEPOLIA_DEPLOYMENT, SEPOLIA_ETH_USDC_5BPS_MARKET, SEPOLIA_HYPOVAULT_ADDRESSES, SEPOLIA_HYPOVAULT_CORE_ADDRESSES, SEPOLIA_HYPOVAULT_MANAGER_ADDRESSES, SEPOLIA_HYPOVAULT_MANAGER_TURNKEY_SIGNERS, SEPOLIA_PANOPTIC_POOL_ADDRESSES, SEPOLIA_PANOPTIC_V2_ADDRESSES, StateViewAbi, UNREALIZED_INTEREST_BITS, VAULT_DISPLAY_NAMES_PER_CHAIN, VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN, WAD as WAD$2, annualizePerSecondRateWad, deriveSupplyRatePerSecWad, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatRateWad as formatRateWad$1, formatTokenAmount as formatTokenAmount$1, formatTokenAmountSigned as formatTokenAmountSigned$1, formatTokenDelta as formatTokenDelta$1, formatTokenFlow as formatTokenFlow$1, formatWad as formatWad$1, formatWadPercent as formatWadPercent$1, formatWadSigned as formatWadSigned$1, getAccountCollateral as getAccountCollateral$1, getAccountSummaryBasic as getAccountSummaryBasic$1, getAccountSummaryRisk as getAccountSummaryRisk$1, getChainDeployment, getCollateralAddresses as getCollateralAddresses$1, getCollateralData as getCollateralData$1, getCurrentRates as getCurrentRates$1, getEthUsdcMarket, getInterestState as getInterestState$1, getIrmCurrent, getIrmCurve, getLiquidationPrices as getLiquidationPrices$1, getNetLiquidationValue as getNetLiquidationValue$1, getNetLiquidationValues as getNetLiquidationValues$1, isLiquidatable as isLiquidatable$1, isSupportedChain, packMarketState, panopticQueryAbi, parseTokenAmount as parseTokenAmount$1, parseWad as parseWad$1, ratePerSecWadToAprPct, readBlockAndAggregate, requireChainDeployment, requireReturnData, resolveVaultDisplayName, utilizationBpsToWad, utilizationPctToWad };
3005
- //# sourceMappingURL=irm-DnM96-X4.js.map
3008
+ export { BASE_CHAIN_ID, BASE_DEPLOYMENT, BASE_ETH_USDC_5BPS_MARKET, BASE_HYPOVAULT_ADDRESSES, BASE_HYPOVAULT_CORE_ADDRESSES, BASE_HYPOVAULT_MANAGER_ADDRESSES, BASE_HYPOVAULT_MANAGER_TURNKEY_SIGNERS, BASE_PANOPTIC_POOL_ADDRESSES, BASE_PANOPTIC_V2_ADDRESSES, BORROW_INDEX_BITS, BPS_SCALE, CHAIN_DEPLOYMENTS, MAINNET_CHAIN_ID, MAINNET_DEPLOYMENT, MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES, MAINNET_PANOPTIC_V2_ADDRESSES, MAINNET_RISK_ENGINES, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, Multicall3Abi, RATE_AT_TARGET_BITS, SECONDS_PER_YEAR, SEPOLIA_CHAIN_ID, SEPOLIA_DEPLOYMENT, SEPOLIA_ETH_USDC_5BPS_MARKET, SEPOLIA_HYPOVAULT_ADDRESSES, SEPOLIA_HYPOVAULT_CORE_ADDRESSES, SEPOLIA_HYPOVAULT_MANAGER_ADDRESSES, SEPOLIA_HYPOVAULT_MANAGER_TURNKEY_SIGNERS, SEPOLIA_PANOPTIC_POOL_ADDRESSES, SEPOLIA_PANOPTIC_V2_ADDRESSES, StateViewAbi, UNREALIZED_INTEREST_BITS, VAULT_DISPLAY_NAMES_PER_CHAIN, VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN, WAD as WAD$1, annualizePerSecondRateWad, deriveSupplyRatePerSecWad, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatRateWad, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatWad, formatWadPercent, formatWadSigned, getAccountCollateral, getAccountSummaryBasic, getAccountSummaryRisk, getChainDeployment, getCollateralAddresses, getCollateralData, getCurrentRates, getEthUsdcMarket, getInterestState, getIrmCurrent, getIrmCurve, getLiquidationPrices, getNetLiquidationValue, getNetLiquidationValues, isLiquidatable, isSupportedChain, packMarketState, panopticQueryAbi as panopticQueryAbi$1, parseTokenAmount, parseWad, ratePerSecWadToAprPct, readBlockAndAggregate, requireChainDeployment, requireReturnData, resolveVaultDisplayName, utilizationBpsToWad, utilizationPctToWad };
@@ -1,3 +1,277 @@
1
- import "../../../position-BqIgubs5.js";
2
- import { PositionGreeksInput, PositionGreeksResult, calculatePortfolioDelta$1 as calculatePortfolioDelta, calculatePortfolioGamma$1 as calculatePortfolioGamma, calculatePortfolioGreeks$1 as calculatePortfolioGreeks, calculatePortfolioValue$1 as calculatePortfolioValue, calculatePositionDelta$1 as calculatePositionDelta, calculatePositionDeltaDebtOnly$1 as calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap$1 as calculatePositionDeltaWithSwap, calculatePositionGamma$1 as calculatePositionGamma, calculatePositionGreeks$1 as calculatePositionGreeks, calculatePositionValue$1 as calculatePositionValue, getLegDelta$1 as getLegDelta, getLegDeltaInVaultFrame$1 as getLegDeltaInVaultFrame, getLegGamma$1 as getLegGamma, getLegNetValueWidth0$1 as getLegNetValueWidth0, getLegValue$1 as getLegValue, getLoanEffectiveDelta$1 as getLoanEffectiveDelta, isCall$1 as isCall, isDefinedRisk$1 as isDefinedRisk, toVaultFrameAtTick$1 as toVaultFrameAtTick } from "../../../index-Zvu-rJpV.js";
3
- export { PositionGreeksInput, PositionGreeksResult, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLoanEffectiveDelta, isCall, isDefinedRisk, toVaultFrameAtTick };
1
+ import "viem";
2
+
3
+ //#region src/panoptic/v2/types/position.d.ts
4
+ /**
5
+ * A single leg of a TokenId.
6
+ */
7
+
8
+ /**
9
+ * A single leg of a TokenId.
10
+ */
11
+ interface TokenIdLeg {
12
+ /** Leg index (0-3) */
13
+ index: bigint;
14
+ /** Asset index (0 or 1) */
15
+ asset: bigint;
16
+ /** Option ratio (1-127) */
17
+ optionRatio: bigint;
18
+ /** Whether this is a long position (true) or short (false) */
19
+ isLong: boolean;
20
+ /** Token type (0 or 1) - which token is being moved */
21
+ tokenType: bigint;
22
+ /** Risk partner leg index (for spreads) */
23
+ riskPartner: bigint;
24
+ /** Strike tick (center of the range) */
25
+ strike: bigint;
26
+ /** Width in tick spacing units */
27
+ width: bigint;
28
+ /** Lower tick of the range */
29
+ tickLower: bigint;
30
+ /** Upper tick of the range */
31
+ tickUpper: bigint;
32
+ } //#endregion
33
+ //#region src/panoptic/v2/greeks/index.d.ts
34
+
35
+ /**
36
+ * Position data.
37
+ */
38
+
39
+ /**
40
+ * Calculate the NET (user-experienced) payoff value for a width=0 (loan/credit) leg.
41
+ *
42
+ * Unlike `getLegValueWidth0` (debt-only), this includes the collateral/holding side and
43
+ * therefore depends on how the position was opened:
44
+ *
45
+ * - **Cover at mint** (`swapAtMint = false`): the collateral is sourced in the SAME token as
46
+ * the debt/credit, so the holding side exactly offsets it → net PnL is FLAT (0 everywhere,
47
+ * mint-relative), regardless of which token the leg is denominated in.
48
+ * - **Zap** (`swapAtMint = true`): the collateral is sourced in the OTHER token, leaving a
49
+ * ±1-delta line in the asset (ETH), anchored to 0 at the mint price:
50
+ * - USDC loan → zap to ETH: +1 (long ETH)
51
+ * - ETH loan → zap to USDC: −1 (short ETH)
52
+ * - USDC credit ← zap from ETH: −1 (short ETH)
53
+ * - ETH credit ← zap from USDC: +1 (long ETH)
54
+ *
55
+ * @returns Net leg value in numeraire token smallest units (mint-relative PnL).
56
+ */
57
+ declare function getLegNetValueWidth0(leg: TokenIdLeg, m: bigint, qCurrentTick: bigint, qMintTick: bigint, isAssetToken0: boolean, swapAtMint: boolean, itmOffsetNotional?: bigint): bigint;
58
+ /**
59
+ * Check if leg is a call option (vs put).
60
+ *
61
+ * A call is when the leg moves the asset token:
62
+ * - If asset is token0: call when tokenType=0
63
+ * - If asset is token1: call when tokenType=1
64
+ */
65
+ declare function isCall(tokenType: bigint, isAssetToken0: boolean): boolean;
66
+ /**
67
+ * Check if position has defined risk (is a spread).
68
+ *
69
+ * A position is defined risk if it has 2+ legs of the same tokenType
70
+ * with both long and short exposure.
71
+ */
72
+ declare function isDefinedRisk(legs: Pick<TokenIdLeg, 'tokenType' | 'isLong'>[]): boolean;
73
+ /**
74
+ * Calculate the value of a single leg.
75
+ *
76
+ * Value represents the current P&L of the position in numeraire token units.
77
+ * Combines base value (from Panoptic's piecewise formula), debt, and ITM adjustment.
78
+ *
79
+ * Uses sqrtPriceX96 for all calculations to maintain precision and on-chain fidelity.
80
+ *
81
+ * @param leg - The leg to calculate
82
+ * @param currentTick - Current pool tick
83
+ * @param mintTick - Tick at position mint
84
+ * @param positionSize - Position size in asset token smallest units
85
+ * @param poolTickSpacing - Pool tick spacing
86
+ * @param definedRisk - Whether position is defined risk
87
+ * @param assetIndex - Optional override for leg.asset (0n = token0 is asset, 1n = token1)
88
+ * @returns Leg value in numeraire token smallest units
89
+ */
90
+ declare function getLegValue(leg: TokenIdLeg, currentTick: bigint, mintTick: bigint, positionSize: bigint, poolTickSpacing: bigint, definedRisk: boolean, assetIndex?: bigint, swapAtMint?: boolean): bigint;
91
+ /**
92
+ * Calculate the delta of a single leg.
93
+ *
94
+ * Delta is the rate of change of position value with respect to price.
95
+ * For puts: delta = vDelta
96
+ * For calls: delta = debtDelta + vDelta + itmDelta (if not defined risk)
97
+ *
98
+ * Uses sqrtPriceX96 for all price calculations to maintain precision.
99
+ *
100
+ * @param leg - The leg to calculate
101
+ * @param currentTick - Current pool tick
102
+ * @param positionSize - Position size in asset token smallest units
103
+ * @param poolTickSpacing - Pool tick spacing
104
+ * @param mintTick - Tick at mint (optional, for ITM adjustment)
105
+ * @param definedRisk - Whether position is defined risk
106
+ * @param assetIndex - Optional override for leg.asset (0n = token0 is asset, 1n = token1)
107
+ * @returns Leg delta in asset token smallest units
108
+ */
109
+ declare function getLegDelta(leg: TokenIdLeg, currentTick: bigint, positionSize: bigint, poolTickSpacing: bigint, mintTick: bigint | undefined, definedRisk: boolean, assetIndex?: bigint): bigint;
110
+ /** Convert a delta between token frames at the current pool tick. */
111
+ declare function toVaultFrameAtTick(delta: bigint, fromAsset: bigint, vaultAssetIndex: 0n | 1n, currentTick: bigint, flipSignOnAssetInversion?: boolean): bigint;
112
+ /**
113
+ * Calculate one leg's wallet-aware delta in the vault asset frame.
114
+ *
115
+ * Width-zero loans and credits must be evaluated directly in the vault frame.
116
+ * Option legs remain in their natural leg frame until converted at the mark tick.
117
+ */
118
+ declare function getLegDeltaInVaultFrame(leg: TokenIdLeg, currentTick: bigint, positionSize: bigint, poolTickSpacing: bigint, mintTick: bigint | undefined, definedRisk: boolean, vaultAssetIndex: 0n | 1n): bigint;
119
+ /**
120
+ * Calculate the gamma (dollar gamma) of a single leg.
121
+ *
122
+ * Formula: gamma = (m * sqrt(K * P * r)) / (2 * (r - 1))
123
+ * where:
124
+ * - m = positionSize * optionRatio (with sign based on long/short)
125
+ * - K = strike price (numeraire/asset)
126
+ * - P = current price (numeraire/asset)
127
+ * - r = 1.0001^(width*tickSpacing/2) ≈ 1 (dimensionless ratio)
128
+ *
129
+ * Uses sqrtPriceX96 arithmetic:
130
+ * - sqrt(K*P*r) = tickToSqrtPriceX96(strikeₜ + currentₜ + widthₜ/2)
131
+ * - Keeps X96/X192 precision until final division
132
+ *
133
+ * @param leg - The leg to calculate
134
+ * @param currentTick - Current pool tick
135
+ * @param positionSize - Position size in asset token smallest units
136
+ * @param poolTickSpacing - Pool tick spacing
137
+ * @param assetIndex - Optional override for leg.asset (0n = token0 is asset, 1n = token1)
138
+ * @returns Leg gamma in numeraire token smallest units
139
+ */
140
+ declare function getLegGamma(leg: TokenIdLeg, currentTick: bigint, positionSize: bigint, poolTickSpacing: bigint, assetIndex?: bigint): bigint;
141
+ /**
142
+ * Parameters for position-level greek calculations.
143
+ */
144
+ interface PositionGreeksInput {
145
+ /** Position legs */
146
+ legs: TokenIdLeg[];
147
+ /** Current pool tick */
148
+ currentTick: bigint;
149
+ /** Tick at position mint */
150
+ mintTick: bigint;
151
+ /** Position size in asset token smallest units */
152
+ positionSize: bigint;
153
+ /** Pool tick spacing */
154
+ poolTickSpacing: bigint;
155
+ /** Optional override for leg.asset on all legs (0n = token0 is asset, 1n = token1) */
156
+ assetIndex?: bigint;
157
+ /**
158
+ * How width=0 (loan/credit) legs were opened. When provided, `calculatePositionValue`
159
+ * returns the NET user-experienced payoff for those legs (Zap = ±1 line, Cover = flat)
160
+ * instead of the debt-only value. Leave undefined for delta/greeks aggregation, which
161
+ * accounts for the held collateral separately.
162
+ */
163
+ swapAtMint?: boolean;
164
+ }
165
+ /**
166
+ * Calculate total value across all legs.
167
+ */
168
+ declare function calculatePositionValue(input: PositionGreeksInput): bigint;
169
+ /**
170
+ * Calculate total delta across all legs.
171
+ */
172
+ declare function calculatePositionDelta(input: PositionGreeksInput): bigint;
173
+ /**
174
+ * Calculate debt-only position delta in a single target asset frame.
175
+ *
176
+ * Option legs are first valued in their natural `leg.asset` frame, then
177
+ * converted into `assetIndex` using the current pool price. Width-zero legs
178
+ * are evaluated directly in the target frame.
179
+ *
180
+ * Width=0 loan/credit legs include only their debt obligation. The held-token
181
+ * side must be added separately from account collateral balances, preventing a
182
+ * zap from being counted once in the position and again in collateral.
183
+ */
184
+ declare function calculatePositionDeltaDebtOnly(input: Omit<PositionGreeksInput, 'assetIndex' | 'swapAtMint'> & {
185
+ assetIndex: 0n | 1n;
186
+ }): bigint;
187
+ /**
188
+ * Calculate total gamma across all legs.
189
+ */
190
+ declare function calculatePositionGamma(input: PositionGreeksInput): bigint;
191
+ /**
192
+ * Position greeks result.
193
+ */
194
+ interface PositionGreeksResult {
195
+ /** Position value in numeraire token smallest units */
196
+ value: bigint;
197
+ /** Position delta in asset token smallest units */
198
+ delta: bigint;
199
+ /** Position gamma in numeraire token smallest units */
200
+ gamma: bigint;
201
+ }
202
+ /**
203
+ * Calculate all greeks for a position.
204
+ */
205
+ declare function calculatePositionGreeks(input: PositionGreeksInput): PositionGreeksResult;
206
+ /**
207
+ * Aggregate value across multiple independent positions.
208
+ *
209
+ * Each entry is valued with its OWN `positionSize`, `mintTick`, and legs, then
210
+ * summed. Do NOT collapse multiple positions into one synthetic `PositionGreeksInput`
211
+ * with a shared `positionSize` — `m = positionSize * optionRatio` is per-position, so a
212
+ * shared size double-counts (and integer `optionRatio` cannot encode fractional shares).
213
+ *
214
+ * @param positions - One `PositionGreeksInput` per open position
215
+ * @returns Total value in numeraire token smallest units
216
+ */
217
+ declare function calculatePortfolioValue(positions: PositionGreeksInput[]): bigint;
218
+ /**
219
+ * Aggregate delta across multiple independent positions.
220
+ *
221
+ * See {@link calculatePortfolioValue} for why each position must keep its own
222
+ * `positionSize` rather than being merged into one synthetic position.
223
+ *
224
+ * @param positions - One `PositionGreeksInput` per open position
225
+ * @returns Total delta in asset token smallest units
226
+ */
227
+ declare function calculatePortfolioDelta(positions: PositionGreeksInput[]): bigint;
228
+ /**
229
+ * Aggregate gamma across multiple independent positions.
230
+ *
231
+ * See {@link calculatePortfolioValue} for why each position must keep its own
232
+ * `positionSize` rather than being merged into one synthetic position.
233
+ *
234
+ * @param positions - One `PositionGreeksInput` per open position
235
+ * @returns Total gamma in numeraire token smallest units
236
+ */
237
+ declare function calculatePortfolioGamma(positions: PositionGreeksInput[]): bigint;
238
+ /**
239
+ * Calculate all greeks aggregated across multiple independent positions.
240
+ */
241
+ declare function calculatePortfolioGreeks(positions: PositionGreeksInput[]): PositionGreeksResult;
242
+ /**
243
+ * Calculate the effective delta of a loan leg accounting for swapAtMint.
244
+ *
245
+ * A loan borrows one token and (optionally) swaps it for the other at mint.
246
+ * The net delta depends on whether the swap occurred:
247
+ *
248
+ * | Scenario | Result |
249
+ * |-----------------------|-------------------------------------------------|
250
+ * | No swap | 0n (hold what you owe, net zero) |
251
+ * | Swap + borrows asset | -m (hold numeraire, owe asset → short exposure) |
252
+ * | Swap + borrows numer. | +m (hold asset, owe numeraire → long exposure) |
253
+ *
254
+ * Only meaningful for legs with `width === 0n`. For options, use `getLegDelta`.
255
+ *
256
+ * @param leg - The loan leg
257
+ * @param positionSize - Position size in asset token smallest units
258
+ * @param swapAtMint - Whether the borrowed tokens were swapped at mint
259
+ * @param assetIndex - Optional override for leg.asset (0n = token0 is asset)
260
+ * @returns Effective delta in asset token smallest units
261
+ */
262
+ declare function getLoanEffectiveDelta(leg: TokenIdLeg, positionSize: bigint, swapAtMint: boolean, assetIndex?: bigint): bigint;
263
+ /**
264
+ * Calculate total delta for a position, using swap-aware delta for loan legs.
265
+ *
266
+ * For legs with `width === 0n` (loans/credits), uses `getLoanEffectiveDelta`
267
+ * which accounts for the swapAtMint flag. For option legs (`width > 0n`),
268
+ * uses the standard `getLegDelta`.
269
+ *
270
+ * @param input - Position greeks input plus swapAtMint flag
271
+ * @returns Total delta in asset token smallest units
272
+ */
273
+ declare function calculatePositionDeltaWithSwap(input: PositionGreeksInput & {
274
+ swapAtMint: boolean;
275
+ }): bigint; //#endregion
276
+ export { PositionGreeksInput, PositionGreeksResult, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLoanEffectiveDelta, isCall, isDefinedRisk, toVaultFrameAtTick };
277
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["Address","BlockMeta","TokenIdLeg","Position","LegGreeksParams","PositionGreeks","ClosedPosition","RealizedPnL","StoredPositionData","StoredPoolMeta","TokenIdLeg","getLegNetValueWidth0","isCall","isDefinedRisk","Pick","getLegValue","getLegDelta","toVaultFrameAtTick","getLegDeltaInVaultFrame","getLegGamma","PositionGreeksInput","calculatePositionValue","calculatePositionDelta","calculatePositionDeltaDebtOnly","Omit","calculatePositionGamma","PositionGreeksResult","calculatePositionGreeks","calculatePortfolioValue","calculatePortfolioDelta","calculatePortfolioGamma","calculatePortfolioGreeks","getLoanEffectiveDelta","calculatePositionDeltaWithSwap"],"sources":["../../../../src/panoptic/v2/types/position.d.ts","../../../../src/panoptic/v2/greeks/index.d.ts"],"sourcesContent":null,"mappings":";;;;;;;AASA;;;UAAiBU,UAAAA;;;;;;;;;;;;;;;;;;;EC0BOC;;;;;;;;;;;;;;;;;;;;AAAxB;;;;;;;iBAAwBA,oBAAAA,MAA0BD;AAQlD;;;;;;;AAOwBG,iBAPAD,MAAAA,CAOa,SAAA,EAAA,MAAA,EAAA,aAAA,EAAA,OAAA,CAAA,EAAA,OAAA;;;;AAAW;;;iBAAxBC,aAAAA,OAAoBC,KAAKJ;;;;;;;;;;;;;;;AAkBjD;;;iBAAwBK,WAAAA,MAAiBL;;;;;;;;;;;;;;;;AAmBzC;;AAEA;iBAFwBM,WAAAA,MAAiBN;;iBAEjBO,kBAAAA;;;;AAOxB;;;iBAAwBC,uBAAAA,MAA6BR;;;;;;;;;;;;;;;;;;;AAsBrD;;;iBAAwBS,WAAAA,MAAiBT;AAIzC;;;UAAiBU,mBAAAA;EAwBOC;QAtBdX;;;EA0BcY;;;;;;;;;;;;AAYxB;;EAAsD,UAAaF,CAAAA,EAAAA,OAAAA;;AAAD;;;iBAhB1CC,sBAAAA,QAA8BD;AAsBtD;;;iBAlBwBE,sBAAAA,QAA8BF;AAsBtD;;;;AAWA;;;;AAAiG;;;iBArBzEG,8BAAAA,QAAsCC,KAAKJ;;;;;;iBAM3CK,sBAAAA,QAA8BL;;;AA2BtD;UAvBiBM,oBAAAA;;;;;;;;;AAiCjB;;iBAtBwBC,uBAAAA,QAA+BP,sBAAsBM;;;;;;;;AAgC7E;;;;AAIwBK,iBAxBAH,uBAAAA,CAwBwB,SAAA,EAxBWR,mBAwBX,EAAA,CAAA,EAAA,MAAA;;;;AAAwD;;;;;;iBAdhFS,uBAAAA,YAAmCT;;;;;;;;;;iBAUnCU,uBAAAA,YAAmCV;;;;iBAInCW,wBAAAA,YAAoCX,wBAAwBM;AAqBpF;;;;;;;;;;;AAWA;;;;;;;;;iBAXwBM,qBAAAA,MAA2BtB;;;;;;;;;;;iBAW3BuB,8BAAAA,QAAsCb"}