timelock-sdk 0.0.236 → 0.0.238

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 (35) hide show
  1. package/dist/abis.cjs +2 -2
  2. package/dist/abis.d.cts +31 -1
  3. package/dist/abis.d.ts +31 -1
  4. package/dist/abis.js +2 -2
  5. package/dist/client.cjs +44 -24
  6. package/dist/client.cjs.map +1 -1
  7. package/dist/client.d.cts +657 -620
  8. package/dist/client.d.ts +327 -290
  9. package/dist/client.js +44 -24
  10. package/dist/client.js.map +1 -1
  11. package/dist/{factory-5hUk9F0p.cjs → factory-CUMBEyKw.cjs} +57 -15
  12. package/dist/factory-CUMBEyKw.cjs.map +1 -0
  13. package/dist/{factory-CXe8NCiA.js → factory-DB64NQVz.js} +57 -15
  14. package/dist/factory-DB64NQVz.js.map +1 -0
  15. package/dist/{index-BmuFpwj-.d.ts → index-3KOVEC1_.d.cts} +259 -65
  16. package/dist/{index-Ba0F075b.d.cts → index-C4hRFzOj.d.ts} +450 -256
  17. package/dist/{numberUtils-B-inHOvt.cjs → numberUtils-BZ_G2lrM.cjs} +3 -3
  18. package/dist/{numberUtils-B-inHOvt.cjs.map → numberUtils-BZ_G2lrM.cjs.map} +1 -1
  19. package/dist/{numberUtils-CjyQGUg6.js → numberUtils-C2B8mSnx.js} +3 -3
  20. package/dist/{numberUtils-CjyQGUg6.js.map → numberUtils-C2B8mSnx.js.map} +1 -1
  21. package/dist/{optionsMarket-D7BmgbPj.d.ts → optionsMarket-DrJWoxeN.d.ts} +91 -45
  22. package/dist/{optionsMarket-B1e5X8fo.d.cts → optionsMarket-fyNO91om.d.cts} +91 -45
  23. package/dist/package.cjs +1 -1
  24. package/dist/package.d.cts +1 -1
  25. package/dist/package.d.ts +1 -1
  26. package/dist/package.js +1 -1
  27. package/dist/{stateView-BMkpa0rT.cjs → stateView-CkfUE7Sg.cjs} +128 -66
  28. package/dist/stateView-CkfUE7Sg.cjs.map +1 -0
  29. package/dist/{stateView-DlySJr25.js → stateView-DMydGVhr.js} +128 -66
  30. package/dist/stateView-DMydGVhr.js.map +1 -0
  31. package/package.json +1 -1
  32. package/dist/factory-5hUk9F0p.cjs.map +0 -1
  33. package/dist/factory-CXe8NCiA.js.map +0 -1
  34. package/dist/stateView-BMkpa0rT.cjs.map +0 -1
  35. package/dist/stateView-DlySJr25.js.map +0 -1
package/dist/abis.cjs CHANGED
@@ -1,5 +1,5 @@
1
- const require_stateView = require('./stateView-BMkpa0rT.cjs');
2
- const require_factory = require('./factory-5hUk9F0p.cjs');
1
+ const require_stateView = require('./stateView-CkfUE7Sg.cjs');
2
+ const require_factory = require('./factory-CUMBEyKw.cjs');
3
3
 
4
4
  //#region src/abis/poolManager.ts
5
5
  const poolManagerAbi = [
package/dist/abis.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as lensAbi, t as optionsMarketAbi } from "./optionsMarket-B1e5X8fo.cjs";
1
+ import { n as lensAbi, t as optionsMarketAbi } from "./optionsMarket-fyNO91om.cjs";
2
2
 
3
3
  //#region src/abis/erc20.d.ts
4
4
  declare const erc20Abi: readonly [{
@@ -246,9 +246,17 @@ declare const factoryAbi: readonly [{
246
246
  readonly type: "function";
247
247
  readonly name: "deployStaticPerpsPricing";
248
248
  readonly inputs: readonly [{
249
+ readonly name: "_openingRate";
250
+ readonly type: "uint32";
251
+ readonly internalType: "uint32";
252
+ }, {
249
253
  readonly name: "_dailyFundingRate";
250
254
  readonly type: "uint32";
251
255
  readonly internalType: "uint32";
256
+ }, {
257
+ readonly name: "_minOpeningAmount";
258
+ readonly type: "uint128";
259
+ readonly internalType: "uint128";
252
260
  }, {
253
261
  readonly name: "_minFundingAmount";
254
262
  readonly type: "uint128";
@@ -380,11 +388,21 @@ declare const factoryAbi: readonly [{
380
388
  readonly type: "address";
381
389
  readonly indexed: true;
382
390
  readonly internalType: "contract StaticPerpsPricing";
391
+ }, {
392
+ readonly name: "openingRate";
393
+ readonly type: "uint32";
394
+ readonly indexed: false;
395
+ readonly internalType: "uint32";
383
396
  }, {
384
397
  readonly name: "dailyFundingRate";
385
398
  readonly type: "uint32";
386
399
  readonly indexed: false;
387
400
  readonly internalType: "uint32";
401
+ }, {
402
+ readonly name: "minOpeningAmount";
403
+ readonly type: "uint128";
404
+ readonly indexed: false;
405
+ readonly internalType: "uint128";
388
406
  }, {
389
407
  readonly name: "minFundingAmount";
390
408
  readonly type: "uint128";
@@ -2527,6 +2545,14 @@ declare const singleOwnerVaultAbi: readonly [{
2527
2545
  readonly name: "tokens";
2528
2546
  readonly type: "address[]";
2529
2547
  readonly internalType: "contract IERC20[]";
2548
+ }, {
2549
+ readonly name: "amounts";
2550
+ readonly type: "uint256[]";
2551
+ readonly internalType: "uint256[]";
2552
+ }, {
2553
+ readonly name: "recipient";
2554
+ readonly type: "address";
2555
+ readonly internalType: "address";
2530
2556
  }];
2531
2557
  readonly outputs: readonly [];
2532
2558
  readonly stateMutability: "nonpayable";
@@ -2774,6 +2800,10 @@ declare const singleOwnerVaultAbi: readonly [{
2774
2800
  readonly type: "address";
2775
2801
  readonly internalType: "address";
2776
2802
  }];
2803
+ }, {
2804
+ readonly type: "error";
2805
+ readonly name: "ArrayLengthMismatch";
2806
+ readonly inputs: readonly [];
2777
2807
  }, {
2778
2808
  readonly type: "error";
2779
2809
  readonly name: "BorrowerNotWhitelisted";
package/dist/abis.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as lensAbi, t as optionsMarketAbi } from "./optionsMarket-D7BmgbPj.js";
1
+ import { n as lensAbi, t as optionsMarketAbi } from "./optionsMarket-DrJWoxeN.js";
2
2
 
3
3
  //#region src/abis/erc20.d.ts
4
4
  declare const erc20Abi: readonly [{
@@ -246,9 +246,17 @@ declare const factoryAbi: readonly [{
246
246
  readonly type: "function";
247
247
  readonly name: "deployStaticPerpsPricing";
248
248
  readonly inputs: readonly [{
249
+ readonly name: "_openingRate";
250
+ readonly type: "uint32";
251
+ readonly internalType: "uint32";
252
+ }, {
249
253
  readonly name: "_dailyFundingRate";
250
254
  readonly type: "uint32";
251
255
  readonly internalType: "uint32";
256
+ }, {
257
+ readonly name: "_minOpeningAmount";
258
+ readonly type: "uint128";
259
+ readonly internalType: "uint128";
252
260
  }, {
253
261
  readonly name: "_minFundingAmount";
254
262
  readonly type: "uint128";
@@ -380,11 +388,21 @@ declare const factoryAbi: readonly [{
380
388
  readonly type: "address";
381
389
  readonly indexed: true;
382
390
  readonly internalType: "contract StaticPerpsPricing";
391
+ }, {
392
+ readonly name: "openingRate";
393
+ readonly type: "uint32";
394
+ readonly indexed: false;
395
+ readonly internalType: "uint32";
383
396
  }, {
384
397
  readonly name: "dailyFundingRate";
385
398
  readonly type: "uint32";
386
399
  readonly indexed: false;
387
400
  readonly internalType: "uint32";
401
+ }, {
402
+ readonly name: "minOpeningAmount";
403
+ readonly type: "uint128";
404
+ readonly indexed: false;
405
+ readonly internalType: "uint128";
388
406
  }, {
389
407
  readonly name: "minFundingAmount";
390
408
  readonly type: "uint128";
@@ -2527,6 +2545,14 @@ declare const singleOwnerVaultAbi: readonly [{
2527
2545
  readonly name: "tokens";
2528
2546
  readonly type: "address[]";
2529
2547
  readonly internalType: "contract IERC20[]";
2548
+ }, {
2549
+ readonly name: "amounts";
2550
+ readonly type: "uint256[]";
2551
+ readonly internalType: "uint256[]";
2552
+ }, {
2553
+ readonly name: "recipient";
2554
+ readonly type: "address";
2555
+ readonly internalType: "address";
2530
2556
  }];
2531
2557
  readonly outputs: readonly [];
2532
2558
  readonly stateMutability: "nonpayable";
@@ -2774,6 +2800,10 @@ declare const singleOwnerVaultAbi: readonly [{
2774
2800
  readonly type: "address";
2775
2801
  readonly internalType: "address";
2776
2802
  }];
2803
+ }, {
2804
+ readonly type: "error";
2805
+ readonly name: "ArrayLengthMismatch";
2806
+ readonly inputs: readonly [];
2777
2807
  }, {
2778
2808
  readonly type: "error";
2779
2809
  readonly name: "BorrowerNotWhitelisted";
package/dist/abis.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as erc20Abi, i as lensAbi, n as quoterAbi, r as optionsMarketAbi, t as stateViewAbi } from "./stateView-DlySJr25.js";
2
- import { n as guardianAbi, r as singleOwnerVaultAbi, t as factoryAbi } from "./factory-CXe8NCiA.js";
1
+ import { a as erc20Abi, i as lensAbi, n as quoterAbi, r as optionsMarketAbi, t as stateViewAbi } from "./stateView-DMydGVhr.js";
2
+ import { n as guardianAbi, r as singleOwnerVaultAbi, t as factoryAbi } from "./factory-DB64NQVz.js";
3
3
 
4
4
  //#region src/abis/poolManager.ts
5
5
  const poolManagerAbi = [
package/dist/client.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
- const require_numberUtils = require('./numberUtils-B-inHOvt.cjs');
4
- const require_stateView = require('./stateView-BMkpa0rT.cjs');
5
- const require_factory = require('./factory-5hUk9F0p.cjs');
3
+ const require_numberUtils = require('./numberUtils-BZ_G2lrM.cjs');
4
+ const require_stateView = require('./stateView-CkfUE7Sg.cjs');
5
+ const require_factory = require('./factory-CUMBEyKw.cjs');
6
6
  let viem = require("viem");
7
7
  let react = require("react");
8
8
  react = require_numberUtils.__toESM(react);
@@ -876,7 +876,8 @@ const useMarketDailyVolume = (marketAddr) => {
876
876
  date: BigInt(data.date),
877
877
  totalVolume: BigInt(data.totalVolume),
878
878
  totalPremium: BigInt(data.totalPremium),
879
- totalPayout: BigInt(data.totalPayout)
879
+ totalPayout: BigInt(data.totalPayout),
880
+ totalProtocolFee: BigInt(data.totalProtocolFee)
880
881
  }));
881
882
  },
882
883
  enabled: !!marketAddr && !!timelockGraphqlClient
@@ -1141,12 +1142,11 @@ const useMintOption = (marketAddr) => {
1141
1142
  const { data: { currentTick } = {} } = await refetchCurrentTick();
1142
1143
  if (currentTick === void 0) throw new Error("Could not fetch current tick");
1143
1144
  strikeTick = require_numberUtils.getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
1144
- const [premium, protocolFee] = await require_numberUtils.getTimelockMarket(marketAddr, client).read.calculatePremium([
1145
+ const [premium, protocolFee] = await require_numberUtils.getTimelockMarket(marketAddr, client).read.getMintFees([
1145
1146
  optionType === "CALL" ? 0 : 1,
1146
1147
  amount,
1147
1148
  strikeTick,
1148
1149
  duration,
1149
- 0,
1150
1150
  "0x"
1151
1151
  ]);
1152
1152
  const maxPremium = (premium + protocolFee) * 11n / 10n;
@@ -1365,7 +1365,7 @@ const useOptionPnl = (option) => {
1365
1365
 
1366
1366
  //#endregion
1367
1367
  //#region src/hooks/options/useOptionPremium.ts
1368
- const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, remainingDuration = 0, strikeTick) => {
1368
+ const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, strikeTick) => {
1369
1369
  const { poolManager, poolKey, payoutAssetDecimals, optionAssetIsToken0 } = useMarketData(marketAddr);
1370
1370
  const { tickSpacing } = usePoolData(poolManager, poolKey);
1371
1371
  const { data: { currentTick } = {} } = useCurrentTick(poolManager, poolKey);
@@ -1384,13 +1384,12 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, r
1384
1384
  const { data: [premium, protocolFee] = [] } = (0, wagmi.useReadContract)({
1385
1385
  address: marketAddr,
1386
1386
  abi: require_stateView.optionsMarketAbi,
1387
- functionName: "calculatePremium",
1387
+ functionName: "getMintFees",
1388
1388
  args: strikeTickRounded !== void 0 && optionAmount !== void 0 && addedDuration !== void 0 ? [
1389
1389
  optionType === "CALL" ? 0 : 1,
1390
1390
  optionAmount,
1391
1391
  strikeTickRounded,
1392
1392
  addedDuration,
1393
- remainingDuration,
1394
1393
  "0x"
1395
1394
  ] : void 0
1396
1395
  });
@@ -1471,7 +1470,7 @@ const useExtendOption = (marketAddr) => {
1471
1470
  if (!marketAddr || !payoutAsset) throw new Error("Market address not available");
1472
1471
  const market = require_numberUtils.getTimelockMarket(marketAddr, client);
1473
1472
  const remainingDuration = Math.max(0, Math.floor((option.expiresAt.getTime() - Date.now()) / 1e3));
1474
- const [premium, protocolFee] = await market.read.calculatePremium([
1473
+ const [premium, protocolFee] = await market.read.getExtendFees([
1475
1474
  option.optionType === "CALL" ? 0 : 1,
1476
1475
  option.positionSizeCurrent,
1477
1476
  option.strikeTick,
@@ -1730,12 +1729,11 @@ const useMintPerp = (marketAddr) => {
1730
1729
  const { data: operators = [] } = await refetchOperators();
1731
1730
  const userPerms = operatorAddr ? operators.find((o) => o.operatorAddr.toLowerCase() === operatorAddr.toLowerCase()) : void 0;
1732
1731
  const validStrikeTick = require_numberUtils.getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
1733
- const [premium, protocolFee] = await market.read.calculatePremium([
1732
+ const [premium, protocolFee] = await market.read.getMintFees([
1734
1733
  optionType === "CALL" ? 0 : 1,
1735
1734
  amount,
1736
1735
  validStrikeTick,
1737
1736
  duration,
1738
- 0,
1739
1737
  "0x"
1740
1738
  ]);
1741
1739
  const maxPremium = (premium + protocolFee) * 11n / 10n;
@@ -2394,9 +2392,9 @@ const useUpdateMarketFees = (marketAddr) => {
2394
2392
  const publicClient = (0, wagmi.usePublicClient)();
2395
2393
  const chainId = (0, wagmi.useChainId)();
2396
2394
  const { data: { feeStrategy, optionPricing, priceFeed } = {}, error: stateError } = useMarketState(marketAddr);
2397
- const { data: { openingFeeRate, baseFeeRate, minOpeningFee, minBaseFee, feeRecipient } = {} } = useFeeRates(feeStrategy);
2395
+ const { data: { openingFeeRate, extensionFeeRate, minOpeningFee, minExtensionFee, feeRecipient } = {} } = useFeeRates(feeStrategy);
2398
2396
  const updateMarketFees = async (rates) => {
2399
- if (openingFeeRate === void 0 || baseFeeRate === void 0 || minOpeningFee === void 0 || minBaseFee === void 0 || feeRecipient === void 0) throw new Error("Missing current fee rates");
2397
+ if (openingFeeRate === void 0 || extensionFeeRate === void 0 || minOpeningFee === void 0 || minExtensionFee === void 0 || feeRecipient === void 0) throw new Error("Missing current fee rates");
2400
2398
  if (!optionPricing || !priceFeed) throw new Error("Market state not available: " + (stateError === null || stateError === void 0 ? void 0 : stateError.message));
2401
2399
  if (!publicClient) throw new Error("Public client not available");
2402
2400
  const factoryAddr = require_numberUtils.timelockFactories[chainId].toLowerCase();
@@ -2406,9 +2404,9 @@ const useUpdateMarketFees = (marketAddr) => {
2406
2404
  functionName: "deployFeeStrategy",
2407
2405
  args: [
2408
2406
  rates.openingFeeRate ?? openingFeeRate,
2409
- rates.baseFeeRate ?? baseFeeRate,
2407
+ rates.extensionFeeRate ?? extensionFeeRate,
2410
2408
  rates.minOpeningFee ?? minOpeningFee,
2411
- rates.minBaseFee ?? minBaseFee,
2409
+ rates.minExtensionFee ?? minExtensionFee,
2412
2410
  rates.feeRecipient ?? feeRecipient
2413
2411
  ]
2414
2412
  });
@@ -2486,16 +2484,29 @@ const usePricingParams = (pricingAddr) => {
2486
2484
  minPremiumAmount
2487
2485
  };
2488
2486
  } else if (pricingModel === 1) {
2489
- const [dailyFundingRate, minFundingAmount] = (0, viem.decodeAbiParameters)([{
2490
- name: "dailyFundingRate",
2491
- type: "uint32"
2492
- }, {
2493
- name: "minFundingAmount",
2494
- type: "uint128"
2495
- }], rawData);
2487
+ const [openingRate, dailyFundingRate, minOpeningAmount, minFundingAmount] = (0, viem.decodeAbiParameters)([
2488
+ {
2489
+ name: "openingRate",
2490
+ type: "uint32"
2491
+ },
2492
+ {
2493
+ name: "dailyFundingRate",
2494
+ type: "uint32"
2495
+ },
2496
+ {
2497
+ name: "minOpeningAmount",
2498
+ type: "uint128"
2499
+ },
2500
+ {
2501
+ name: "minFundingAmount",
2502
+ type: "uint128"
2503
+ }
2504
+ ], rawData);
2496
2505
  return {
2497
2506
  model: "static",
2507
+ openingRate,
2498
2508
  dailyFundingRate,
2509
+ minOpeningAmount,
2499
2510
  minFundingAmount
2500
2511
  };
2501
2512
  }
@@ -2546,7 +2557,9 @@ const useUpdateMarketPricing = (marketAddr) => {
2546
2557
  if (!feeStrategy || !priceFeed) throw new Error("Market state not available: " + (stateError === null || stateError === void 0 ? void 0 : stateError.message));
2547
2558
  const factoryAddr = require_numberUtils.timelockFactories[chainId].toLowerCase();
2548
2559
  if (data.model === "static" && pricingData.model === "static") {
2560
+ data.openingRate ?? (data.openingRate = pricingData.openingRate);
2549
2561
  data.dailyFundingRate ?? (data.dailyFundingRate = pricingData.dailyFundingRate);
2562
+ data.minOpeningAmount ?? (data.minOpeningAmount = pricingData.minOpeningAmount);
2550
2563
  data.minFundingAmount ?? (data.minFundingAmount = pricingData.minFundingAmount);
2551
2564
  }
2552
2565
  if (data.model === "bsm" && pricingData.model === "bsm") {
@@ -2557,7 +2570,9 @@ const useUpdateMarketPricing = (marketAddr) => {
2557
2570
  data.minPremiumAmount ?? (data.minPremiumAmount = pricingData.minPremiumAmount);
2558
2571
  }
2559
2572
  if (data.model !== pricingData.model) if (data.model === "static") {
2573
+ if (data.openingRate === void 0) throw new Error("openingRate is required when switching to static model");
2560
2574
  if (data.dailyFundingRate === void 0) throw new Error("dailyFundingRate is required when switching to static model");
2575
+ if (data.minOpeningAmount === void 0) throw new Error("minOpeningAmount is required when switching to static model");
2561
2576
  if (data.minFundingAmount === void 0) throw new Error("minFundingAmount is required when switching to static model");
2562
2577
  } else {
2563
2578
  if (data.logicContract === void 0) throw new Error("logicContract is required when switching to option model");
@@ -2570,7 +2585,12 @@ const useUpdateMarketPricing = (marketAddr) => {
2570
2585
  address: factoryAddr,
2571
2586
  abi: require_factory.factoryAbi,
2572
2587
  functionName: "deployStaticPerpsPricing",
2573
- args: [data.dailyFundingRate, data.minFundingAmount]
2588
+ args: [
2589
+ data.openingRate,
2590
+ data.dailyFundingRate,
2591
+ data.minOpeningAmount,
2592
+ data.minFundingAmount
2593
+ ]
2574
2594
  }) : await writeContractAsync({
2575
2595
  address: factoryAddr,
2576
2596
  abi: require_factory.factoryAbi,