@panoptic-eng/sdk 1.0.56 → 1.0.58

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/index.js CHANGED
@@ -24457,7 +24457,7 @@ var _1 = {
24457
24457
  "semiFungiblePositionManagerV4": "0x00000000000005C3287f136Ef5AF56c68Ea6849f",
24458
24458
  "semiFungiblePositionManagerV3": "0x00000000000005E4693aDc8Ec0f12D686f728198",
24459
24459
  "builderFactory": "0x0000000000000a3D22E158417AA639D7F71b0FF7",
24460
- "riskEngine": "0x0000000000000E65545005B26207D7edFd031260",
24460
+ "riskEngine": "0x000000000000075e29cdaa9cb640a69e148ca7da",
24461
24461
  "panopticPoolImplementation": "0x000000000000135429F0DaCaB61639Bf6a63EbbC",
24462
24462
  "collateralTrackerImplementation": "0x0000000000001d9c38CA405A2e04420865A08A33",
24463
24463
  "panopticFactoryV4": "0x0000000000000c51d0f8cf4bd9adE7191372a625",
@@ -24468,12 +24468,7 @@ var _1 = {
24468
24468
  "interactionHelper": "0x00000000000041fe14Ce3c2392337CE501aE8328"
24469
24469
  }
24470
24470
  },
24471
- "riskEngines": [
24472
- "0x000000000000075e29cdaa9cb640a69e148ca7da",
24473
- "0x0000000000000fe1e261f66ce2f44def4f5ae0cb",
24474
- "0x0000000000000e673aECBDB5f5fE5DFAf4a8e9Ac",
24475
- "0x0000000000000E65545005B26207D7edFd031260"
24476
- ],
24471
+ "riskEngines": ["0x000000000000075e29cdaa9cb640a69e148ca7da", "0x0000000000000fe1e261f66ce2f44def4f5ae0cb"],
24477
24472
  "markets": { "ethUsdc30bps": {
24478
24473
  "currency0": "0x0000000000000000000000000000000000000000",
24479
24474
  "currency1": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
@@ -24492,7 +24487,8 @@ var _1 = {
24492
24487
  "poolId": "2824133844976349",
24493
24488
  "fee": 500,
24494
24489
  "weth": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
24495
- }
24490
+ },
24491
+ "deprecatedRiskEngines": ["0x0000000000000e673aECBDB5f5fE5DFAf4a8e9Ac", "0x0000000000000E65545005B26207D7edFd031260"]
24496
24492
  };
24497
24493
  var _4663 = {
24498
24494
  "chainId": 4663,
@@ -24536,7 +24532,7 @@ var _4663 = {
24536
24532
  "semiFungiblePositionManagerV4": "0x00000000000005C3287f136Ef5AF56c68Ea6849f",
24537
24533
  "semiFungiblePositionManagerV3": "0x00000000000005E4693aDc8Ec0f12D686f728198",
24538
24534
  "builderFactory": "0x0000000000000a3D22E158417AA639D7F71b0FF7",
24539
- "riskEngine": "0x0000000000000E65545005B26207D7edFd031260",
24535
+ "riskEngine": "0x000000000000075e29cdaa9cb640a69e148ca7da",
24540
24536
  "panopticPoolImplementation": "0x000000000000135429F0DaCaB61639Bf6a63EbbC",
24541
24537
  "collateralTrackerImplementation": "0x0000000000001d9c38CA405A2e04420865A08A33",
24542
24538
  "panopticFactoryV4": "0x0000000000000c51d0f8cf4bd9adE7191372a625",
@@ -24547,7 +24543,11 @@ var _4663 = {
24547
24543
  "interactionHelper": "0x00000000000041fe14Ce3c2392337CE501aE8328"
24548
24544
  }
24549
24545
  },
24550
- "riskEngines": ["0x0000000000000E65545005B26207D7edFd031260", "0x0000000000000fe1e261f66ce2f44def4f5ae0cb"],
24546
+ "riskEngines": [
24547
+ "0x000000000000075e29cdaa9cb640a69e148ca7da",
24548
+ "0x0000000000000fe1e261f66ce2f44def4f5ae0cb",
24549
+ "0x0000000000000f3fb82469581A74776178E76Ca4"
24550
+ ],
24551
24551
  "markets": { "spyUsdg": {
24552
24552
  "currency0": "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",
24553
24553
  "currency1": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
@@ -24558,7 +24558,8 @@ var _4663 = {
24558
24558
  "subgraphs": {
24559
24559
  "hypovault": "https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-robinhood/prod/gn",
24560
24560
  "panoptic": "https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-robinhood/v2_prod/gn"
24561
- }
24561
+ },
24562
+ "deprecatedRiskEngines": ["0x0000000000000E65545005B26207D7edFd031260"]
24562
24563
  };
24563
24564
  var _8453 = {
24564
24565
  "chainId": 8453,
@@ -31748,12 +31749,15 @@ function medianBigInt(values) {
31748
31749
  const lowerMiddle = sorted[upperMiddleIndex - 1];
31749
31750
  return lowerMiddle === void 0 ? void 0 : (lowerMiddle + upperMiddle) / 2n;
31750
31751
  }
31751
- function clampPriorityFee(priorityFee) {
31752
- if (priorityFee < MIN_VAULT_PRIORITY_FEE_PER_GAS) return MIN_VAULT_PRIORITY_FEE_PER_GAS;
31752
+ function getChainPriorityFeeFloor(chainId) {
31753
+ return chainId === ROBINHOOD_CHAIN_ID ? 0n : void 0;
31754
+ }
31755
+ function clampPriorityFee(priorityFee, minimumPriorityFeePerGas = MIN_VAULT_PRIORITY_FEE_PER_GAS) {
31756
+ if (priorityFee < minimumPriorityFeePerGas) return minimumPriorityFeePerGas;
31753
31757
  if (priorityFee > MAX_VAULT_PRIORITY_FEE_PER_GAS) return MAX_VAULT_PRIORITY_FEE_PER_GAS;
31754
31758
  return priorityFee;
31755
31759
  }
31756
- function resolveFeeHistoryQuote({ baseFeePerGas, reward }) {
31760
+ function resolveFeeHistoryQuote({ baseFeePerGas, reward, minimumPriorityFeePerGas }) {
31757
31761
  const latestBaseFeeIndex = baseFeePerGas.length - 2;
31758
31762
  if (latestBaseFeeIndex < 0 || reward === void 0 || reward.length === 0) return null;
31759
31763
  const p90Rewards = reward.flatMap((blockRewards) => {
@@ -31762,16 +31766,18 @@ function resolveFeeHistoryQuote({ baseFeePerGas, reward }) {
31762
31766
  });
31763
31767
  const sampledPriorityFee = medianBigInt(p90Rewards);
31764
31768
  if (sampledPriorityFee === void 0) return null;
31765
- const maxPriorityFeePerGas = clampPriorityFee(sampledPriorityFee);
31769
+ const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS;
31770
+ const maxPriorityFeePerGas = clampPriorityFee(sampledPriorityFee, effectivePriorityFeeFloor);
31766
31771
  const bufferedBaseFee = ceilMultiplyFraction(baseFeePerGas[latestBaseFeeIndex], BASE_FEE_BUFFER_NUMERATOR, BASE_FEE_BUFFER_DENOMINATOR);
31767
31772
  return {
31768
31773
  maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,
31769
31774
  maxPriorityFeePerGas,
31770
- minimumMaxFeePerGas: bufferedBaseFee + MIN_VAULT_PRIORITY_FEE_PER_GAS,
31775
+ minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,
31776
+ ...minimumPriorityFeePerGas === void 0 ? {} : { minimumPriorityFeePerGas },
31771
31777
  source: "fee_history"
31772
31778
  };
31773
31779
  }
31774
- function resolveDeltaHedgeFeeHistoryQuote({ baseFeePerGas, reward }) {
31780
+ function resolveDeltaHedgeFeeHistoryQuote({ baseFeePerGas, reward, minimumPriorityFeePerGas }) {
31775
31781
  const latestBaseFeeIndex = baseFeePerGas.length - 2;
31776
31782
  if (latestBaseFeeIndex < 0 || reward === void 0 || reward.length === 0) return null;
31777
31783
  const p25Rewards = reward.flatMap((blockRewards) => {
@@ -31780,22 +31786,25 @@ function resolveDeltaHedgeFeeHistoryQuote({ baseFeePerGas, reward }) {
31780
31786
  });
31781
31787
  const rawPriorityFeePerGas = medianBigInt(p25Rewards);
31782
31788
  if (rawPriorityFeePerGas === void 0) return null;
31783
- const maxPriorityFeePerGas = clampPriorityFee(rawPriorityFeePerGas);
31789
+ const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS;
31790
+ const maxPriorityFeePerGas = clampPriorityFee(rawPriorityFeePerGas, effectivePriorityFeeFloor);
31784
31791
  const bufferedBaseFee = ceilMultiplyFraction(baseFeePerGas[latestBaseFeeIndex], BASE_FEE_BUFFER_NUMERATOR, BASE_FEE_BUFFER_DENOMINATOR);
31785
31792
  return {
31786
31793
  maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,
31787
31794
  maxPriorityFeePerGas,
31788
- minimumMaxFeePerGas: bufferedBaseFee + MIN_VAULT_PRIORITY_FEE_PER_GAS,
31795
+ minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,
31796
+ ...minimumPriorityFeePerGas === void 0 ? {} : { minimumPriorityFeePerGas },
31789
31797
  rawPriorityFeePerGas,
31790
31798
  source: "fee_history_p25"
31791
31799
  };
31792
31800
  }
31793
- function resolveRpcPriorityFeeQuote({ baseFeePerGas, rawPriorityFeePerGas }) {
31801
+ function resolveRpcPriorityFeeQuote({ baseFeePerGas, rawPriorityFeePerGas, minimumPriorityFeePerGas }) {
31794
31802
  const bufferedBaseFee = ceilMultiplyFraction(baseFeePerGas, BASE_FEE_BUFFER_NUMERATOR, BASE_FEE_BUFFER_DENOMINATOR);
31795
31803
  return {
31796
31804
  maxFeePerGas: bufferedBaseFee + rawPriorityFeePerGas,
31797
31805
  maxPriorityFeePerGas: rawPriorityFeePerGas,
31798
- minimumMaxFeePerGas: bufferedBaseFee + rawPriorityFeePerGas,
31806
+ minimumMaxFeePerGas: bufferedBaseFee + (minimumPriorityFeePerGas ?? rawPriorityFeePerGas),
31807
+ ...minimumPriorityFeePerGas === void 0 ? {} : { minimumPriorityFeePerGas },
31799
31808
  rawPriorityFeePerGas,
31800
31809
  source: "rpc_priority_fee"
31801
31810
  };
@@ -31816,7 +31825,7 @@ function getVaultTransactionReplacementFeeQuote({ originalQuote, historicalQuote
31816
31825
  requiredMaxPriorityFeePerGas: requiredReplacementPriorityFee,
31817
31826
  maximumAffordableFeePerGas: MAX_VAULT_TRANSACTION_GAS_COST / gasLimit
31818
31827
  });
31819
- const bufferedBaseFee = historicalQuote.minimumMaxFeePerGas - MIN_VAULT_PRIORITY_FEE_PER_GAS;
31828
+ const bufferedBaseFee = historicalQuote.minimumMaxFeePerGas - (historicalQuote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS);
31820
31829
  const currentMarketMaxFee = bufferedBaseFee + requiredMaxPriorityFeePerGas;
31821
31830
  const desiredMaxFeePerGas = currentMarketMaxFee > bumpedMaxFee ? currentMarketMaxFee : bumpedMaxFee;
31822
31831
  const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit;
@@ -31834,13 +31843,15 @@ function getVaultTransactionReplacementFeeQuote({ originalQuote, historicalQuote
31834
31843
  maxPriorityFeePerGas: requiredMaxPriorityFeePerGas
31835
31844
  };
31836
31845
  }
31837
- function resolveFallbackQuote({ maxFeePerGas: estimatedMaxFeePerGas, maxPriorityFeePerGas: estimatedPriorityFeePerGas }) {
31838
- const maxPriorityFeePerGas = clampPriorityFee(estimatedPriorityFeePerGas);
31846
+ function resolveFallbackQuote({ maxFeePerGas: estimatedMaxFeePerGas, maxPriorityFeePerGas: estimatedPriorityFeePerGas, minimumPriorityFeePerGas }) {
31847
+ const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS;
31848
+ const maxPriorityFeePerGas = clampPriorityFee(estimatedPriorityFeePerGas, effectivePriorityFeeFloor);
31839
31849
  const estimatedBaseFeeAllowance = estimatedMaxFeePerGas > estimatedPriorityFeePerGas ? estimatedMaxFeePerGas - estimatedPriorityFeePerGas : 0n;
31840
31850
  return {
31841
31851
  maxFeePerGas: estimatedBaseFeeAllowance + maxPriorityFeePerGas,
31842
31852
  maxPriorityFeePerGas,
31843
- minimumMaxFeePerGas: estimatedBaseFeeAllowance + MIN_VAULT_PRIORITY_FEE_PER_GAS,
31853
+ minimumMaxFeePerGas: estimatedBaseFeeAllowance + effectivePriorityFeeFloor,
31854
+ ...minimumPriorityFeePerGas === void 0 ? {} : { minimumPriorityFeePerGas },
31844
31855
  source: "viem_fallback"
31845
31856
  };
31846
31857
  }
@@ -31853,7 +31864,7 @@ function applyVaultTransactionGasCostLimit(quote, gasLimit) {
31853
31864
  minimumRequiredFeePerGas: quote.minimumMaxFeePerGas
31854
31865
  });
31855
31866
  if (quote.maxFeePerGas <= maximumAffordableFeePerGas) return quote;
31856
- const bufferedBaseFee = quote.minimumMaxFeePerGas - MIN_VAULT_PRIORITY_FEE_PER_GAS;
31867
+ const bufferedBaseFee = quote.minimumMaxFeePerGas - (quote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS);
31857
31868
  const affordablePriorityFee = maximumAffordableFeePerGas - bufferedBaseFee;
31858
31869
  return {
31859
31870
  ...quote,
@@ -31866,7 +31877,8 @@ function bufferVaultTransactionGasEstimate(gasEstimate) {
31866
31877
  return ceilMultiplyFraction(gasEstimate, GAS_ESTIMATE_BUFFER_NUMERATOR, GAS_ESTIMATE_BUFFER_DENOMINATOR);
31867
31878
  }
31868
31879
  function validateVaultSignedTransactionFeeCaps(feeCaps, quote) {
31869
- const { gasLimit, maxFeePerGas, maxPriorityFeePerGas } = feeCaps;
31880
+ const { chainId, gasLimit, maxFeePerGas, maxPriorityFeePerGas } = feeCaps;
31881
+ const minimumPriorityFeePerGas = quote?.minimumPriorityFeePerGas ?? getChainPriorityFeeFloor(chainId) ?? MIN_VAULT_PRIORITY_FEE_PER_GAS;
31870
31882
  if (maxFeePerGas === null || maxPriorityFeePerGas === null) return {
31871
31883
  valid: false,
31872
31884
  code: "MissingEip1559Fees",
@@ -31877,10 +31889,10 @@ function validateVaultSignedTransactionFeeCaps(feeCaps, quote) {
31877
31889
  code: "InvalidFeeCaps",
31878
31890
  reason: `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) cannot exceed maxFeePerGas (${maxFeePerGas.toString()} wei).`
31879
31891
  };
31880
- if (maxPriorityFeePerGas < MIN_VAULT_PRIORITY_FEE_PER_GAS) return {
31892
+ if (maxPriorityFeePerGas < minimumPriorityFeePerGas) return {
31881
31893
  valid: false,
31882
31894
  code: "PriorityFeeTooLow",
31883
- reason: `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) must be at least ${MIN_VAULT_PRIORITY_FEE_PER_GAS.toString()} wei (0.1 gwei).`
31895
+ reason: `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) must be at least ${minimumPriorityFeePerGas.toString()} wei.`
31884
31896
  };
31885
31897
  if (maxPriorityFeePerGas > MAX_VAULT_PRIORITY_FEE_PER_GAS) return {
31886
31898
  valid: false,
@@ -31895,21 +31907,27 @@ function validateVaultSignedTransactionFeeCaps(feeCaps, quote) {
31895
31907
  if (quote !== void 0 && maxFeePerGas < quote.minimumMaxFeePerGas) return {
31896
31908
  valid: false,
31897
31909
  code: "MaxFeeTooLow",
31898
- reason: `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ${quote.minimumMaxFeePerGas.toString()} wei for the buffered next-block base fee and 0.1 gwei minimum priority fee.`
31910
+ reason: `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ${quote.minimumMaxFeePerGas.toString()} wei for the buffered next-block base fee and configured minimum priority fee.`
31899
31911
  };
31900
31912
  return { valid: true };
31901
31913
  }
31902
- async function resolveVaultTransactionFeeQuote({ readFeeHistory, readFallbackEstimate }) {
31914
+ async function resolveVaultTransactionFeeQuote({ readFeeHistory, readFallbackEstimate, minimumPriorityFeePerGas }) {
31903
31915
  let feeHistoryError;
31904
31916
  try {
31905
- const quote = resolveFeeHistoryQuote(await readFeeHistory());
31917
+ const quote = resolveFeeHistoryQuote({
31918
+ ...await readFeeHistory(),
31919
+ minimumPriorityFeePerGas
31920
+ });
31906
31921
  if (quote !== null) return quote;
31907
31922
  feeHistoryError = new Error("eth_feeHistory returned incomplete base fee or reward data");
31908
31923
  } catch (error) {
31909
31924
  feeHistoryError = error;
31910
31925
  }
31911
31926
  try {
31912
- return resolveFallbackQuote(await readFallbackEstimate());
31927
+ return resolveFallbackQuote({
31928
+ ...await readFallbackEstimate(),
31929
+ minimumPriorityFeePerGas
31930
+ });
31913
31931
  } catch (fallbackError) {
31914
31932
  throw new VaultTransactionFeeEstimationError({
31915
31933
  feeHistoryError,
@@ -31921,12 +31939,13 @@ async function resolveVaultTransactionFeeQuote({ readFeeHistory, readFallbackEst
31921
31939
  * Resolve explicit EIP-1559 fees for operator-controlled vault transactions.
31922
31940
  *
31923
31941
  * The normal path follows the median p90 priority fee from the last 20 blocks,
31924
- * with a 0.1 gwei floor and 3 gwei ceiling. If fee history is unavailable,
31925
- * Viem's estimate is used while preserving those bounds and its original
31926
- * base-fee allowance.
31942
+ * with a 3 gwei ceiling and a 0.1 gwei floor except on chains that do not use
31943
+ * tips for ordering. If fee history is unavailable, Viem's estimate is used
31944
+ * while preserving those bounds and its original base-fee allowance.
31927
31945
  */
31928
31946
  async function getVaultTransactionFeeQuote(client) {
31929
31947
  return resolveVaultTransactionFeeQuote({
31948
+ minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),
31930
31949
  readFeeHistory: () => getFeeHistory(client, {
31931
31950
  blockCount: FEE_HISTORY_BLOCK_COUNT,
31932
31951
  blockTag: "latest",
@@ -31941,13 +31960,19 @@ async function getVaultDeltaHedgeHistoricalFeeQuote(client) {
31941
31960
  blockTag: "latest",
31942
31961
  rewardPercentiles: DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES
31943
31962
  });
31944
- const quote = resolveDeltaHedgeFeeHistoryQuote(feeHistory);
31963
+ const quote = resolveDeltaHedgeFeeHistoryQuote({
31964
+ ...feeHistory,
31965
+ minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id)
31966
+ });
31945
31967
  if (quote === null) throw new Error("eth_feeHistory returned incomplete p25 base fee or reward data");
31946
31968
  return quote;
31947
31969
  }
31948
- async function resolveVaultDeltaHedgeInitialFeeQuote({ readRpcQuote, readHistoricalQuote }) {
31970
+ async function resolveVaultDeltaHedgeInitialFeeQuote({ readRpcQuote, readHistoricalQuote, minimumPriorityFeePerGas }) {
31949
31971
  try {
31950
- return resolveRpcPriorityFeeQuote(await readRpcQuote());
31972
+ return resolveRpcPriorityFeeQuote({
31973
+ ...await readRpcQuote(),
31974
+ minimumPriorityFeePerGas
31975
+ });
31951
31976
  } catch {
31952
31977
  return readHistoricalQuote();
31953
31978
  }
@@ -31959,6 +31984,7 @@ async function resolveVaultDeltaHedgeInitialFeeQuote({ readRpcQuote, readHistori
31959
31984
  */
31960
31985
  async function getVaultDeltaHedgeInitialFeeQuote(client) {
31961
31986
  return resolveVaultDeltaHedgeInitialFeeQuote({
31987
+ minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),
31962
31988
  readRpcQuote: async () => {
31963
31989
  const [rawPriorityFee, latestBlock] = await Promise.all([client.request({ method: "eth_maxPriorityFeePerGas" }), getBlock(client, { blockTag: "latest" })]);
31964
31990
  if (latestBlock.baseFeePerGas === null) throw new Error("Latest block does not include an EIP-1559 base fee");