@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,261 +0,0 @@
1
- import { TokenIdLeg } from "./position-BqIgubs5.js";
2
-
3
- //#region src/panoptic/v2/greeks/index.d.ts
4
- /**
5
- * Calculate the NET (user-experienced) payoff value for a width=0 (loan/credit) leg.
6
- *
7
- * Unlike `getLegValueWidth0` (debt-only), this includes the collateral/holding side and
8
- * therefore depends on how the position was opened:
9
- *
10
- * - **Cover at mint** (`swapAtMint = false`): the collateral is sourced in the SAME token as
11
- * the debt/credit, so the holding side exactly offsets it → net PnL is FLAT (0 everywhere,
12
- * mint-relative), regardless of which token the leg is denominated in.
13
- * - **Zap** (`swapAtMint = true`): the collateral is sourced in the OTHER token, leaving a
14
- * ±1-delta line in the asset (ETH), anchored to 0 at the mint price:
15
- * - USDC loan → zap to ETH: +1 (long ETH)
16
- * - ETH loan → zap to USDC: −1 (short ETH)
17
- * - USDC credit ← zap from ETH: −1 (short ETH)
18
- * - ETH credit ← zap from USDC: +1 (long ETH)
19
- *
20
- * @returns Net leg value in numeraire token smallest units (mint-relative PnL).
21
- */
22
-
23
- /**
24
- * Calculate the NET (user-experienced) payoff value for a width=0 (loan/credit) leg.
25
- *
26
- * Unlike `getLegValueWidth0` (debt-only), this includes the collateral/holding side and
27
- * therefore depends on how the position was opened:
28
- *
29
- * - **Cover at mint** (`swapAtMint = false`): the collateral is sourced in the SAME token as
30
- * the debt/credit, so the holding side exactly offsets it → net PnL is FLAT (0 everywhere,
31
- * mint-relative), regardless of which token the leg is denominated in.
32
- * - **Zap** (`swapAtMint = true`): the collateral is sourced in the OTHER token, leaving a
33
- * ±1-delta line in the asset (ETH), anchored to 0 at the mint price:
34
- * - USDC loan → zap to ETH: +1 (long ETH)
35
- * - ETH loan → zap to USDC: −1 (short ETH)
36
- * - USDC credit ← zap from ETH: −1 (short ETH)
37
- * - ETH credit ← zap from USDC: +1 (long ETH)
38
- *
39
- * @returns Net leg value in numeraire token smallest units (mint-relative PnL).
40
- */
41
- declare function getLegNetValueWidth0(leg: TokenIdLeg, m: bigint, qCurrentTick: bigint, qMintTick: bigint, isAssetToken0: boolean, swapAtMint: boolean, itmOffsetNotional?: bigint): bigint;
42
- /**
43
- * Check if leg is a call option (vs put).
44
- *
45
- * A call is when the leg moves the asset token:
46
- * - If asset is token0: call when tokenType=0
47
- * - If asset is token1: call when tokenType=1
48
- */
49
- declare function isCall(tokenType: bigint, isAssetToken0: boolean): boolean;
50
- /**
51
- * Check if position has defined risk (is a spread).
52
- *
53
- * A position is defined risk if it has 2+ legs of the same tokenType
54
- * with both long and short exposure.
55
- */
56
- declare function isDefinedRisk(legs: Pick<TokenIdLeg, 'tokenType' | 'isLong'>[]): boolean;
57
- /**
58
- * Calculate the value of a single leg.
59
- *
60
- * Value represents the current P&L of the position in numeraire token units.
61
- * Combines base value (from Panoptic's piecewise formula), debt, and ITM adjustment.
62
- *
63
- * Uses sqrtPriceX96 for all calculations to maintain precision and on-chain fidelity.
64
- *
65
- * @param leg - The leg to calculate
66
- * @param currentTick - Current pool tick
67
- * @param mintTick - Tick at position mint
68
- * @param positionSize - Position size in asset token smallest units
69
- * @param poolTickSpacing - Pool tick spacing
70
- * @param definedRisk - Whether position is defined risk
71
- * @param assetIndex - Optional override for leg.asset (0n = token0 is asset, 1n = token1)
72
- * @returns Leg value in numeraire token smallest units
73
- */
74
- declare function getLegValue(leg: TokenIdLeg, currentTick: bigint, mintTick: bigint, positionSize: bigint, poolTickSpacing: bigint, definedRisk: boolean, assetIndex?: bigint, swapAtMint?: boolean): bigint;
75
- /**
76
- * Calculate the delta of a single leg.
77
- *
78
- * Delta is the rate of change of position value with respect to price.
79
- * For puts: delta = vDelta
80
- * For calls: delta = debtDelta + vDelta + itmDelta (if not defined risk)
81
- *
82
- * Uses sqrtPriceX96 for all price calculations to maintain precision.
83
- *
84
- * @param leg - The leg to calculate
85
- * @param currentTick - Current pool tick
86
- * @param positionSize - Position size in asset token smallest units
87
- * @param poolTickSpacing - Pool tick spacing
88
- * @param mintTick - Tick at mint (optional, for ITM adjustment)
89
- * @param definedRisk - Whether position is defined risk
90
- * @param assetIndex - Optional override for leg.asset (0n = token0 is asset, 1n = token1)
91
- * @returns Leg delta in asset token smallest units
92
- */
93
- declare function getLegDelta(leg: TokenIdLeg, currentTick: bigint, positionSize: bigint, poolTickSpacing: bigint, mintTick: bigint | undefined, definedRisk: boolean, assetIndex?: bigint): bigint;
94
- /** Convert a delta between token frames at the current pool tick. */
95
- declare function toVaultFrameAtTick(delta: bigint, fromAsset: bigint, vaultAssetIndex: 0n | 1n, currentTick: bigint, flipSignOnAssetInversion?: boolean): bigint;
96
- /**
97
- * Calculate one leg's wallet-aware delta in the vault asset frame.
98
- *
99
- * Width-zero loans and credits must be evaluated directly in the vault frame.
100
- * Option legs remain in their natural leg frame until converted at the mark tick.
101
- */
102
- declare function getLegDeltaInVaultFrame(leg: TokenIdLeg, currentTick: bigint, positionSize: bigint, poolTickSpacing: bigint, mintTick: bigint | undefined, definedRisk: boolean, vaultAssetIndex: 0n | 1n): bigint;
103
- /**
104
- * Calculate the gamma (dollar gamma) of a single leg.
105
- *
106
- * Formula: gamma = (m * sqrt(K * P * r)) / (2 * (r - 1))
107
- * where:
108
- * - m = positionSize * optionRatio (with sign based on long/short)
109
- * - K = strike price (numeraire/asset)
110
- * - P = current price (numeraire/asset)
111
- * - r = 1.0001^(width*tickSpacing/2) ≈ 1 (dimensionless ratio)
112
- *
113
- * Uses sqrtPriceX96 arithmetic:
114
- * - sqrt(K*P*r) = tickToSqrtPriceX96(strikeₜ + currentₜ + widthₜ/2)
115
- * - Keeps X96/X192 precision until final division
116
- *
117
- * @param leg - The leg to calculate
118
- * @param currentTick - Current pool tick
119
- * @param positionSize - Position size in asset token smallest units
120
- * @param poolTickSpacing - Pool tick spacing
121
- * @param assetIndex - Optional override for leg.asset (0n = token0 is asset, 1n = token1)
122
- * @returns Leg gamma in numeraire token smallest units
123
- */
124
- declare function getLegGamma(leg: TokenIdLeg, currentTick: bigint, positionSize: bigint, poolTickSpacing: bigint, assetIndex?: bigint): bigint;
125
- /**
126
- * Parameters for position-level greek calculations.
127
- */
128
- interface PositionGreeksInput {
129
- /** Position legs */
130
- legs: TokenIdLeg[];
131
- /** Current pool tick */
132
- currentTick: bigint;
133
- /** Tick at position mint */
134
- mintTick: bigint;
135
- /** Position size in asset token smallest units */
136
- positionSize: bigint;
137
- /** Pool tick spacing */
138
- poolTickSpacing: bigint;
139
- /** Optional override for leg.asset on all legs (0n = token0 is asset, 1n = token1) */
140
- assetIndex?: bigint;
141
- /**
142
- * How width=0 (loan/credit) legs were opened. When provided, `calculatePositionValue`
143
- * returns the NET user-experienced payoff for those legs (Zap = ±1 line, Cover = flat)
144
- * instead of the debt-only value. Leave undefined for delta/greeks aggregation, which
145
- * accounts for the held collateral separately.
146
- */
147
- swapAtMint?: boolean;
148
- }
149
- /**
150
- * Calculate total value across all legs.
151
- */
152
- declare function calculatePositionValue(input: PositionGreeksInput): bigint;
153
- /**
154
- * Calculate total delta across all legs.
155
- */
156
- declare function calculatePositionDelta(input: PositionGreeksInput): bigint;
157
- /**
158
- * Calculate debt-only position delta in a single target asset frame.
159
- *
160
- * Option legs are first valued in their natural `leg.asset` frame, then
161
- * converted into `assetIndex` using the current pool price. Width-zero legs
162
- * are evaluated directly in the target frame.
163
- *
164
- * Width=0 loan/credit legs include only their debt obligation. The held-token
165
- * side must be added separately from account collateral balances, preventing a
166
- * zap from being counted once in the position and again in collateral.
167
- */
168
- declare function calculatePositionDeltaDebtOnly(input: Omit<PositionGreeksInput, 'assetIndex' | 'swapAtMint'> & {
169
- assetIndex: 0n | 1n;
170
- }): bigint;
171
- /**
172
- * Calculate total gamma across all legs.
173
- */
174
- declare function calculatePositionGamma(input: PositionGreeksInput): bigint;
175
- /**
176
- * Position greeks result.
177
- */
178
- interface PositionGreeksResult {
179
- /** Position value in numeraire token smallest units */
180
- value: bigint;
181
- /** Position delta in asset token smallest units */
182
- delta: bigint;
183
- /** Position gamma in numeraire token smallest units */
184
- gamma: bigint;
185
- }
186
- /**
187
- * Calculate all greeks for a position.
188
- */
189
- declare function calculatePositionGreeks(input: PositionGreeksInput): PositionGreeksResult;
190
- /**
191
- * Aggregate value across multiple independent positions.
192
- *
193
- * Each entry is valued with its OWN `positionSize`, `mintTick`, and legs, then
194
- * summed. Do NOT collapse multiple positions into one synthetic `PositionGreeksInput`
195
- * with a shared `positionSize` — `m = positionSize * optionRatio` is per-position, so a
196
- * shared size double-counts (and integer `optionRatio` cannot encode fractional shares).
197
- *
198
- * @param positions - One `PositionGreeksInput` per open position
199
- * @returns Total value in numeraire token smallest units
200
- */
201
- declare function calculatePortfolioValue(positions: PositionGreeksInput[]): bigint;
202
- /**
203
- * Aggregate delta across multiple independent positions.
204
- *
205
- * See {@link calculatePortfolioValue} for why each position must keep its own
206
- * `positionSize` rather than being merged into one synthetic position.
207
- *
208
- * @param positions - One `PositionGreeksInput` per open position
209
- * @returns Total delta in asset token smallest units
210
- */
211
- declare function calculatePortfolioDelta(positions: PositionGreeksInput[]): bigint;
212
- /**
213
- * Aggregate gamma across multiple independent positions.
214
- *
215
- * See {@link calculatePortfolioValue} for why each position must keep its own
216
- * `positionSize` rather than being merged into one synthetic position.
217
- *
218
- * @param positions - One `PositionGreeksInput` per open position
219
- * @returns Total gamma in numeraire token smallest units
220
- */
221
- declare function calculatePortfolioGamma(positions: PositionGreeksInput[]): bigint;
222
- /**
223
- * Calculate all greeks aggregated across multiple independent positions.
224
- */
225
- declare function calculatePortfolioGreeks(positions: PositionGreeksInput[]): PositionGreeksResult;
226
- /**
227
- * Calculate the effective delta of a loan leg accounting for swapAtMint.
228
- *
229
- * A loan borrows one token and (optionally) swaps it for the other at mint.
230
- * The net delta depends on whether the swap occurred:
231
- *
232
- * | Scenario | Result |
233
- * |-----------------------|-------------------------------------------------|
234
- * | No swap | 0n (hold what you owe, net zero) |
235
- * | Swap + borrows asset | -m (hold numeraire, owe asset → short exposure) |
236
- * | Swap + borrows numer. | +m (hold asset, owe numeraire → long exposure) |
237
- *
238
- * Only meaningful for legs with `width === 0n`. For options, use `getLegDelta`.
239
- *
240
- * @param leg - The loan leg
241
- * @param positionSize - Position size in asset token smallest units
242
- * @param swapAtMint - Whether the borrowed tokens were swapped at mint
243
- * @param assetIndex - Optional override for leg.asset (0n = token0 is asset)
244
- * @returns Effective delta in asset token smallest units
245
- */
246
- declare function getLoanEffectiveDelta(leg: TokenIdLeg, positionSize: bigint, swapAtMint: boolean, assetIndex?: bigint): bigint;
247
- /**
248
- * Calculate total delta for a position, using swap-aware delta for loan legs.
249
- *
250
- * For legs with `width === 0n` (loans/credits), uses `getLoanEffectiveDelta`
251
- * which accounts for the swapAtMint flag. For option legs (`width > 0n`),
252
- * uses the standard `getLegDelta`.
253
- *
254
- * @param input - Position greeks input plus swapAtMint flag
255
- * @returns Total delta in asset token smallest units
256
- */
257
- declare function calculatePositionDeltaWithSwap(input: PositionGreeksInput & {
258
- swapAtMint: boolean;
259
- }): bigint; //#endregion
260
- export { PositionGreeksInput, PositionGreeksResult, calculatePortfolioDelta as calculatePortfolioDelta$1, calculatePortfolioGamma as calculatePortfolioGamma$1, calculatePortfolioGreeks as calculatePortfolioGreeks$1, calculatePortfolioValue as calculatePortfolioValue$1, calculatePositionDelta as calculatePositionDelta$1, calculatePositionDeltaDebtOnly as calculatePositionDeltaDebtOnly$1, calculatePositionDeltaWithSwap as calculatePositionDeltaWithSwap$1, calculatePositionGamma as calculatePositionGamma$1, calculatePositionGreeks as calculatePositionGreeks$1, calculatePositionValue as calculatePositionValue$1, getLegDelta as getLegDelta$1, getLegDeltaInVaultFrame as getLegDeltaInVaultFrame$1, getLegGamma as getLegGamma$1, getLegNetValueWidth0 as getLegNetValueWidth0$1, getLegValue as getLegValue$1, getLoanEffectiveDelta as getLoanEffectiveDelta$1, isCall as isCall$1, isDefinedRisk as isDefinedRisk$1, toVaultFrameAtTick as toVaultFrameAtTick$1 };
261
- //# sourceMappingURL=index-Zvu-rJpV.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-Zvu-rJpV.d.ts","names":["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/greeks/index.d.ts"],"sourcesContent":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;;;;;;;AAQA;;;;;;iBARwBC,oBAAAA,MAA0BD;AAelD;;;;AAAgD;;;iBAPxBE,MAAAA;;;;;;;iBAOAC,aAAAA,OAAoBC,KAAKJ;;;;;;;;AAkBjD;;;;;;;;;;iBAAwBK,WAAAA,MAAiBL;;;;;;;;;AAmBzC;;AAEA;;;;;;;AAOA;iBATwBM,WAAAA,MAAiBN;;iBAEjBO,kBAAAA;;;;;;;iBAOAC,uBAAAA,MAA6BR;;;;;;;;;;;;AAsBrD;;;;AAIA;;;;AAwBA;;iBA5BwBS,WAAAA,MAAiBT;;AAgCzC;;UA5BiBU,mBAAAA;;QAEPV;;;;;;;;EAsCca,eAAAA,EAAAA,MAAAA;EAA8B;EAAA,UAAaH,CAAAA,EAAAA,MAAAA;EAAmB;AAApB;;;;AAMlE;;;;AAIA;;iBA1BwBC,sBAAAA,QAA8BD;;AAqCtD;;AAAuDA,iBAjC/BE,sBAAAA,CAiC+BF,KAAAA,EAjCDA,mBAiCCA,CAAAA,EAAAA,MAAAA;;AAA0C;;;;;;;;;;iBArBzEG,8BAAAA,QAAsCC,KAAKJ;;AAiCnE,CAAA,CAAA,EAAwBQ,MAAAA;;;;iBA3BAH,sBAAAA,QAA8BL;;;;UAIrCM,oBAAAA;;EAiCOG,KAAAA,EAAAA,MAAAA;;;;;;;;;iBAtBAF,uBAAAA,QAA+BP,sBAAsBM;AAgC7E;;;;AAIA;;;;AAAwG;;;iBAxBhFE,uBAAAA,YAAmCR;;;;;;;;;;iBAUnCS,uBAAAA,YAAmCT;;;;;;;;AAmC3D;;iBAzBwBU,uBAAAA,YAAmCV;;;;iBAInCW,wBAAAA,YAAoCX,wBAAwBM;;;;;AAgCpF;;;;;;;;;;;;;;;;iBAXwBM,qBAAAA,MAA2BtB;;;;;;;;;;;iBAW3BuB,8BAAAA,QAAsCb"}