timelock-sdk 0.0.156 → 0.0.159

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 (31) hide show
  1. package/dist/abis.cjs +1 -1
  2. package/dist/abis.d.cts +1 -1
  3. package/dist/abis.d.ts +1 -1
  4. package/dist/abis.js +1 -1
  5. package/dist/{client-DfG9023x.d.ts → client-C5uUBjks.d.ts} +12373 -3243
  6. package/dist/{client-L8_H45kU.d.cts → client-COCvyyDy.d.cts} +12456 -3326
  7. package/dist/client.cjs +331 -7
  8. package/dist/client.cjs.map +1 -1
  9. package/dist/client.d.cts +3 -3
  10. package/dist/client.d.ts +3 -3
  11. package/dist/client.js +332 -9
  12. package/dist/client.js.map +1 -1
  13. package/dist/{optionUtils-Daz9iARj.cjs → optionUtils-B-TKN7Ni.cjs} +10 -3
  14. package/dist/optionUtils-B-TKN7Ni.cjs.map +1 -0
  15. package/dist/{optionUtils-B7EA45zY.js → optionUtils-CL-MSoFS.js} +5 -4
  16. package/dist/optionUtils-CL-MSoFS.js.map +1 -0
  17. package/dist/{optionsMarket-CT26uUTa.js → optionsMarket-BbXpQnpV.js} +193 -148
  18. package/dist/optionsMarket-BbXpQnpV.js.map +1 -0
  19. package/dist/{optionsMarket-T7r7iDKa.cjs → optionsMarket-DtjLm46g.cjs} +193 -148
  20. package/dist/optionsMarket-DtjLm46g.cjs.map +1 -0
  21. package/dist/package.cjs +3 -2
  22. package/dist/package.d.cts +3 -3
  23. package/dist/package.d.ts +3 -3
  24. package/dist/package.js +3 -3
  25. package/dist/{uniswapMathLens-DNbMIHSs.d.ts → uniswapMathLens-BoQxBJoY.d.cts} +95 -51
  26. package/dist/{uniswapMathLens-DT3TTcQa.d.cts → uniswapMathLens-Ds8UmCMU.d.ts} +95 -51
  27. package/package.json +1 -1
  28. package/dist/optionUtils-B7EA45zY.js.map +0 -1
  29. package/dist/optionUtils-Daz9iARj.cjs.map +0 -1
  30. package/dist/optionsMarket-CT26uUTa.js.map +0 -1
  31. package/dist/optionsMarket-T7r7iDKa.cjs.map +0 -1
package/dist/client.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
 
4
- const require_optionUtils = require('./optionUtils-Daz9iARj.cjs');
5
- const require_optionsMarket = require('./optionsMarket-T7r7iDKa.cjs');
4
+ const require_optionUtils = require('./optionUtils-B-TKN7Ni.cjs');
5
+ const require_optionsMarket = require('./optionsMarket-DtjLm46g.cjs');
6
6
  const require_singleOwnerVault = require('./singleOwnerVault-GCpQV7pN.cjs');
7
7
  let viem = require("viem");
8
8
  let react = require("react");
@@ -638,7 +638,7 @@ const useExerciseOption = (marketAddr) => {
638
638
  //#region src/hooks/options/useMarketVolume.ts
639
639
  const useMarketVolume = (marketAddr) => {
640
640
  const { graphqlClient } = useTimelockConfig();
641
- const { data } = (0, __tanstack_react_query.useQuery)({
641
+ const { data, ...rest } = (0, __tanstack_react_query.useQuery)({
642
642
  queryKey: ["marketVolume", (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"],
643
643
  queryFn: async () => {
644
644
  const result = await graphqlClient.GetMarketVolume({ marketAddr: marketAddr.toLowerCase() });
@@ -652,7 +652,10 @@ const useMarketVolume = (marketAddr) => {
652
652
  },
653
653
  enabled: !!marketAddr && !!graphqlClient
654
654
  });
655
- return data || {};
655
+ return {
656
+ data: data || {},
657
+ ...rest
658
+ };
656
659
  };
657
660
 
658
661
  //#endregion
@@ -814,14 +817,13 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, r
814
817
  address: marketAddr,
815
818
  abi: require_optionsMarket.optionsMarketAbi,
816
819
  functionName: "calculatePremium",
817
- args: strikeTickRounded !== void 0 ? [
820
+ args: strikeTickRounded !== void 0 && optionAmount !== void 0 && addedDuration !== void 0 ? [
818
821
  optionType === "CALL" ? 0 : 1,
819
822
  optionAmount,
820
823
  strikeTickRounded,
821
824
  addedDuration,
822
825
  remainingDuration
823
- ] : void 0,
824
- query: { enabled: strikeTickRounded !== void 0 }
826
+ ] : void 0
825
827
  });
826
828
  return (0, react.useMemo)(() => {
827
829
  if (premium === void 0 || protocolFee === void 0 || payoutAssetDecimals === void 0) return {};
@@ -2196,6 +2198,327 @@ const useFeeRates = (feeStrategy) => {
2196
2198
  return data || {};
2197
2199
  };
2198
2200
 
2201
+ //#endregion
2202
+ //#region src/hooks/options/useMarketState.ts
2203
+ const useMarketState = (marketAddr) => {
2204
+ const { timelockLens } = useLens();
2205
+ const { data, ...rest } = (0, wagmi.useReadContract)({
2206
+ address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
2207
+ abi: require_optionsMarket.lensAbi,
2208
+ functionName: "getMarketState",
2209
+ args: marketAddr ? [marketAddr] : void 0
2210
+ });
2211
+ return {
2212
+ data: data || {},
2213
+ ...rest
2214
+ };
2215
+ };
2216
+
2217
+ //#endregion
2218
+ //#region src/abis/factory.ts
2219
+ const factoryAbi = [
2220
+ {
2221
+ type: "function",
2222
+ name: "deployFeeStrategy",
2223
+ inputs: [
2224
+ {
2225
+ name: "_openingFeeRate",
2226
+ type: "uint32",
2227
+ internalType: "uint32"
2228
+ },
2229
+ {
2230
+ name: "_baseFeeRate",
2231
+ type: "uint32",
2232
+ internalType: "uint32"
2233
+ },
2234
+ {
2235
+ name: "_minOpeningFee",
2236
+ type: "uint128",
2237
+ internalType: "uint128"
2238
+ },
2239
+ {
2240
+ name: "_minBaseFee",
2241
+ type: "uint128",
2242
+ internalType: "uint128"
2243
+ },
2244
+ {
2245
+ name: "_feeRecipient",
2246
+ type: "address",
2247
+ internalType: "address"
2248
+ }
2249
+ ],
2250
+ outputs: [{
2251
+ name: "",
2252
+ type: "address",
2253
+ internalType: "contract FeeStrategy"
2254
+ }],
2255
+ stateMutability: "nonpayable"
2256
+ },
2257
+ {
2258
+ type: "function",
2259
+ name: "deployOptionPricing",
2260
+ inputs: [
2261
+ {
2262
+ name: "_logicContract",
2263
+ type: "address",
2264
+ internalType: "contract StatelessOptionPricing"
2265
+ },
2266
+ {
2267
+ name: "_iv",
2268
+ type: "uint32",
2269
+ internalType: "uint32"
2270
+ },
2271
+ {
2272
+ name: "_riskFreeRate",
2273
+ type: "uint32",
2274
+ internalType: "uint32"
2275
+ },
2276
+ {
2277
+ name: "_minPremiumDailyRate",
2278
+ type: "uint32",
2279
+ internalType: "uint32"
2280
+ },
2281
+ {
2282
+ name: "_minPremiumAmount",
2283
+ type: "uint256",
2284
+ internalType: "uint256"
2285
+ }
2286
+ ],
2287
+ outputs: [{
2288
+ name: "",
2289
+ type: "address",
2290
+ internalType: "contract OptionPricing"
2291
+ }],
2292
+ stateMutability: "nonpayable"
2293
+ },
2294
+ {
2295
+ type: "function",
2296
+ name: "deployStaticPerpsPricing",
2297
+ inputs: [{
2298
+ name: "_dailyFundingRate",
2299
+ type: "uint32",
2300
+ internalType: "uint32"
2301
+ }, {
2302
+ name: "_minFundingAmount",
2303
+ type: "uint128",
2304
+ internalType: "uint128"
2305
+ }],
2306
+ outputs: [{
2307
+ name: "",
2308
+ type: "address",
2309
+ internalType: "contract StaticPerpsPricing"
2310
+ }],
2311
+ stateMutability: "nonpayable"
2312
+ },
2313
+ {
2314
+ type: "function",
2315
+ name: "feeStrategies",
2316
+ inputs: [{
2317
+ name: "",
2318
+ type: "bytes32",
2319
+ internalType: "bytes32"
2320
+ }],
2321
+ outputs: [{
2322
+ name: "",
2323
+ type: "address",
2324
+ internalType: "contract FeeStrategy"
2325
+ }],
2326
+ stateMutability: "view"
2327
+ },
2328
+ {
2329
+ type: "function",
2330
+ name: "optionPricings",
2331
+ inputs: [{
2332
+ name: "",
2333
+ type: "bytes32",
2334
+ internalType: "bytes32"
2335
+ }],
2336
+ outputs: [{
2337
+ name: "",
2338
+ type: "address",
2339
+ internalType: "contract OptionPricing"
2340
+ }],
2341
+ stateMutability: "view"
2342
+ },
2343
+ {
2344
+ type: "function",
2345
+ name: "staticPerpsPricings",
2346
+ inputs: [{
2347
+ name: "",
2348
+ type: "bytes32",
2349
+ internalType: "bytes32"
2350
+ }],
2351
+ outputs: [{
2352
+ name: "",
2353
+ type: "address",
2354
+ internalType: "contract StaticPerpsPricing"
2355
+ }],
2356
+ stateMutability: "view"
2357
+ },
2358
+ {
2359
+ type: "event",
2360
+ name: "DeployFeeStrategy",
2361
+ inputs: [
2362
+ {
2363
+ name: "feeStrategy",
2364
+ type: "address",
2365
+ indexed: true,
2366
+ internalType: "contract FeeStrategy"
2367
+ },
2368
+ {
2369
+ name: "openingFeeRate",
2370
+ type: "uint32",
2371
+ indexed: false,
2372
+ internalType: "uint32"
2373
+ },
2374
+ {
2375
+ name: "baseFeeRate",
2376
+ type: "uint32",
2377
+ indexed: false,
2378
+ internalType: "uint32"
2379
+ },
2380
+ {
2381
+ name: "minOpeningFee",
2382
+ type: "uint128",
2383
+ indexed: false,
2384
+ internalType: "uint128"
2385
+ },
2386
+ {
2387
+ name: "minBaseFee",
2388
+ type: "uint128",
2389
+ indexed: false,
2390
+ internalType: "uint128"
2391
+ },
2392
+ {
2393
+ name: "feeRecipient",
2394
+ type: "address",
2395
+ indexed: false,
2396
+ internalType: "address"
2397
+ }
2398
+ ],
2399
+ anonymous: false
2400
+ },
2401
+ {
2402
+ type: "event",
2403
+ name: "DeployOptionPricing",
2404
+ inputs: [
2405
+ {
2406
+ name: "pricing",
2407
+ type: "address",
2408
+ indexed: true,
2409
+ internalType: "contract OptionPricing"
2410
+ },
2411
+ {
2412
+ name: "statelessPricing",
2413
+ type: "address",
2414
+ indexed: false,
2415
+ internalType: "contract StatelessOptionPricing"
2416
+ },
2417
+ {
2418
+ name: "iv",
2419
+ type: "uint32",
2420
+ indexed: false,
2421
+ internalType: "uint32"
2422
+ },
2423
+ {
2424
+ name: "riskFreeRate",
2425
+ type: "uint32",
2426
+ indexed: false,
2427
+ internalType: "uint32"
2428
+ },
2429
+ {
2430
+ name: "minPremiumDailyRate",
2431
+ type: "uint32",
2432
+ indexed: false,
2433
+ internalType: "uint32"
2434
+ },
2435
+ {
2436
+ name: "minPremiumAmount",
2437
+ type: "uint256",
2438
+ indexed: false,
2439
+ internalType: "uint256"
2440
+ }
2441
+ ],
2442
+ anonymous: false
2443
+ },
2444
+ {
2445
+ type: "event",
2446
+ name: "DeployStaticPerpsPricing",
2447
+ inputs: [
2448
+ {
2449
+ name: "pricing",
2450
+ type: "address",
2451
+ indexed: true,
2452
+ internalType: "contract StaticPerpsPricing"
2453
+ },
2454
+ {
2455
+ name: "dailyFundingRate",
2456
+ type: "uint32",
2457
+ indexed: false,
2458
+ internalType: "uint32"
2459
+ },
2460
+ {
2461
+ name: "minFundingAmount",
2462
+ type: "uint128",
2463
+ indexed: false,
2464
+ internalType: "uint128"
2465
+ }
2466
+ ],
2467
+ anonymous: false
2468
+ }
2469
+ ];
2470
+
2471
+ //#endregion
2472
+ //#region src/hooks/fees/useUpdateMarketFees.ts
2473
+ const useUpdateMarketFees = (marketAddr) => {
2474
+ const { writeContractAsync, ...rest } = (0, wagmi.useWriteContract)();
2475
+ const publicClient = (0, wagmi.usePublicClient)();
2476
+ const chainId = (0, wagmi.useChainId)();
2477
+ const { data: { feeStrategy, optionPricing } } = useMarketState(marketAddr);
2478
+ const { openingFeeRate, baseFeeRate, minOpeningFee, minBaseFee, feeRecipient } = useFeeRates(feeStrategy);
2479
+ const updateMarketFeeRates = async (rates) => {
2480
+ if (openingFeeRate === void 0 || baseFeeRate === void 0 || minOpeningFee === void 0 || minBaseFee === void 0 || feeRecipient === void 0) throw new Error("Missing current fee rates");
2481
+ if (!optionPricing) throw new Error("Could not load market state");
2482
+ if (!publicClient) throw new Error("Public client not available");
2483
+ const factoryAddr = require_optionUtils.timelockFactories[chainId].toLowerCase();
2484
+ const hash = await writeContractAsync({
2485
+ address: factoryAddr,
2486
+ abi: factoryAbi,
2487
+ functionName: "deployFeeStrategy",
2488
+ args: [
2489
+ rates.openingFeeRate ?? openingFeeRate,
2490
+ rates.baseFeeRate ?? baseFeeRate,
2491
+ rates.minOpeningFee ?? minOpeningFee,
2492
+ rates.minBaseFee ?? minBaseFee,
2493
+ rates.feeRecipient ?? feeRecipient
2494
+ ]
2495
+ });
2496
+ const deployEvent = (await publicClient.waitForTransactionReceipt({ hash })).logs.find((log) => log.address.toLowerCase() === factoryAddr);
2497
+ if (!deployEvent) throw new Error("DeployFeeStrategy event not found");
2498
+ const decodedEvent = (0, viem.decodeEventLog)({
2499
+ abi: factoryAbi,
2500
+ data: deployEvent.data,
2501
+ topics: deployEvent.topics
2502
+ });
2503
+ if (decodedEvent.eventName !== "DeployFeeStrategy") throw new Error("Unexpected event");
2504
+ const newFeeStrategy = decodedEvent.args.feeStrategy;
2505
+ return {
2506
+ deployHash: hash,
2507
+ updateHash: await writeContractAsync({
2508
+ address: marketAddr,
2509
+ abi: require_optionsMarket.optionsMarketAbi,
2510
+ functionName: "updateAddresses",
2511
+ args: [optionPricing, newFeeStrategy]
2512
+ }),
2513
+ newFeeStrategy
2514
+ };
2515
+ };
2516
+ return {
2517
+ updateMarketFeeRates,
2518
+ ...rest
2519
+ };
2520
+ };
2521
+
2199
2522
  //#endregion
2200
2523
  exports.TimelockProvider = TimelockProvider;
2201
2524
  exports.batchGetAmountsFromLiquidity = batchGetAmountsFromLiquidity;
@@ -2237,6 +2560,7 @@ exports.useSetOperatorPerms = useSetOperatorPerms;
2237
2560
  exports.useTimelockConfig = useTimelockConfig;
2238
2561
  exports.useTokenBalance = useTokenBalance;
2239
2562
  exports.useTokenData = useTokenData;
2563
+ exports.useUpdateMarketFees = useUpdateMarketFees;
2240
2564
  exports.useUserOperators = useUserOperators;
2241
2565
  exports.useUserPerps = useUserPerps;
2242
2566
  exports.useVaultData = useVaultData;