@panoptic-eng/sdk 1.0.48 → 1.0.50

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 (39) hide show
  1. package/dist/cow/index.js.map +1 -1
  2. package/dist/{cow-BPcuMjYR.js → cow-CSSKPknb.js} +1 -1
  3. package/dist/deployments.d.ts +12 -4
  4. package/dist/deployments.d.ts.map +1 -1
  5. package/dist/deployments.js +78 -10
  6. package/dist/deployments.js.map +1 -1
  7. package/dist/{greeks-9aTE-DwO.js → greeks-CNi1-cnp.js} +39 -16
  8. package/dist/index.d.ts +518 -76
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +701 -84
  11. package/dist/index.js.map +1 -1
  12. package/dist/{irm-C7QhFiwL.js → irm-BJaJSUjF.js} +80 -12
  13. package/dist/panoptic/v2/greeks/index.d.ts +12 -1
  14. package/dist/panoptic/v2/greeks/index.d.ts.map +1 -1
  15. package/dist/panoptic/v2/greeks/index.js +39 -16
  16. package/dist/panoptic/v2/greeks/index.js.map +1 -1
  17. package/dist/panoptic/v2/index.d.ts +1336 -74
  18. package/dist/panoptic/v2/index.d.ts.map +1 -1
  19. package/dist/panoptic/v2/index.js +20322 -18660
  20. package/dist/panoptic/v2/index.js.map +1 -1
  21. package/dist/panoptic/v2/react-public.d.ts +1518 -240
  22. package/dist/panoptic/v2/react-public.d.ts.map +1 -1
  23. package/dist/panoptic/v2/react-public.js +11518 -9319
  24. package/dist/panoptic/v2/react-public.js.map +1 -1
  25. package/dist/{rates-5oQD-SuM.js → rates-COAJpKRd.js} +612 -73
  26. package/dist/{router-C26q7i8w.js → router-B-I1eACz.js} +5 -43
  27. package/dist/router-BSS7HKd2.js +837 -0
  28. package/dist/uniswap/index.d.ts +465 -215
  29. package/dist/uniswap/index.d.ts.map +1 -1
  30. package/dist/uniswap/index.js +1799 -1076
  31. package/dist/uniswap/index.js.map +1 -1
  32. package/dist/{v2-DVcophLf.js → v2-zF6b01PI.js} +2488 -1596
  33. package/dist/{writes-DBHwfbDD.js → writes-D1zN0v9x.js} +4 -3
  34. package/dist/zodiac/index.d.ts +51 -7
  35. package/dist/zodiac/index.d.ts.map +1 -1
  36. package/dist/zodiac/index.js +154 -2
  37. package/dist/zodiac/index.js.map +1 -1
  38. package/package.json +2 -1
  39. package/dist/router-ClhAkKjh.js +0 -312
@@ -1,5 +1,5 @@
1
- import { MulticallNoDataError, MulticallResultFailedError, MulticallResultMissingError, PanopticValidationError, collateralTrackerV2Abi, decodeLeftRightUnsigned, getBlockMeta, getPool, getPositions, panopticPoolV2Abi, riskEngineAbi } from "./rates-5oQD-SuM.js";
2
- import { NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, tickToSqrtPriceX96 } from "./greeks-9aTE-DwO.js";
1
+ import { MulticallNoDataError, MulticallResultFailedError, MulticallResultMissingError, PanopticValidationError, collateralTrackerV2Abi, decodeLeftRightUnsigned, getBlockMeta, getPool, getPositions, panopticPoolV2Abi, riskEngineAbi } from "./rates-COAJpKRd.js";
2
+ import { NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, tickToSqrtPriceX96 } from "./greeks-CNi1-cnp.js";
3
3
  import { decodeFunctionResult, encodeFunctionData } from "viem";
4
4
  import { call } from "viem/actions";
5
5
 
@@ -2328,24 +2328,25 @@ var _1 = {
2328
2328
  "collateralTracker1": "0x69E9f9e44E5F52237493b980dd7306198C64A4E4"
2329
2329
  } },
2330
2330
  "v2": {
2331
- "semiFungiblePositionManagerV4": "0x000000000000047534b9E1D528ED997169865a64",
2332
- "semiFungiblePositionManagerV3": "0x000000000000031d296bBA22f188472157eEb01f",
2333
- "builderFactory": "0x00000000000008D41F2cd5bF144F61cEB3661F98",
2334
- "riskEngine": "0x0000000000000e673aECBDB5f5fE5DFAf4a8e9Ac",
2335
- "panopticPoolImplementation": "0x00000000000010bb6695dAAC60D0515c0A01a948",
2336
- "collateralTrackerImplementation": "0x0000000000002038055dB8f2B2Fd356598935C51",
2331
+ "semiFungiblePositionManagerV4": "0x00000000000005C3287f136Ef5AF56c68Ea6849f",
2332
+ "semiFungiblePositionManagerV3": "0x00000000000005E4693aDc8Ec0f12D686f728198",
2333
+ "builderFactory": "0x0000000000000a3D22E158417AA639D7F71b0FF7",
2334
+ "riskEngine": "0x0000000000000E65545005B26207D7edFd031260",
2335
+ "panopticPoolImplementation": "0x000000000000135429F0DaCaB61639Bf6a63EbbC",
2336
+ "collateralTrackerImplementation": "0x0000000000001d9c38CA405A2e04420865A08A33",
2337
2337
  "panopticFactoryV4": "0x0000000000000c51d0f8cf4bd9adE7191372a625",
2338
2338
  "panopticFactoryV3": "0x0000000000000aDC9A108591e718F2aee963a2a7",
2339
2339
  "panopticHelper": "0x0000000000000000000000000000000000000000",
2340
- "panopticMath": "0x000000000000301F5BC0171C75967b8e78a92b10",
2340
+ "panopticMath": "0x000000000000334bbd65C195581cf59ECf315932",
2341
2341
  "panopticQuery": "0x0000000000000e1aE9c66C1c3B0A547D23389C93",
2342
- "interactionHelper": "0x00000000000040ae7CD505F4E0e3F34195D8c08C"
2342
+ "interactionHelper": "0x00000000000041fe14Ce3c2392337CE501aE8328"
2343
2343
  }
2344
2344
  },
2345
2345
  "riskEngines": [
2346
2346
  "0x000000000000075e29cdaa9cb640a69e148ca7da",
2347
2347
  "0x0000000000000fe1e261f66ce2f44def4f5ae0cb",
2348
- "0x0000000000000e673aECBDB5f5fE5DFAf4a8e9Ac"
2348
+ "0x0000000000000e673aECBDB5f5fE5DFAf4a8e9Ac",
2349
+ "0x0000000000000E65545005B26207D7edFd031260"
2349
2350
  ],
2350
2351
  "markets": { "ethUsdc30bps": {
2351
2352
  "currency0": "0x0000000000000000000000000000000000000000",
@@ -2367,6 +2368,63 @@ var _1 = {
2367
2368
  "weth": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
2368
2369
  }
2369
2370
  };
2371
+ var _4663 = {
2372
+ "chainId": 4663,
2373
+ "infrastructure": {
2374
+ "uniswapV3Factory": "0x1f7d7550b1b028f7571e69a784071f0205fd2efa",
2375
+ "poolManager": "0x8366a39cc670b4001a1121b8f6a443a643e40951",
2376
+ "stateView": "0xf3334192d15450cdd385c8b70e03f9a6bd9e673b"
2377
+ },
2378
+ "hypovault": {
2379
+ "core": {
2380
+ "hypoVaultImplementation": "0x0000000000000000000000000000000000000000",
2381
+ "factory": "0x0000000000000000000000000000000000000000",
2382
+ "accountant": "0x0000000000000000000000000000000000000000",
2383
+ "rolesAuthority": "0x0000000000000000000000000000000000000000",
2384
+ "collateralTrackerDecoderAndSanitizer": "0x0000000000000000000000000000000000000000"
2385
+ },
2386
+ "vaults": {
2387
+ "wethPlpVault": "0x0000000000000000000000000000000000000000",
2388
+ "usdcPlpVault": "0x0000000000000000000000000000000000000000"
2389
+ },
2390
+ "managers": {
2391
+ "wethPlpVaultManager": "0x0000000000000000000000000000000000000000",
2392
+ "usdcPlpVaultManager": "0x0000000000000000000000000000000000000000"
2393
+ },
2394
+ "turnkeySigners": {
2395
+ "wethPlpVaultManager": "0x0000000000000000000000000000000000000000",
2396
+ "usdcPlpVaultManager": "0x0000000000000000000000000000000000000000"
2397
+ }
2398
+ },
2399
+ "panoptic": {
2400
+ "pool": {
2401
+ "version": "v4",
2402
+ "panopticPool": "0x0000000000000000000000000000000000000000",
2403
+ "collateralTracker0": "0x0000000000000000000000000000000000000000",
2404
+ "collateralTracker1": "0x0000000000000000000000000000000000000000"
2405
+ },
2406
+ "v2": {
2407
+ "semiFungiblePositionManagerV4": "0x00000000000005C3287f136Ef5AF56c68Ea6849f",
2408
+ "semiFungiblePositionManagerV3": "0x00000000000005E4693aDc8Ec0f12D686f728198",
2409
+ "builderFactory": "0x0000000000000a3D22E158417AA639D7F71b0FF7",
2410
+ "riskEngine": "0x0000000000000E65545005B26207D7edFd031260",
2411
+ "panopticPoolImplementation": "0x000000000000135429F0DaCaB61639Bf6a63EbbC",
2412
+ "collateralTrackerImplementation": "0x0000000000001d9c38CA405A2e04420865A08A33",
2413
+ "panopticFactoryV4": "0x0000000000000c51d0f8cf4bd9adE7191372a625",
2414
+ "panopticFactoryV3": "0x0000000000000aDC9A108591e718F2aee963a2a7",
2415
+ "panopticHelper": "0x0000000000000000000000000000000000000000",
2416
+ "panopticMath": "0x000000000000334bbd65C195581cf59ECf315932",
2417
+ "panopticQuery": "0x0000000000000e1aE9c66C1c3B0A547D23389C93",
2418
+ "interactionHelper": "0x00000000000041fe14Ce3c2392337CE501aE8328"
2419
+ }
2420
+ },
2421
+ "riskEngines": ["0x0000000000000E65545005B26207D7edFd031260"],
2422
+ "markets": {},
2423
+ "subgraphs": {
2424
+ "hypovault": "",
2425
+ "panoptic": "https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-robinhood/v2_prod/gn"
2426
+ }
2427
+ };
2370
2428
  var _8453 = {
2371
2429
  "chainId": 8453,
2372
2430
  "infrastructure": {
@@ -2495,6 +2553,7 @@ var _11155111 = {
2495
2553
  };
2496
2554
  var chainDeployments_data_default = {
2497
2555
  "1": _1,
2556
+ "4663": _4663,
2498
2557
  "8453": _8453,
2499
2558
  "11155111": _11155111
2500
2559
  };
@@ -2504,6 +2563,7 @@ var chainDeployments_data_default = {
2504
2563
  const MAINNET_CHAIN_ID = 1;
2505
2564
  const SEPOLIA_CHAIN_ID = 11155111;
2506
2565
  const BASE_CHAIN_ID = 8453;
2566
+ const ROBINHOOD_CHAIN_ID = 4663;
2507
2567
  const CHAIN_DEPLOYMENTS = chainDeployments_data_default;
2508
2568
  function getChainDeployment(chainId) {
2509
2569
  return CHAIN_DEPLOYMENTS[chainId];
@@ -2543,6 +2603,14 @@ const SEPOLIA_ETH_USDC_5BPS_MARKET = getEthUsdcMarket(SEPOLIA_DEPLOYMENT);
2543
2603
  const MAINNET_RISK_ENGINES = MAINNET_DEPLOYMENT.riskEngines;
2544
2604
  const BASE_RISK_ENGINES = BASE_DEPLOYMENT.riskEngines;
2545
2605
  const SEPOLIA_RISK_ENGINES = SEPOLIA_DEPLOYMENT.riskEngines;
2606
+ const ROBINHOOD_DEPLOYMENT = CHAIN_DEPLOYMENTS[ROBINHOOD_CHAIN_ID];
2607
+ const ROBINHOOD_HYPOVAULT_CORE_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.core;
2608
+ const ROBINHOOD_HYPOVAULT_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.vaults;
2609
+ const ROBINHOOD_HYPOVAULT_MANAGER_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.managers;
2610
+ const ROBINHOOD_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = ROBINHOOD_DEPLOYMENT.hypovault.turnkeySigners;
2611
+ const ROBINHOOD_PANOPTIC_POOL_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.pool;
2612
+ const ROBINHOOD_PANOPTIC_V2_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.v2;
2613
+ const ROBINHOOD_RISK_ENGINES = ROBINHOOD_DEPLOYMENT.riskEngines;
2546
2614
 
2547
2615
  //#endregion
2548
2616
  //#region ../deployments/src/vaultDisplayNames.js
@@ -2765,4 +2833,4 @@ async function getIrmCurve(params) {
2765
2833
  }
2766
2834
 
2767
2835
  //#endregion
2768
- 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, deriveSupplyRatePerSecWad, getAccountCollateral, getAccountSummaryBasic, getAccountSummaryRisk, getChainDeployment, getCollateralAddresses, getCollateralData, getCurrentRates, getEthUsdcMarket, getInterestState, getIrmCurrent, getIrmCurve, getLiquidationPrices, getNetLiquidationValue, getNetLiquidationValues, isLiquidatable, isSupportedChain, packMarketState, panopticQueryAbi, ratePerSecWadToAprPct, readBlockAndAggregate, requireChainDeployment, requireReturnData, resolveVaultDisplayName, utilizationBpsToWad, utilizationPctToWad };
2836
+ 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, ROBINHOOD_CHAIN_ID, ROBINHOOD_DEPLOYMENT, ROBINHOOD_HYPOVAULT_ADDRESSES, ROBINHOOD_HYPOVAULT_CORE_ADDRESSES, ROBINHOOD_HYPOVAULT_MANAGER_ADDRESSES, ROBINHOOD_HYPOVAULT_MANAGER_TURNKEY_SIGNERS, ROBINHOOD_PANOPTIC_POOL_ADDRESSES, ROBINHOOD_PANOPTIC_V2_ADDRESSES, ROBINHOOD_RISK_ENGINES, 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, deriveSupplyRatePerSecWad, getAccountCollateral, getAccountSummaryBasic, getAccountSummaryRisk, getChainDeployment, getCollateralAddresses, getCollateralData, getCurrentRates, getEthUsdcMarket, getInterestState, getIrmCurrent, getIrmCurve, getLiquidationPrices, getNetLiquidationValue, getNetLiquidationValues, isLiquidatable, isSupportedChain, packMarketState, panopticQueryAbi, ratePerSecWadToAprPct, readBlockAndAggregate, requireChainDeployment, requireReturnData, resolveVaultDisplayName, utilizationBpsToWad, utilizationPctToWad };
@@ -166,6 +166,10 @@ interface PositionGreeksInput {
166
166
  * Calculate total value across all legs.
167
167
  */
168
168
  declare function calculatePositionValue(input: PositionGreeksInput): bigint;
169
+ /** Prepare mint-time invariants once for an arbitrary series of valuation ticks. */
170
+ declare function preparePositionValue(input: Omit<PositionGreeksInput, 'currentTick'>): (currentTick: bigint) => bigint;
171
+ /** Value a tick series without repeating position preparation. */
172
+ declare function calculatePositionValues(input: Omit<PositionGreeksInput, 'currentTick'>, ticks: readonly bigint[]): bigint[];
169
173
  /**
170
174
  * Calculate total delta across all legs.
171
175
  */
@@ -184,6 +188,13 @@ declare function calculatePositionDelta(input: PositionGreeksInput): bigint;
184
188
  declare function calculatePositionDeltaDebtOnly(input: Omit<PositionGreeksInput, 'assetIndex' | 'swapAtMint'> & {
185
189
  assetIndex: 0n | 1n;
186
190
  }): bigint;
191
+ /** Delta and one strategy contract's notional, both in the requested asset frame. */
192
+ declare function getPositionDeltaMetrics(input: Omit<PositionGreeksInput, 'assetIndex' | 'swapAtMint'> & {
193
+ assetIndex: 0n | 1n;
194
+ }): {
195
+ delta: bigint;
196
+ contractSize: bigint;
197
+ };
187
198
  /**
188
199
  * Calculate total gamma across all legs.
189
200
  */
@@ -273,5 +284,5 @@ declare function getLoanEffectiveDelta(leg: TokenIdLeg, positionSize: bigint, sw
273
284
  declare function calculatePositionDeltaWithSwap(input: PositionGreeksInput & {
274
285
  swapAtMint: boolean;
275
286
  }): 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 };
287
+ export { PositionGreeksInput, PositionGreeksResult, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLoanEffectiveDelta, getPositionDeltaMetrics, isCall, isDefinedRisk, preparePositionValue, toVaultFrameAtTick };
277
288
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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","preparePositionValue","Omit","calculatePositionValues","calculatePositionDelta","calculatePositionDeltaDebtOnly","getPositionDeltaMetrics","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;EAwBcY;EAAoB,WAAA,EAAA,MAAA;EAAA;EAAgC,QAAxBC,EAAAA,MAAAA;EAAI;;EAEhCC;EAAuB,eAAA,EAAA,MAAA;EAAA;EAAgC,UAAxBD,CAAAA,EAAAA,MAAAA;EAAI;;;;AAI3D;;;;;;;iBARwBF,sBAAAA,QAA8BD;;iBAE9BE,oBAAAA,QAA4BC,KAAKH;;iBAEjCI,uBAAAA,QAA+BD,KAAKH;AAgB5D;;;AAA8DG,iBAZtCE,sBAAAA,CAYsCF,KAAAA,EAZRH,mBAYQG,CAAAA,EAAAA,MAAAA;AAAI;;AAIlE;;;;AAA2D;;;;AAS3D;iBAbwBG,8BAAAA,QAAsCH,KAAKH;;;AAiBnE;iBAbwBO,uBAAAA,QAA+BJ,KAAKH;;;EAwBpCU,KAAAA,EAAAA,MAAAA;EAAuB,YAAA,EAAA,MAAA;CAAA;;AAAkD;;iBAfzEF,sBAAAA,QAA8BR;;;;UAIrCS,oBAAAA;;;;;;EAuBOE,KAAAA,EAAAA,MAAAA;;;;;iBAZAD,uBAAAA,QAA+BV,sBAAsBS;;;;;AAsB7E;;;;;;;iBAVwBE,uBAAAA,YAAmCX;;;AAoB3D;;;;AAIA;;;AAAoFS,iBAd5DG,uBAAAA,CAc4DH,SAAAA,EAdzBT,mBAcyBS,EAAAA,CAAAA,EAAAA,MAAAA;AAAoB;;;;;;;;;iBAJhFI,uBAAAA,YAAmCb;;;;iBAInCc,wBAAAA,YAAoCd,wBAAwBS;;;;;;;;AAqBpF;;;;;;;;;;;AAWA;;iBAXwBM,qBAAAA,MAA2BzB;;;;;;;;;;;iBAW3B0B,8BAAAA,QAAsChB"}
@@ -459,9 +459,13 @@ function getLegGamma(leg, currentTick, positionSize, poolTickSpacing, assetIndex
459
459
  * Calculate total value across all legs.
460
460
  */
461
461
  function calculatePositionValue(input) {
462
- const { legs, currentTick, mintTick, positionSize, poolTickSpacing, assetIndex, swapAtMint } = input;
462
+ return preparePositionValue(input)(input.currentTick);
463
+ }
464
+ /** Prepare mint-time invariants once for an arbitrary series of valuation ticks. */
465
+ function preparePositionValue(input) {
466
+ const { legs, mintTick, positionSize, poolTickSpacing, assetIndex, swapAtMint } = input;
463
467
  const definedRisk = isDefinedRisk(legs);
464
- if (swapAtMint === void 0) return legs.reduce((sum$1, leg) => sum$1 + getLegValue(leg, currentTick, mintTick, positionSize, poolTickSpacing, definedRisk, assetIndex, swapAtMint), 0n);
468
+ if (swapAtMint === void 0) return (currentTick) => legs.reduce((sum, leg) => sum + getLegValue(leg, currentTick, mintTick, positionSize, poolTickSpacing, definedRisk, assetIndex, swapAtMint), 0n);
465
469
  let numeraireItmPool = 0n;
466
470
  let assetItmPool = 0n;
467
471
  for (const leg of legs) {
@@ -476,19 +480,29 @@ function calculatePositionValue(input) {
476
480
  if (isPut) numeraireItmPool += itm;
477
481
  else assetItmPool += itm;
478
482
  }
479
- let sum = 0n;
480
- for (const leg of legs) if (leg.width === 0n) {
481
- const isAssetToken0 = resolveAssetDirection(leg, assetIndex);
482
- const borrowsAsset = isCall(leg.tokenType, isAssetToken0);
483
- const offset = borrowsAsset ? assetItmPool : numeraireItmPool;
484
- if (borrowsAsset) assetItmPool = 0n;
485
- else numeraireItmPool = 0n;
486
- const qCurrentTick = quoteTick(currentTick, isAssetToken0);
487
- const qMintTick = quoteTick(mintTick, isAssetToken0);
488
- const m = leg.isLong ? -(positionSize * leg.optionRatio) : positionSize * leg.optionRatio;
489
- sum += getLegNetValueWidth0(leg, m, qCurrentTick, qMintTick, isAssetToken0, swapAtMint, offset);
490
- } else sum += getLegValue(leg, currentTick, mintTick, positionSize, poolTickSpacing, definedRisk, assetIndex, swapAtMint);
491
- return sum;
483
+ const initialNumeraireItm = numeraireItmPool;
484
+ const initialAssetItm = assetItmPool;
485
+ return (currentTick) => {
486
+ let numeraireItmPool$1 = initialNumeraireItm;
487
+ let assetItmPool$1 = initialAssetItm;
488
+ let sum = 0n;
489
+ for (const leg of legs) if (leg.width === 0n) {
490
+ const isAssetToken0 = resolveAssetDirection(leg, assetIndex);
491
+ const borrowsAsset = isCall(leg.tokenType, isAssetToken0);
492
+ const offset = borrowsAsset ? assetItmPool$1 : numeraireItmPool$1;
493
+ if (borrowsAsset) assetItmPool$1 = 0n;
494
+ else numeraireItmPool$1 = 0n;
495
+ const qCurrentTick = quoteTick(currentTick, isAssetToken0);
496
+ const qMintTick = quoteTick(mintTick, isAssetToken0);
497
+ const m = leg.isLong ? -(positionSize * leg.optionRatio) : positionSize * leg.optionRatio;
498
+ sum += getLegNetValueWidth0(leg, m, qCurrentTick, qMintTick, isAssetToken0, swapAtMint, offset);
499
+ } else sum += getLegValue(leg, currentTick, mintTick, positionSize, poolTickSpacing, definedRisk, assetIndex, swapAtMint);
500
+ return sum;
501
+ };
502
+ }
503
+ /** Value a tick series without repeating position preparation. */
504
+ function calculatePositionValues(input, ticks) {
505
+ return ticks.map(preparePositionValue(input));
492
506
  }
493
507
  /**
494
508
  * Calculate total delta across all legs.
@@ -514,6 +528,15 @@ function calculatePositionDeltaDebtOnly(input) {
514
528
  const definedRisk = isDefinedRisk(legs);
515
529
  return legs.reduce((sum, leg) => sum + getLegDeltaInVaultFrame(leg, currentTick, positionSize, poolTickSpacing, mintTick, definedRisk, assetIndex), 0n);
516
530
  }
531
+ /** Delta and one strategy contract's notional, both in the requested asset frame. */
532
+ function getPositionDeltaMetrics(input) {
533
+ const orderedLegs = [...input.legs].sort((a, b) => a.index < b.index ? -1 : a.index > b.index ? 1 : 0);
534
+ const nativeLeg = orderedLegs.find((leg) => leg.width > 0n) ?? orderedLegs[0];
535
+ return {
536
+ delta: calculatePositionDeltaDebtOnly(input),
537
+ contractSize: nativeLeg ? toVaultFrameAtTick(input.positionSize, nativeLeg.asset, input.assetIndex, input.currentTick) : 0n
538
+ };
539
+ }
517
540
  /**
518
541
  * Calculate total gamma across all legs.
519
542
  */
@@ -627,5 +650,5 @@ function calculatePositionDeltaWithSwap(input) {
627
650
  }
628
651
 
629
652
  //#endregion
630
- export { calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLoanEffectiveDelta, isCall, isDefinedRisk, toVaultFrameAtTick };
653
+ export { calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLoanEffectiveDelta, getPositionDeltaMetrics, isCall, isDefinedRisk, preparePositionValue, toVaultFrameAtTick };
631
654
  //# sourceMappingURL=index.js.map